-
Notifications
You must be signed in to change notification settings - Fork 48.4k
Disable for...of by default, rewrite cases where it matters #12198
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
for (const key of Object.keys(fragment.props)) { | ||
const keys = Object.keys(fragment.props); | ||
for (let i = 0; i < keys.length; i++) { | ||
const key = keys[i]; |
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.
Strictly saying this is the only case where it matters. But I figured changing TestRenderer code doesn't hurt too.
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.
Nice! Thanks Dan.
@@ -11,6 +11,7 @@ module.exports = { | |||
|
|||
plugins: [ | |||
'jest', | |||
'no-for-of-loops', |
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.
Do you need a whole plugin for this? You can use no-restricted-syntax to block for..of loops with a custom message.
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.
Oh I didn’t know that. Happy to take a PR.
…#12198) * Add no-for-of lint rule * Ignore legit use cases of for..of * Rewrite for..of in source code
…#12198) * Add no-for-of lint rule * Ignore legit use cases of for..of * Rewrite for..of in source code
* Add no-for-of lint rule * Ignore legit use cases of for..of * Rewrite for..of in source code
for...of
introduces a dependency onSymbol
andSymbol.iterator
(and bloated code too, withtry
/catch
in a potentially very hot DEV path). We accidentally merged that in #10783.I'm adding this rule so we can be more vigilant. You can ignore it for build and other scripts but please don't ignore it in the source.