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: Improve error messages to include the allowed patterns #9176
no-unused-vars: Improve error messages to include the allowed patterns #9176
Conversation
@TheSavior, thanks for your PR! By analyzing the history of the files in this pull request, we identified @not-an-aardvark, @mysticatea and @nzakas to be potential reviewers. |
tests/lib/rules/no-unused-vars.js
Outdated
{ | ||
code: "var _a; var b;", | ||
options: [{ vars: "all", varsIgnorePattern: "^_" }], | ||
errors: [{ message: "'b' is defined but never used. Allowed unused vars must match '^_'", line: 1, column: 13 }] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of surrounding the matcher with single quotes, would it be better to surround it with /
characters instead to clarify that it's a regex?
'b' is defined but never used. Allowed unused vars must match /^_/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I've wondered that and I agree it makes it more clear that it is a regex.
The report messages look good to me. As a nitpick, I think we generally try to make report messages end in a period, but it's not a big deal either way. |
87f19bc
to
2dd2407
Compare
2dd2407
to
a8d26f6
Compare
a8d26f6
to
bf447e0
Compare
LGTM |
Yay! It builds successfully. |
This is a WIP and is just providing an implementation of tests to ensure the cases are satisfactory before updating the rule.
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What rule do you want to change?
no-unused-vars
Does this change cause the rule to produce more or fewer warnings?
Neither
How will the change be implemented? (New option, new default behavior, etc.)?
Updating the error messages
Please provide some example code that this change will affect:
See #9171
What changes did you make? (Give an overview)
Improving the error messages to give a hint as to what the allowed pattern is.
Is there anything you'd like reviewers to focus on?