Skip to content

Commit

Permalink
Fix forbid-prop-types crash (fixes #579)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed May 8, 2016
1 parent 504e0d0 commit 6950cbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rules/forbid-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ module.exports = function(context) {
*/
function checkForbidden(declarations) {
declarations.forEach(function(declaration) {
if (declaration.type !== 'Property') {
return;
}
var target;
var value = declaration.value;
if (
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/forbid-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ ruleTester.run('forbid-prop-types', rule, {
'});'
].join('\n'),
parserOptions: parserOptions
}, {
// Proptypes declared with a spread property
code: [
'class Test extends react.component {',
' static propTypes = {',
' intl: React.propTypes.number,',
' ...propTypes',
' };',
'}'
].join('\n'),
parser: 'babel-eslint'
}],

invalid: [{
Expand Down

0 comments on commit 6950cbd

Please sign in to comment.