diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js index 658f50fae4..650f4752f1 100644 --- a/lib/rules/prop-types.js +++ b/lib/rules/prop-types.js @@ -385,8 +385,6 @@ module.exports = function(context) { } break; case 'VariableDeclarator': - type = 'destructuring'; - for (var i = 0, j = node.id.properties.length; i < j; i++) { if ( (node.id.properties[i].key.name !== 'props' && node.id.properties[i].key.value !== 'props') || @@ -394,6 +392,7 @@ module.exports = function(context) { ) { continue; } + type = 'destructuring'; properties = node.id.properties[i].value.properties; break; } diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index bdf907359d..0da4cc3821 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -538,6 +538,16 @@ eslintTester.addRuleTest('lib/rules/prop-types', { '};' ].join('\n'), parser: 'babel-eslint' + }, { + code: [ + 'class Hello extends React.Component {', + ' render() {', + ' let {firstname} = this;', + ' return