Skip to content

Commit

Permalink
Fix crash in prop-types when encountering an empty variable declarati…
Browse files Browse the repository at this point in the history
…on (fixes #130)
  • Loading branch information
yannickcr committed Jun 28, 2015
1 parent 3e280a6 commit 8682320
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ module.exports = function(context) {
},

VariableDeclarator: function(node) {
if (node.init.type !== 'ThisExpression' || node.id.type !== 'ObjectPattern') {
if (!node.init || node.init.type !== 'ThisExpression' || node.id.type !== 'ObjectPattern') {
return;
}
markPropTypesAsUsed(node);
Expand Down
4 changes: 3 additions & 1 deletion tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,10 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
code: [
'class Hello extends React.Component {',
' render() {',
' var text;',
' text = \'Hello \';',
' let {props: {firstname}} = this;',
' return <div>Hello {firstname}</div>;',
' return <div>{text} {firstname}</div>;',
' }',
'}'
].join('\n'),
Expand Down

0 comments on commit 8682320

Please sign in to comment.