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

Improve no-array-for-each rule docs #1149

Merged
merged 4 commits into from
Apr 3, 2021
Merged

Conversation

bmish
Copy link
Sponsor Contributor

@bmish bmish commented Mar 24, 2021

No description provided.


This rule is partly fixable.

Note that this rule may erroneously catch/fix loops with arrays that are not iterable and thus cannot be converted to for-of loops.
Copy link

Choose a reason for hiding this comment

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

What would be an example of this?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

I had experienced issues where this rule (and also the unicorn/prefer-spread rule) erroneously converted someObj.forEach(...) to a for-of loop in my Ember app leading to the x is not iterable error, but it turns out someObj was just an object that implemented array functions like forEach (see Ember.ArrayProxy#forEach) and was not actually iterable.

I removed this warning for now.

@bmish bmish changed the title docs: elaborate on benefits/restrictions of for-of loops in no-array-for-each rule doc docs: elaborate on benefits of for-of loops in no-array-for-each rule doc Mar 25, 2021
@sindresorhus sindresorhus changed the title docs: elaborate on benefits of for-of loops in no-array-for-each rule doc Improve no-array-for-each rule docs Apr 3, 2021
@sindresorhus sindresorhus merged commit 1ea39f4 into sindresorhus:main Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants