Skip to content

Commit

Permalink
Fix simple destructuring handling (fixes #137)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jul 1, 2015
1 parent 824ba8d commit a869bd1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,14 @@ 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') ||
node.id.properties[i].value.type !== 'ObjectPattern'
) {
continue;
}
type = 'destructuring';
properties = node.id.properties[i].value.properties;
break;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <div>{firstname}</div>;',
' }',
'};'
].join('\n'),
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit a869bd1

Please sign in to comment.