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
Add no-array-for-each
rule
#1017
Conversation
rules/no-array-for-each.js
Outdated
return false; | ||
} | ||
|
||
// TODO: check parameters conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure how to check this,
Should not fix
foo.forEach(foo => bar());
->
for (const foo of foo) bar();
a[foo].forEach(foo => bar());
->
for (const foo of a[foo]) bar();
Should fix
a((foo) => foo).forEach(foo => bar());
->
for (const foo of a((foo) => foo)) bar();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured a way to detect this, but not very efficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A similar logic maybe possible to auto fix destructuring parameters, but it's much complicated, I'm going to try in a seperate PR.
# Conflicts: # index.js # readme.md
|
This is really well done (as always). And a super useful rule. 🙌🏻 |
> Output | ||
|
||
`␊ | ||
1 | for (const [foo, index] of a((foo, index) => foo + index).entries()) bar();␊ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was stupid, forgot to swap parameters.
You're killin' it, @fisker! 🥳 |
Fixes #955
Not done yet, still twoTODO
s need fix.