Skip to content

Commit a0d55ed

Browse files
committed
Fix crash with empty destructuring (fixes #251)
1 parent de6e7b5 commit a0d55ed

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/rules/prop-types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ module.exports = function(context) {
364364
} else if (
365365
node.parent.id &&
366366
node.parent.id.properties &&
367+
node.parent.id.properties.length &&
367368
getKeyValue(node.parent.id.properties[0])
368369
) {
369370
type = 'destructuring';

tests/lib/rules/prop-types.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,21 @@ ruleTester.run('prop-types', rule, {
756756
ecmaFeatures: {
757757
jsx: true
758758
}
759+
}, {
760+
code: [
761+
'class Hello extends React.Component {',
762+
' render() {',
763+
' const {} = this.props;',
764+
' return <div>Hello</div>;',
765+
' }',
766+
'}'
767+
].join('\n'),
768+
env: {
769+
es6: true
770+
},
771+
ecmaFeatures: {
772+
jsx: true
773+
}
759774
}
760775
],
761776

0 commit comments

Comments
 (0)