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-unmodified-loop-condition false positive #5445

Closed
mourner opened this issue Mar 1, 2016 · 2 comments
Closed

no-unmodified-loop-condition false positive #5445

mourner opened this issue Mar 1, 2016 · 2 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

@mourner
Copy link
Contributor

mourner commented Mar 1, 2016

Using ESLint 2.2.0, the following code causes a false positive:

/*eslint no-unmodified-loop-condition: 2 */
var a = [1, 2, 3];
var len = a.length;
for (var i = 0; i < len - 1; i++) {}
// produces: `len` is not modified in this loop. (no-unmodified-loop-condition)

This is a false positive because i is modified in the loop condition. If you replace len - 1 with len, the error disappears.

Reproducible in the ESLint demo too. The issue is similar to #5166, but not the same. cc @feross @mysticatea

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Mar 1, 2016
@alberto alberto 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 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 evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Mar 1, 2016
@alberto
Copy link
Member

alberto commented Mar 1, 2016

Confirmed

@mysticatea mysticatea self-assigned this Mar 2, 2016
mysticatea added a commit that referenced this issue Mar 3, 2016
Previously, this rule has been checking whether every BinaryExpression
was modified or not. But this way has been reporting wrong warnings in
chaining binary expression (e.g. `foo + bar < 1`).
Now, this rule came to check whether the top of BinaryExpressions was
modified or not.
mysticatea added a commit that referenced this issue Mar 5, 2016
Previously, this rule has been checking whether every BinaryExpression
was modified or not. But this way has been reporting wrong warnings in
chaining binary expression (e.g. `foo + bar < 1`).
Now, this rule came to check whether the top of BinaryExpressions was
modified or not.
nzakas added a commit that referenced this issue Mar 7, 2016
…-false-positive

Fix: `no-unmodified-loop-condition` false positive (fixes #5445)
@mourner
Copy link
Contributor Author

mourner commented Mar 8, 2016

@mysticatea thank you for fixing this so quickly!

craigmichaelmartin pushed a commit to craigmichaelmartin/eslint that referenced this issue Mar 9, 2016
Previously, this rule has been checking whether every BinaryExpression
was modified or not. But this way has been reporting wrong warnings in
chaining binary expression (e.g. `foo + bar < 1`).
Now, this rule came to check whether the top of BinaryExpressions was
modified or not.
@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

4 participants