Skip to content

Commit

Permalink
Fix prop-types crash (fixes #383)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jan 9, 2016
1 parent a929545 commit 18b27cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util/Components.js
Expand Up @@ -304,7 +304,7 @@ function componentRule(rule, context) {
break;
}
}
if (!node) {
if (!node || !node.value) {
return null;
}
node = node.value;
Expand Down
14 changes: 14 additions & 0 deletions tests/lib/rules/prop-types.js
Expand Up @@ -1795,6 +1795,20 @@ ruleTester.run('prop-types', rule, {
errors: [
{message: '\'result.notok\' is missing in props validation'}
]
}, {
code: [
'let Greetings = {};',
'Greetings.Hello = class extends React.Component {',
' render () {',
' return <div>Hello {this.props.name}</div>;',
' }',
'}',
'Greetings.Hello.propTypes = {};'
].join('\n'),
parserOptions: parserOptions,
errors: [{
message: '\'name\' is missing in props validation'
}]
}
]
});

0 comments on commit 18b27cb

Please sign in to comment.