-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Parameter "varsIgnorePattern" should ensure that they will never be read #13183
Comments
just to make sure I am getting this correctly, you need to report a variable that are in ignore list whenever they are read or written? or just read? according to your example, if you don't want to use those variables - const [_name, _age, job, _nationality, address] = person
+ const [ , , , , job, , , address] = person cause as per the required, no need of having those variables in the first place. maybe I am missing something. let me know 👍 |
@anikethsaha Thank you for the reply =] IMO is strange to write |
this means that the variable is being used. it will be lint-free.
so you meant something strict in which ignore variables should not be used at all? maybe I am not getting the proposal correctly, can you give some more example for this. |
@macabeus thanks for the issue! This is certainly an interesting proposal. I don't have a strong opinion at the moment on whether this feature belongs to this rule. Enforcing naming conventions seem to be beyond the scope of responsibility for On the other hand, this looks useful, and duplicating the configured patterns and the overall logic for unused vars in another rule might not make sense. |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
What rule do you want to change?
no-unused-vars
Does this change cause the rule to produce more or fewer warnings?
Nop
How will the change be implemented? (New option, new default behavior, etc.)?
Currently, we could set the parameter
varsIgnorePattern
onno-unused-vars
to ignore some patterns on variables that we expected that will be assigned but never reader.A common convention on others languages is to add a landing
_
on a variable that is never read. On JS it's useful, for example, on array destructuring:So if a variable follow the pattern, the expected is to be never read, so it'll should show an error:
Would be useful to have a configuration to set that. Something like
showErrorWhenReadIgnoredVariable: true
Please provide some example code that this change will affect:
It's an additional feature and won't break any current code.
What does the rule currently do for this code?
Set variables that we can write but never read.
What will the rule do after it's changed?
It'll be possible to use the parameter
showErrorWhenReadIgnoredVariable
.Are you willing to submit a pull request to implement this change?
I could do that.
The text was updated successfully, but these errors were encountered: