diff --git a/lib/util/Components.js b/lib/util/Components.js index 852254e8fe..ef25709557 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -567,7 +567,7 @@ function componentRule(rule, context) { } if (refId.type === 'MemberExpression') { componentNode = refId.parent.right; - } else if (refId.parent && refId.parent.type === 'VariableDeclarator') { + } else if (refId.parent && refId.parent.type === 'VariableDeclarator' && refId.parent.init.type !== 'Identifier') { componentNode = refId.parent.init; } break; diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index b72f043abc..41c2a42677 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -2277,6 +2277,25 @@ ruleTester.run('prop-types', rule, { '}' ].join('\n'), parser: 'babel-eslint' + }, { + code: ` + import React from 'react'; + import PropTypes from 'prop-types'; + import {connect} from 'react-redux'; + + class Foo extends React.Component { + render() { + return this.props.children; + } + } + + Foo.propTypes = { + children: PropTypes.element.isRequired + }; + + export const Unconnected = Foo; + export default connect(Foo); + ` } ],