@babel/eslint-parser false positive for no-unused-vars rule with TypeScript types
See original GitHub issueBug Report
- I would like to work on a fix!
Current behavior @babel/eslint-parser gives false positive (shows error) for no-unused-vars rule with TypeScript types:
error 'Rubik' is defined but never used no-unused-vars
Input Code
import Rubik from './Rubik';
export default class Arranger {
private readonly rubik: Rubik;
}
Expected behavior When run eslint, no errors/warnings should arise.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
- Filename:
babel.config.js
{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"
],
"plugins": [
"@babel/proposal-class-properties"
]
}
- Filename:
.eslintrc.json
{
"parser": "@babel/eslint-parser",
"rules": {
"no-unused-vars": ["error"]
}
}
Environment
System:
OS: Linux 4.19 Alpine Linux
Binaries:
Node: 12.18.3 - /usr/bin/node
Yarn: 1.22.4 - /usr/bin/yarn
npmPackages:
@babel/core: ^7.10.2 => 7.11.4
@babel/eslint-parser: ^7.11.4 => 7.11.4
@babel/eslint-plugin: ^7.11.3 => 7.11.3
@babel/plugin-proposal-class-properties: ^7.8.3 => 7.10.4
@babel/preset-env: ^7.10.2 => 7.11.0
@babel/preset-typescript: ^7.9.0 => 7.10.4
eslint: 7.2.* => 7.2.0
webpack: ^4.43.0 => 4.44.1
Note This issue already existed before switching to Babel monorepo (in babel/babel-eslint) so the switch is not the cause.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
typescript-eslint/no-unused-vars false positive in type ...
Question: What's wrong with this rule and why it triggers in this case. Why eslint recognizes type declaration for functions in types/interfaces ...
Read more >Kent C. Dodds on Twitter: "Starting to think that using ...
Getting some parser errors + things like "Partial<Props>" is triggering eslint's "no-undef" rule to error out because "Partial" is not defined.
Read more >TSConfig Reference - Docs on every TSConfig option
Intro to the TSConfig Reference. A TSConfig file in a directory indicates that the directory is the root of a TypeScript or JavaScript...
Read more >parseroptions.project has been set for @typescript-eslint/parser
@bluenote10 I use both overrides.rules and rules because I need to lint different files in different ways. For example, rules contains the rules...
Read more >typescript-eslint/no-unused-vars false positive in type ...
@typescript-eslint/parser; @typescript-eslint/eslint-plugin. in your .eslintrc.js make sure you have the following lines added to rules section:
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In that case it’s all good.
Maybe this part can be mentioned in readme or docs:
Anyway, thanks for the info.
@taylankasap That’s a good idea!
@prateekbh That’s right!