New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no-unused-vars does not report error when comma operator is used #14325
Comments
This is occurring because of the This looks like a bug but I’d like another set of eyes. @eslint/eslint-tsc |
The increment operator also writes (to itself) after reading. let x = 0;
x++;
^ let x = 0;
x++; x = 0;
^ |
It appears you’re right. Here is an example without the increment operator that makes it clear: let x = 0;
x=2, x = 0;
x = 3; |
I will take this issue 👍🏻 |
seems it was not exactly related to comma operator. imagine this code: var a;
a; // => rvalue
and these cases can be caught by some other rules: var a;
a; // => caught by no-unused-expressions var a;
a, b; // caught by no-sequences |
I think it's fine to not account for this in
|
With
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:
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
The text was updated successfully, but these errors were encountered: