Skip to content

Commit

Permalink
[Fix] prop-types: Read name of callee object.
Browse files Browse the repository at this point in the history
In isPragmaComponentWrapper check name of callee object if available.

Fixes #2124
  • Loading branch information
CrOrc authored and ljharb committed Jan 8, 2019
1 parent 5fc50aa commit 7f7b96d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/util/Components.js
Expand Up @@ -401,8 +401,8 @@ function componentRule(rule, context) {
}
const propertyNames = ['forwardRef', 'memo'];
const calleeObject = node.callee.object;
if (calleeObject) {
return arrayIncludes(propertyNames, node.callee.property.name) && node.callee.object.name === pragma;
if (calleeObject && node.callee.property) {
return arrayIncludes(propertyNames, node.callee.property.name) && calleeObject.name === pragma;
}
return arrayIncludes(propertyNames, node.callee.name) && this.isDestructuredFromPragmaImport(node.callee.name);
},
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/prop-types.js
Expand Up @@ -2296,6 +2296,13 @@ ruleTester.run('prop-types', rule, {
export const Unconnected = Foo;
export default connect(Foo);
`
}, {
code: `
const a = {};
function fn1() {}
const b = a::fn1();
`,
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit 7f7b96d

Please sign in to comment.