Skip to content

Commit

Permalink
Fix sort-comp crash on spread operator (fixes #624)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jun 6, 2016
1 parent aa359fb commit 0aeebaf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rules/sort-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ module.exports = Components.detect(function(context, components) {
case 'ClassDeclaration':
return node.body.body;
case 'ObjectExpression':
return node.properties;
return node.properties.filter(function(property) {
return property.type === 'Property';
});
default:
return [];
}
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/sort-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ ruleTester.run('sort-comp', rule, {
')'
].join('\n'),
parser: 'babel-eslint'
}, {
// Must ignore spread operator
code: [
'var Hello = React.createClass({',
' ...proto,',
' render: function() {',
' return <div>Hello</div>;',
' }',
'});'
].join('\n'),
parser: 'babel-eslint'
}],

invalid: [{
Expand Down

0 comments on commit 0aeebaf

Please sign in to comment.