Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Rewrite prefer-for-of rule #1758

Merged
merged 1 commit into from
Nov 22, 2016
Merged

Rewrite prefer-for-of rule #1758

merged 1 commit into from
Nov 22, 2016

Conversation

nchen63
Copy link
Contributor

@nchen63 nchen63 commented Nov 20, 2016

fixes #1753

use walker instead of regex to determine usage of index variable
more validation, less fragile
more restrictive in suggesting for-of when multiple statements are in initializer, condition, or incrementer
allows for different ways of incrementing

old code had false positives:

    for(let x = 0; NOTX < arr.length; x++) {}

    for(let x = 0; x < arr.length; x--) {}

    for(let x = 0; x <= arr.length; x++) {}

    for(let x = 1; x < arr.length; x++) {}

    for(let x = 0; x < arr.length; x+=11) {}

and crashes on:

    for(let x = 0; true; x++) {}

    for(let x = 0; x < arr.length;) {}

@nchen63 nchen63 changed the title Rewrite for-of rule Rewrite prefer-for-of rule Nov 20, 2016
@nchen63 nchen63 merged commit d29f484 into master Nov 22, 2016
@adidahiya adidahiya deleted the for-of branch November 22, 2016 21:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError when prefer-for-of is enabled
1 participant