@@ -12,9 +12,6 @@ const messages = {
1212 [ SUGGESTION ] : 'Merge with previous one.' ,
1313} ;
1414
15- const isExpressionStatement = node =>
16- node ?. parent . type === 'ExpressionStatement'
17- && node . parent . expression === node ;
1815const isClassList = node => isMemberExpression ( node , {
1916 property : 'classList' ,
2017 optional : false ,
@@ -65,10 +62,7 @@ const cases = [
6562 optional : false ,
6663 } ) ,
6764 } ,
68- ] . map ( problematicalCase => ( {
69- ...problematicalCase ,
70- test : callExpression => problematicalCase . test ( callExpression ) && isExpressionStatement ( callExpression ) ,
71- } ) ) ;
65+ ] ;
7266
7367function create ( context ) {
7468 const {
@@ -82,7 +76,7 @@ function create(context) {
8276 return {
8377 * CallExpression ( secondCall ) {
8478 for ( const { description, test, ignore = [ ] } of cases ) {
85- if ( ! test ( secondCall ) ) {
79+ if ( ! test ( secondCall ) || secondCall . parent . type !== 'ExpressionStatement' ) {
8680 continue ;
8781 }
8882
@@ -91,7 +85,12 @@ function create(context) {
9185 continue ;
9286 }
9387
94- const firstCall = getPreviousNode ( secondCall . parent , sourceCode ) ?. expression ;
88+ const previousNode = getPreviousNode ( secondCall . parent , sourceCode ) ;
89+ if ( previousNode ?. type !== 'ExpressionStatement' ) {
90+ continue ;
91+ }
92+
93+ const firstCall = previousNode . expression ;
9594 if ( ! test ( firstCall ) || ! isSameReference ( firstCall . callee , secondCall . callee ) ) {
9695 continue ;
9796 }
0 commit comments