no-unused-vars does not report error when comma operator is used
See original GitHub issueWith no-unused-vars
enabled eslint does not mark a variable as unused if assignment is combined with the comma operator.
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Both produce no warning:
let x = 0;
x++, x = 0;
let x = 0;
x++, x = 0;
x = 3;
What did you expect to happen? It should mark the last occurance of x as an unused variable.
What actually happened? Please copy-paste the actual, raw output from ESLint. eslint thinks everything is fine.
Steps to reproduce this issue:
Are you willing to submit a pull request to fix this bug? No
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 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 >C static code analysis: Comma operator should not be used
It is especially error-prone in array subscripts where it might be misinterpreted as accessing a multidimensional array. The use of a comma in...
Read more >Disallow Use of the Comma Operator (no-sequences) - ESLint
Disallow Use of the Comma Operator (no-sequences). The comma operator includes multiple expressions where only one is expected. It evaluates each operand ...
Read more >comma-dangle | typescript-eslint
Examples. This rule extends the base eslint/comma-dangle rule. It adds support for TypeScript syntax. See the ESLint documentation for more details on the ......
Read more >Rules - JavaScript Standard Style
Rules · No unused variables. · Add a space after keywords. · Add a space before a function declaration's parentheses. · Multiple blank...
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
I will take this issue 👍🏻
This is occurring because of the
x++
, not because of the comma operator. The post fix increment operation counts as both a read and a write, which is why there is no warning.This looks like a bug but I’d like another set of eyes. @eslint/eslint-tsc