Skip to content
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

Merged
merged 1 commit into from Aug 31, 2017

Conversation

TheSavior
Copy link
Contributor

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?

@jsf-clabot
Copy link

jsf-clabot commented Aug 28, 2017

CLA assistant check
All committers have signed the CLA.

@mention-bot
Copy link

@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.

{
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 }]
Copy link
Member

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 /^_/.

Copy link
Contributor Author

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.

@not-an-aardvark
Copy link
Member

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.

@TheSavior TheSavior changed the title [WIP] no-unused-vars: Improve error messages to include the allowed patterns no-unused-vars: Improve error messages to include the allowed patterns Aug 29, 2017
@TheSavior TheSavior force-pushed the no-unused-vars-messages branch 3 times, most recently from 87f19bc to 2dd2407 Compare August 29, 2017 18:18
@not-an-aardvark not-an-aardvark added enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules labels Aug 29, 2017
@eslintbot
Copy link

LGTM

@eslint eslint deleted a comment from eslintbot Aug 29, 2017
@eslint eslint deleted a comment from eslintbot Aug 29, 2017
@eslint eslint deleted a comment from eslintbot Aug 29, 2017
@eslint eslint deleted a comment from eslintbot Aug 29, 2017
@eslint eslint deleted a comment from eslintbot Aug 29, 2017
@eslint eslint deleted a comment from eslintbot Aug 29, 2017
@eslint eslint deleted a comment from eslintbot Aug 29, 2017
@eslint eslint deleted a comment from eslintbot Aug 29, 2017
@TheSavior
Copy link
Contributor Author

Yay! It builds successfully.

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 31, 2017
@not-an-aardvark not-an-aardvark merged commit 2db356b into eslint:master Aug 31, 2017
@TheSavior TheSavior deleted the no-unused-vars-messages branch September 1, 2017 00:09
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 28, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants