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 confused when var is re-assigned with return value of function that takes it as argument #6646

Closed
ahocevar opened this issue Jul 10, 2016 · 4 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

@ahocevar
Copy link

What version of ESLint are you using?

3.0.1

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

default

Please show your full configuration:

https://github.com/openlayers/eslint-config-openlayers/blob/master/index.js

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

https://github.com/openlayers/ol3/blob/9b3c4294c146dd929ecd4c8c0188dfc01580e30c/src/ol/render/canvas/canvasreplay.js#L1085-L1090

What did you expect to happen?

Like in v2.x, I would expect that eslint does not complain, since offset is clearly used.

What actually happened? Please include the actual, raw output from ESLint.

eslint complains about offset being defined but never used:

/home/travis/build/openlayers/ol3/src/ol/render/canvas/canvasreplay.js
  1085:7  error  'offset' is defined but never used  no-unused-vars
  1357:7  error  'offset' is defined but never used  no-unused-vars

This problem came up in openlayers/openlayers#5569.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jul 10, 2016
@ilyavolodin ilyavolodin added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 10, 2016
@ilyavolodin
Copy link
Member

This should've been fixed with v3.0.1. @mysticatea could you take a quick look please?

@laurent-le-graverend
Copy link

laurent-le-graverend commented Jul 11, 2016

Having the same issue with the following code and version 3.0.1:

function someFunction() {
  var a = 0, i;
  for (i = 0; i < 2; i++) {
    a = myFunction(a);
  }
}

'a' is defined but never used (no-unused-var)

@mysticatea mysticatea self-assigned this Jul 11, 2016
@mysticatea mysticatea 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 Jul 11, 2016
@mysticatea
Copy link
Member

Thank you for this issue.
I confirmed. I will fix this.

ilyavolodin pushed a commit that referenced this issue Jul 15, 2016
* Fix: `no-unused-var` false positive in loop (fixes #6646)

* Chore: add some private tags to jsdoc comments.

* Chore: add `isFunctionNode` and `isLoopNode` to ast-utils.

* Chore: add a test for my mistake.

#6649 (comment)

* Chore: add tests for `isFunctionNode` and `isLoopNode`

* Chore: rename `isLoopNode` → `isLoop` and `isFunctionNode` → `isFunction`
@ahocevar
Copy link
Author

Thanks for fixing this!

@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