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

Fix invalid autofix with destructuring assignment in no-for-loops rule #476

Merged
merged 5 commits into from Dec 17, 2019

Commits on Dec 17, 2019

  1. fix: invalid autofix with destructuring assignment in no-for-loops rule

    Example (original):
    ```js
    for (let i = 0; i < arr.length; i++) {
      const { a, b } = arr[i];
      console.log(a, b);
    }
    ```
    
    Autofix (before this fix):
    ```js
    for (const element of arr) {
      console.log(a, b);
    }
    ```
    
    Autofix (after this fix):
    ```js
    for (const element of arr) {
      const { a, b } = element;
      console.log(a, b);
    }
    ```
    
    When `arr[i]` is used in a destructuring assignment, the entire assignment should not be removed (previous behavior), only `arr[i]` should be replaced with `element` (new behavior).
    bmish committed Dec 17, 2019
    Copy the full SHA
    1e2f579 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    ca742cb View commit details
    Browse the repository at this point in the history
  3. Fix element used case

    fisker committed Dec 17, 2019
    Copy the full SHA
    c034799 View commit details
    Browse the repository at this point in the history
  4. Merge remote-tracking branch 'remotes/bmish/no-for-loops-destructurin…

    …g-fix' into no-for-loops-destructuring-fix
    
    # Conflicts:
    #	rules/no-for-loop.js
    #	test/no-for-loop.js
    fisker committed Dec 17, 2019
    Copy the full SHA
    c244114 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    9a025f6 View commit details
    Browse the repository at this point in the history