Skip to content

Commit 2f6e2b0

Browse files
committed
Fix crash when destructuring with only the rest spread (fixes #269)
1 parent fca4db0 commit 2f6e2b0

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/rules/prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ module.exports = Components.detect(function(context, components) {
180180
* @return {string} the name of the key
181181
*/
182182
function getKeyValue(node) {
183-
var key = node.key;
183+
var key = node.key || node.argument;
184184
return key.type === 'Identifier' ? key.name : key.value;
185185
}
186186

tests/lib/rules/prop-types.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,24 @@ ruleTester.run('prop-types', rule, {
917917
'}'
918918
].join('\n'),
919919
parser: 'babel-eslint'
920+
}, {
921+
code: [
922+
'var Hello = React.createClass({',
923+
' render: function() {',
924+
' var {...other} = this.props;',
925+
' return (',
926+
' <div {...other} />',
927+
' );',
928+
' }',
929+
'});'
930+
].join('\n'),
931+
env: {
932+
es6: true
933+
},
934+
ecmaFeatures: {
935+
jsx: true,
936+
experimentalObjectRestSpread: true
937+
}
920938
}
921939
],
922940

0 commit comments

Comments
 (0)