Skip to content

Commit 18b27cb

Browse files
committed
Fix prop-types crash (fixes #383)
1 parent a929545 commit 18b27cb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/util/Components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ function componentRule(rule, context) {
304304
break;
305305
}
306306
}
307-
if (!node) {
307+
if (!node || !node.value) {
308308
return null;
309309
}
310310
node = node.value;

tests/lib/rules/prop-types.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,20 @@ ruleTester.run('prop-types', rule, {
17951795
errors: [
17961796
{message: '\'result.notok\' is missing in props validation'}
17971797
]
1798+
}, {
1799+
code: [
1800+
'let Greetings = {};',
1801+
'Greetings.Hello = class extends React.Component {',
1802+
' render () {',
1803+
' return <div>Hello {this.props.name}</div>;',
1804+
' }',
1805+
'}',
1806+
'Greetings.Hello.propTypes = {};'
1807+
].join('\n'),
1808+
parserOptions: parserOptions,
1809+
errors: [{
1810+
message: '\'name\' is missing in props validation'
1811+
}]
17981812
}
17991813
]
18001814
});

0 commit comments

Comments
 (0)