Skip to content

Commit 7efe31a

Browse files
committed
Account for class methods.
1 parent 0eacd40 commit 7efe31a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/rules/sort-comp.js

+2
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,12 @@ module.exports = {
399399
setter: node.kind === 'set',
400400
static: node.static,
401401
instanceVariable: !node.static &&
402+
node.type === 'ClassProperty' &&
402403
node.value &&
403404
node.value.type !== 'ArrowFunctionExpression' &&
404405
node.value.type !== 'FunctionExpression',
405406
instanceMethod: !node.static &&
407+
node.type === 'ClassProperty' &&
406408
node.value &&
407409
(node.value.type === 'ArrowFunctionExpression' ||
408410
node.value.type === 'FunctionExpression'),

tests/lib/rules/sort-comp.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ ruleTester.run('sort-comp', rule, {
316316
'class Hello extends React.Component {',
317317
' foo = () => {}',
318318
' constructor() {}',
319+
' classMethod() {}',
319320
' static bar = () => {}',
320321
' render() {',
321322
' return <div>{this.props.text}</div>;',
@@ -564,7 +565,8 @@ ruleTester.run('sort-comp', rule, {
564565
'class Hello extends React.Component {',
565566
' constructor() {}',
566567
' static bar = () => {}',
567-
' foo = () => {}',
568+
' classMethod() {}',
569+
' foo = function() {}',
568570
' render() {',
569571
' return <div>{this.props.text}</div>;',
570572
' }',

0 commit comments

Comments
 (0)