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 error message should provide hint on ignorePattern. #9171

Closed
TheSavior opened this issue Aug 28, 2017 · 9 comments
Closed

no-unused-vars error message should provide hint on ignorePattern. #9171

TheSavior opened this issue Aug 28, 2017 · 9 comments
Assignees
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

Comments

@TheSavior
Copy link
Contributor

We use no-unused-vars but provide allowed patterns for ignored vars and args.

"no-unused-vars": [1, {"vars": "all", varsIgnorePattern: "^_", "args": "all", "argsIgnorePattern": "^_"}],

With this code:

/* eslint no-unused-vars: [2, {"vars": "all", varsIgnorePattern: "^_", "args": "all", "argsIgnorePattern": "^_"}] */

[1,2,3].map((item, index, array) => {
  return item / array.length;
});

We get this error:

3:20 - 'index' is defined but never used. (no-unused-vars)

It is unreasonable for our engineers to be aware of our allowed pattern in the configuration and this warning will instead cause people to go through lots of work and confusion to get eslint to pass, or they will just turn it off.

I think a more valuable warning message would be something like this:

3:20 - 'index' is defined but never used. If this is intentional, consider matching the allowed unused argument pattern /^_/ (no-unused-vars)
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 28, 2017
@platinumazure platinumazure 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 and removed triage An ESLint team member will look at this issue soon labels Aug 28, 2017
@platinumazure
Copy link
Member

I'm 👍 to this as long as we can find a way to shorten the message a bit.

@TheSavior
Copy link
Contributor Author

> 'is defined but never used. If this is intentional, consider matching the allowed unused argument pattern'.length
104

> 'is defined but never used. Allowed unused args must match'.length
57

How do you feel about that?

@platinumazure
Copy link
Member

How do you feel about that?

Works for me, thanks.

@TheSavior
Copy link
Contributor Author

I modified the tests to reflect the new error messages. If those look good, we can update the rule to make them pass. I just want to make sure I'm covering the cases and people are happy with it before putting in the work on the rule.

@TheSavior
Copy link
Contributor Author

What is the path forward to getting this tagged as "accepted" instead of "evaluating"?

@platinumazure
Copy link
Member

@TheSavior We will accept the issue when enough people on the ESLint core team have supported the issue that we have reached consensus. This means one champion and three 👍s from other team members.

I'll champion. So we need two more 👍s (mine no longer counts).

@eslint/eslint-team Anyone else want to support this? I think this would be a small but very useful improvement to the messaging for this rule.

@platinumazure platinumazure self-assigned this Aug 30, 2017
@kaicataldo kaicataldo 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
@kaicataldo
Copy link
Member

kaicataldo commented Aug 31, 2017

This is now accepted.

@TheSavior
Copy link
Contributor Author

Yay, great. Any more comments on the PR would be great, otherwise that is good to go as well. #9176

@kaicataldo
Copy link
Member

It looks like we missed the fixes message on the PR. This was closed in #9176.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 12, 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 Apr 12, 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

No branches or pull requests

4 participants