diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js old mode 100644 new mode 100755 index b24f5238b0..85cc51e076 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -295,7 +295,11 @@ module.exports = function usedPropTypesInstructions(context, components, utils) name = getPropertyName(node); if (name) { allNames = parentNames.concat(name); - if (node.parent.type === 'MemberExpression') { + if ( + // Match props.foo.bar, don't match bar[props.foo] + node.parent.type === 'MemberExpression' && + node.parent.object === node + ) { markPropTypesAsUsed(node.parent, allNames); } // Do not mark computed props as used. diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js old mode 100644 new mode 100755 index 0babd91930..a16ad51293 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -2303,6 +2303,19 @@ ruleTester.run('prop-types', rule, { const b = a::fn1(); `, parser: 'babel-eslint' + }, + { + // issue #1259 + code: ` + const Hello = props => { + const { notInProp } = dict[props.foo]; + return
+ } + + Hello.propTypes = { + foo: PropTypes.number, + } + ` } ],