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
no-array-for-each
: Ignore React.Children.forEach
#1088
Conversation
I think this rule should share code with eslint-plugin-unicorn/rules/no-array-callback-reference.js Lines 71 to 80 in e54dc66
|
I wrote a new function and applied to |
const ignoredObjects = [ | ||
'React.Children', | ||
'Children' | ||
]; |
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 thinking we could have a shared utility method that is like isNotNativeArrayMethod
. In case there are other false-positives in the future.
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.
That's a good idea, like the not-dom-node.js
, but I was hoping get some help from eslint-utils
, anyway I'll keep this in mind, maybe try in another PR.
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.
That package isn't very actively maintained. I suggest we just do the utilities here for now and we can move them there later on if it becomes maintained again. Alternatively, you could fork eslint-utils
for now.
rules/utils/is-node-matches.js
Outdated
return true; | ||
} | ||
|
||
function isNodeMatches(node, descriptions) { |
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.
This needs a short doc comment on what descriptions
is.
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.
keyPath
is a commonly used term for foo.bar
descriptions of a method chain.
test/no-array-for-each.js
Outdated
'foo.notForEach(element => bar())', | ||
// #1087 | ||
'React.Children.forEach(children, (child) => {});', | ||
'React.Children.forEach(children, (child) => {});' |
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.
'React.Children.forEach(children, (child) => {});' | |
'Children.forEach(children, (child) => {});' |
@@ -70,7 +71,7 @@ const iteratorMethods = [ | |||
|
|||
const ignoredCallee = [ | |||
'Promise', | |||
'React.children', | |||
'React.Children', |
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 think this mean to be React.Children
.
My 11 month daughter is coding for me... I'll fix after she sleep. |
Fixes #1087