Skip to content

Commit

Permalink
Fix sort-comp ClassExpression
Browse files Browse the repository at this point in the history
Fixes jsx-eslint#1076. Also adds test.
  • Loading branch information
Roy Sutton committed Feb 21, 2017
1 parent 22f3638 commit ab1631d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rules/sort-comp.js
Expand Up @@ -291,6 +291,7 @@ module.exports = {
*/
function getComponentProperties(node) {
switch (node.type) {
case 'ClassExpression':
case 'ClassDeclaration':
return node.body.body;
case 'ObjectExpression':
Expand Down
14 changes: 14 additions & 0 deletions tests/lib/rules/sort-comp.js
Expand Up @@ -286,6 +286,20 @@ ruleTester.run('sort-comp', rule, {
].join('\n'),
parserOptions: parserOptions,
errors: [{message: 'render should be placed after onClick'}]
}, {
// Must force a custom method to be placed before render, even in function
code: [
'var Hello = () => {',
' return class Test extends React.Component {',
' render () {',
' return <div>Hello</div>;',
' }',
' onClick () {}',
' }',
'};'
].join('\n'),
parserOptions: parserOptions,
errors: [{message: 'render should be placed after onClick'}]
}, {
// Must force a custom method to be placed after render if no 'everything-else' group is specified
code: [
Expand Down

0 comments on commit ab1631d

Please sign in to comment.