-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[core] Allow for..of
loops
#42600
[core] Allow for..of
loops
#42600
Conversation
Netlify deploy previewhttps://deploy-preview-42600--material-ui.netlify.app/ Bundle size report |
@@ -65,7 +65,7 @@ function createTheme(options = {}, ...args) { | |||
const traverse = (node, component) => { | |||
let key; | |||
|
|||
// eslint-disable-next-line guard-for-in, no-restricted-syntax | |||
// eslint-disable-next-line guard-for-in | |||
for (key in node) { |
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 necessarily part of this PR, but is this in
intentional? Is it required to traverse prototype properties here?
Another thing I noticed while sniffing around this code is that we can likely easily optimize occurences of str.indexOf(search) === 0
to the more performant string.startsWith(search)
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.
Considering https://github.com/mui/material-ui/pull/13919/files#r241988655, this code may benefit from a more thorough review (cc @DiegoAndai) ;)
I'd like to keep this PR focused on eslint changes only, though.
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.
@Janpot may I ask you to create an issue for the optimization? that way we can ask the community for contributions.
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'll verify first whether it's a real optimization
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.
Just a small comment with possible side-quests 🙂
Removed the
eslint-config-airbnb-base
package. It is meant to be used in non-React apps.The primary reason for its removal is to allow using iterators and the
for..of
loops, as the browser support is good (the spec is a part of ES2015).Removal of this package also removes 3 additional no-restricted-syntax rules:
However, we have other rules that prevent writing unsafe code using these constructs:
guard-for-in
,no-labels
, andno-with
.Note that writing for..of loops in projects in this repo is still prevented by tsconfig's
target
being set to "ES5". Changing this should be discussed first in a separate PR.