File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
40
40
* [ Refactor] [ ` jsx-sort-default-props ` ] : remove unnecessary code ([ #1817 ] [ ] @ljharb )
41
41
* [ Docs] [ ` jsx-no-target-blank ` ] : fix syntax highlighting ([ #3199 ] [ ] @shamrin )
42
42
* [ Docs] [ ` jsx-key ` ] : improve example ([ #3202 ] [ ] @chnakamura )
43
+ * [ Refactor] [ ` jsx-key ` ] : use more AST selectors (@ljharb )
43
44
44
45
[ #3207 ] : https://github.com/yannickcr/eslint-plugin-react/issues/3207
45
46
[ #3202 ] : https://github.com/yannickcr/eslint-plugin-react/pull/3202
Original file line number Diff line number Diff line change @@ -163,19 +163,19 @@ module.exports = {
163
163
} ,
164
164
165
165
// Array.prototype.map
166
- 'CallExpression, OptionalCallExpression' ( node ) {
167
- if ( node . callee && node . callee . type !== 'MemberExpression' && node . callee . type !== 'OptionalMemberExpression' ) {
168
- return ;
169
- }
170
-
171
- if ( node . callee && node . callee . property && node . callee . property . name !== 'map' ) {
172
- return ;
173
- }
174
-
166
+ // eslint-disable-next-line no-multi-str
167
+ 'CallExpression[callee.type="MemberExpression"][callee.property.name="map"],\
168
+ CallExpression[callee.type="OptionalMemberExpression"][callee.property.name="map"],\
169
+ OptionalCallExpression[callee.type="MemberExpression"][callee.property.name="map"],\
170
+ OptionalCallExpression[callee.type="OptionalMemberExpression"][callee.property.name="map"]' ( node ) {
175
171
const fn = node . arguments [ 0 ] ;
176
172
const isFn = fn && fn . type === 'FunctionExpression' ;
177
173
const isArrFn = fn && fn . type === 'ArrowFunctionExpression' ;
178
174
175
+ if ( ! fn && ! isFn && ! isArrFn ) {
176
+ return ;
177
+ }
178
+
179
179
if ( isArrFn && ( fn . body . type === 'JSXElement' || fn . body . type === 'JSXFragment' ) ) {
180
180
checkIteratorElement ( fn . body ) ;
181
181
}
You can’t perform that action at this time.
0 commit comments