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 argsIgnorePattern affecting "args": "after-used" since 3.6.0 #7250

Closed
danpoltawski opened this issue Sep 26, 2016 · 5 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 bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@danpoltawski
Copy link

danpoltawski commented Sep 26, 2016

Tell us about your environment

  • ESLint Version: v3.6.0
  • Node Version: v6.6.0
  • npm Version: 3.10.7

What parser (default, Babel-ESLint, etc.) are you using? deafult

Please show your full configuration: https://github.com/moodle/moodle/blob/master/.eslintrc

What did you do? Please include the actual source code causing the issue.

When attempting to upgrade to eslint 3.6.0, we got some new errors reported by no-unused-vars which should have been ignored by args: 'after-used'. It turned out that argsIgnorePattern is now affecting the result of things which should be ignored by "args": "after-used"

I attempted to isolate the code down to the smallest test case:

Problem file:

/* eslint 'no-unused-vars': ['error', {"args": "after-used", "argsIgnorePattern": "^baz$"}] */

(function(foo, bar, baz) {
        return baz;
})();

Output:

$ eslint problem.js 

/Users/danp/www/eslintest/problem.js
  3:16  error  'bar' is defined but never used  no-unused-vars

✖ 1 problem (1 error, 0 warnings)

Ok file:

/* eslint 'no-unused-vars': ['error', {"args": "after-used"}] */

(function(foo, bar, baz) {
        return baz;
})();
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Sep 26, 2016
@danpoltawski
Copy link
Author

(Note: this was detected because we have our argsIgnorePattern too liberally matching by mistake)

@not-an-aardvark
Copy link
Member

This was probably caused by #7143.

I think the issue is that we now check for the last non-ignored parameter (in your case, bar) rather than the last parameter itself (baz). However, we don't account for cases where an ignored parameter is used.

@platinumazure platinumazure added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Sep 26, 2016
@platinumazure
Copy link
Member

Confirmed in the online demo. I think this is something we should consider for a patch release, if possible.

@mysticatea
Copy link
Member

mysticatea commented Sep 27, 2016

Thank you for this issue.

Though I'd like to say this is intentional since baz is ignored, we should fix this issue to prevent a breaking change without major version up.
I will work on this within today (JST).

By the way, I'm interested in the option which warns such access to ignored variables. Maybe disallowUseIgnored. Or a separated rule such as no-use-ignored-vars.

@mysticatea mysticatea self-assigned this Sep 27, 2016
@danpoltawski
Copy link
Author

Thanks! As mentioned above - in our case it was caused by a misconfiguration of argsIgnorePattern which matched a lot of args, so I am not sure how much you should be concerned about this being a problem in practice.

@nzakas nzakas closed this as completed in dffb4fa Sep 30, 2016
danpoltawski added a commit to danpoltawski/moodle that referenced this issue Oct 7, 2016
1) Bump eslint verson in npm
2) Enable tabs rule introduced in 3.2.0
3) With rules deprecated in 3.3.0 to their replacements
   http://eslint.org/blog/2016/08/eslint-v3.3.0-released
4) Deprecate the use of M.str (fixes MDLSITE-3646) with new
   no-restricted-properties introduced in 3.5.0
5) Fixup no-unused-vars - remove argsIgnorePattern which shouldn't have allowed
   partial matches and turns out to be uncesssary
   (detected because of eslint/eslint#7250 in 3.6.0)
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 6, 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 bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

5 participants