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

Update: for-direction detection false positives/negatives #11254

Merged
merged 1 commit into from Feb 1, 2019

Conversation

BridgeAR
Copy link
Contributor

@BridgeAR BridgeAR commented Jan 8, 2019

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

I updated the for-direction rule to prevent false positives and false negatives.

Is there anything you'd like reviewers to focus on?

No

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jan 8, 2019
Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! Left one inline note.

In addition: Could you please add tests (if not already present) for cases where the for increment direction "could be wrong" but the step size is a variable?

For example:

for(var i = 0; i < MAX; i -= STEP_SIZE);

To me, those examples should be valid because we don't know if STEP_SIZE is positive or negative.

Also, since this change can introduce more warnings, the commit summary tag should say "Update". Would you mind making that change as well? (Simplest way to do that is to push new commits without squashing, then edit the PR title.)

"for(var i = 10; i >= 0; i %= 2){}"
"for(var i = 10; i >= 0; i %= 2){}",
"for(var i = 0; i < MAX; i += STEP_SIZE);",
"for(var i = MAX; i < MIN; i -= STEP_SIZE);"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this should say i > MIN.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was meant as test which you requested and I was to lazy to change the variable names, so it seemed confusing afterwards. I fixed that now and added another one on top.

@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 Jan 8, 2019
@BridgeAR BridgeAR changed the title Fix: for-direction detection false positives/negatives Update: for-direction detection false positives/negatives Jan 9, 2019
@not-an-aardvark
Copy link
Member

@platinumazure Friendly ping, have your suggestions been addressed?

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Sorry for not following up sooner.

@btmills btmills merged commit b5143bf into eslint:master Feb 1, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Aug 1, 2019
@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 Aug 1, 2019
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

Successfully merging this pull request may close these issues.

None yet

5 participants