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 highlights at wrong position #14324
Comments
Confirmed. We are probably just highlighting the last reference. |
@nzakas If there are no objections I will work on a fix for this one. |
@snitin315 please feel free to open a PR! 😄 |
I see here https://github.com/eslint/eslint/blob/master/lib/rules/no-unused-vars.js#L628-L630 that it reports the last reference whenever there are multiple references. How should we check if we want to report the last one or any other one? |
I'd prefer report the var where it was defined. But let's see what the others' thoughts. :) |
@aladdin-add we chose to highlight the last reference because that’s where the most likely error is. It’s easy to find the declaration but that last reference might not be obvious. @snitin315 basically, you want the last write reference. You can tell by using |
With
no-unused-vars
enabled eslint highlights the last use of the variable. If it is used left and right of an assignment it should mark the one on the left.What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Instead of this:
What did you expect to happen?
It should be this:
What actually happened? Please copy-paste the actual, raw output from ESLint.
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: