From 7f7b96d155dcb43baa3f438aa7c4720f0aa94298 Mon Sep 17 00:00:00 2001 From: Roman Yakubuk Date: Tue, 8 Jan 2019 08:54:29 +0300 Subject: [PATCH] [Fix] `prop-types`: Read name of callee object. In isPragmaComponentWrapper check name of callee object if available. Fixes #2124 --- lib/util/Components.js | 4 ++-- tests/lib/rules/prop-types.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/util/Components.js b/lib/util/Components.js index ef25709557..6b886f03be 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -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); }, diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index 41c2a42677..ab1785930f 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -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' } ],