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]: reporter should report the last reference instead of declaration #13181
Comments
Thanks for writing this up. Just to make sure I understand, you’re suggesting that the last reference of an unused variable be highlighted? And if there is only a declaration then the declaration is highlighted? |
Yes |
That sounds good to me. It would be nice if we could use a clearer message to, something like "The value of variable foo is never used after this assignment" or something similar. |
much better 👍 |
This bug confused me (as shown in 13227).
eslint reports line 1 of |
I have submitted the PR #13354 to move this issue forward quickly. |
What rule do you want to change?
no-unused-vars
Does this change cause the rule to produce more or fewer warnings?
same
How will the change be implemented? (New option, new default behavior, etc.)?
default
Please provide some example code that this change will affect:
Currently, the reporter reports the location in a declaration of a variable which is fine but not for all cases.
case 1
case2
In this way, it makes easy to track the error if any.
Another advantage of reporting this way is many editors do provide shortcut keys to jump to the declaration of any variable/function but the opposite is not true for some.
ref : #12871, #13172
What does the rule currently do for this code?
reports in the variable declaration
What will the rule do after it's changed?
reports in the last reference of the variable if the variable is being self-referred
Are you willing to submit a pull request to implement this change?
Yes
The text was updated successfully, but these errors were encountered: