ESLint 6.2.2 + babel-eslint 10.0.3 + no-unused-vars false positive with for-of loop
See original GitHub issueTell us about your environment
- ESLint Version: 6.2.2
- Node Version: 12.6.0
- npm Version: 6.11.2
What parser (default, Babel-ESLint, etc.) are you using?
Babel-ESLint 10.0.3
Also tried Babel-ESLint 10.0.2
but ran into https://github.com/eslint/eslint/issues/12117. Following the advice there, I tried running 10.0.3
Please show your full configuration:
Configuration
{
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
generators: true,
experimentalObjectRestSpread: true
}
},
extends: ["airbnb"],
rules: {
'react/sort-comp': 0,
"react/require-default-props": 0,
"react/forbid-prop-types": ['error', { forbid: ['any', 'array']}],
"react/destructuring-assignment": 0,
"react/static-property-placement": ['error', 'static public field'],
"react/state-in-constructor": 0,
"react/jsx-props-no-spreading": 0,
"linebreak-style": 0,
"function-paren-newline": ['error', 'consistent'],
"object-curly-newline": ['error', { 'consistent': true }],
"babel/semi": 2,
"no-param-reassign": ['error', { props: false }],
"arrow-parens": ['error', 'as-needed', { "requireForBlockBody": true }],
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
for (const type of TYPES) {
const itemsOfType = items.filter(item => item.__typename === type);
}
for (const [name, offset] of items) {
if (offset >= scrollTop) {
this.setState({ active: name });
return;
}
}
npm run lint
What did you expect to happen? Get no errors
What actually happened? Please include the actual, raw output from ESLint.
98:10 error 'type' is defined but never used no-unused-vars
126:15 error 'name' is defined but never used no-unused-vars
126:21 error 'offset' is defined but never used no-unused-vars
Are you willing to submit a pull request to fix this bug? Yes, but I can’t commit to it in the next couple of weeks
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
ESLint 6.2.0 + babel-eslint + no-unused-vars false positive ...
The variable keyword from the for-in loop is seen as not used. This may be a bug in babel-eslint since the issue does...
Read more >no-unused-vars - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Why am I getting a 'no-unused-vars' warning in a for... ...
Please upgrade the babel-eslint package to version 10.0.3 . This will most likely fix those false-positives where vars are used inside loops ......
Read more >no-unused-vars - TypeScript ESLint
no -unused-vars. Disallow unused variables. ✓. Extending "plugin:@typescript-eslint/recommended" in an ESLint configuration enables this rule.
Read more >eslint-plugin-no-unused-vars-rest - npm package
Learn more about eslint-plugin-no-unused-vars-rest: package health score, popularity, security, maintenance, versions and more.
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 FreeTop 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
Top GitHub Comments
@camyyssa It looks like your babel-eslint is still using the old eslint-scope for some reason. Try blowing away the node_modules and rerunning
npm install
, does that resolve your issue?😳 It does!
I could have found the steps to resolve this on my own 😊. Sorry to waste your time @platinumazure 🙂 but thank you so much for the help!
For future me, and in case you stumble on this post because you have the same problem:
node-modules
, and try again