Skip to content

Commit 6950cbd

Browse files
committed
Fix forbid-prop-types crash (fixes #579)
1 parent 504e0d0 commit 6950cbd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/rules/forbid-prop-types.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ module.exports = function(context) {
5353
*/
5454
function checkForbidden(declarations) {
5555
declarations.forEach(function(declaration) {
56+
if (declaration.type !== 'Property') {
57+
return;
58+
}
5659
var target;
5760
var value = declaration.value;
5861
if (

tests/lib/rules/forbid-prop-types.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@ ruleTester.run('forbid-prop-types', rule, {
188188
'});'
189189
].join('\n'),
190190
parserOptions: parserOptions
191+
}, {
192+
// Proptypes declared with a spread property
193+
code: [
194+
'class Test extends react.component {',
195+
' static propTypes = {',
196+
' intl: React.propTypes.number,',
197+
' ...propTypes',
198+
' };',
199+
'}'
200+
].join('\n'),
201+
parser: 'babel-eslint'
191202
}],
192203

193204
invalid: [{

0 commit comments

Comments
 (0)