Skip to content

Commit 7f7b96d

Browse files
CrOrcljharb
authored andcommitted
[Fix] prop-types: Read name of callee object.
In isPragmaComponentWrapper check name of callee object if available. Fixes jsx-eslint#2124
1 parent 5fc50aa commit 7f7b96d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/util/Components.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ function componentRule(rule, context) {
401401
}
402402
const propertyNames = ['forwardRef', 'memo'];
403403
const calleeObject = node.callee.object;
404-
if (calleeObject) {
405-
return arrayIncludes(propertyNames, node.callee.property.name) && node.callee.object.name === pragma;
404+
if (calleeObject && node.callee.property) {
405+
return arrayIncludes(propertyNames, node.callee.property.name) && calleeObject.name === pragma;
406406
}
407407
return arrayIncludes(propertyNames, node.callee.name) && this.isDestructuredFromPragmaImport(node.callee.name);
408408
},

tests/lib/rules/prop-types.js

+7
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,13 @@ ruleTester.run('prop-types', rule, {
22962296
export const Unconnected = Foo;
22972297
export default connect(Foo);
22982298
`
2299+
}, {
2300+
code: `
2301+
const a = {};
2302+
function fn1() {}
2303+
const b = a::fn1();
2304+
`,
2305+
parser: 'babel-eslint'
22992306
}
23002307
],
23012308

0 commit comments

Comments
 (0)