[no-unused-vars] flagged though it is used inside an object
See original GitHub issueTell us about your environment
- ESLint Version: 6.6.0 as well as 7.0.0
- Node Version: 12.16.3
- npm Version: 6.14.4
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
{
"env": {
"browser": true,
"es6": true,
"jquery": true
},
"extends": [
"airbnb-base",
"plugin:prettier/recommended"
],
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module"
},
"plugins": ["prettier"],
"rules": {
"camelcase": "off",
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
let placedAt = 0;
let placedAt = myFunction({
previous: placedAt
});
eslint js/
What did you expect to happen? eslint finishing without an error.
What actually happened? Please include the actual, raw output from ESLint.
eslint complains with error 'placedAt' is assigned a value but never used no-unused-vars
.
While the placedAt
variable is used inside the object given to myFunction
function
Are you willing to submit a pull request to fix this bug? I could try, though my time and JS-foo is not so good, but given some guidance I can give it a try.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
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 >typescript-eslint/no-unused-vars does not work correctly
Add these line to your eslintrc.js file under rules : "no-use-before-define": "off", "@typescript-eslint/no-use-before-define": ["error"],.
Read more >How to disable "no-unused-vars" in Visual Studio Code (or at ...
One thing that annoys the heck out of me, though, is Visual Studio Code's ESLint plugin marking any unused variable or argument as...
Read more >12 essential ESLint rules for React - LogRocket Blog
If the project is using the no-unused-vars rule, this results in an error since React is imported but not used anywhere.
Read more >Turning on checking for a rule - ESLint - LinkedIn
It's common to use a style guide as a starting point and then customize it ... I see it also in the pop-up...
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
Hi @gforcada,
The logic is the same as before: On the last reassignment, you could just call the function for its side effects, without reassigning the variable.
Or you can add another usage:
Basically, the last assignment is what is unused here. Either drop that reassignment, or use the variable again, and the rule will be satisfied.
Are you sure you want to redeclare
placedAt
?Seems this would make more sense:
Also, no-unused-vars is expecting another use of
placedAt
after the reassignment. With the code you have provided, you could callmyFunction
without assigning the result, and this would both satisfy the rule and have no observable effect on behavior:If you do intend to reassign to
placedAt
, simply use it later in the code, and the rule will be satisfied.