File tree Expand file tree Collapse file tree
lib/tokenize/statements/expression-statement Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,12 +15,8 @@ import {
1515const {
1616 isCallExpression,
1717 isAssignmentExpression,
18- isArrayExpression,
19- isStringLiteral,
20- isTemplateLiteral,
2118 isExpressionStatement,
2219 isStatement,
23- isBooleanLiteral,
2420} = types ;
2521
2622function isNotLastOrParentLast ( path ) {
@@ -76,29 +72,6 @@ const isNextCallWithLeadingComments = (path) => {
7672 return isCallExpression ( nextExpression ) ;
7773} ;
7874
79- export function isNextSimpleWithLeadingComments ( path ) {
80- const next = path . getNextSibling ( ) ;
81-
82- if ( ! hasTrailingComment ( path ) )
83- return false ;
84-
85- if ( ! isExpressionStatement ( next ) )
86- return false ;
87-
88- const { expression} = next . node ;
89-
90- if ( isBooleanLiteral ( expression ) )
91- return true ;
92-
93- if ( isStringLiteral ( expression ) )
94- return true ;
95-
96- if ( isTemplateLiteral ( expression ) )
97- return true ;
98-
99- return isArrayExpression ( next . node . expression ) ;
100- }
101-
10275function isAssignWithTrailingComments ( path ) {
10376 const { expression} = path . node ;
10477
Original file line number Diff line number Diff line change @@ -12,10 +12,7 @@ import {
1212 printLeadingCommentLine ,
1313 printLeadingCommentBlock ,
1414} from './comments.js' ;
15- import {
16- afterIf ,
17- isNextSimpleWithLeadingComments ,
18- } from './after-if.js' ;
15+ import { afterIf } from './after-if.js' ;
1916import { beforeIf } from './before-if.js' ;
2017
2118const { isIfStatement} = types ;
@@ -82,3 +79,12 @@ export const ExpressionStatement = {
8279 maybe . markAfter ( store ( ) , path ) ;
8380 } ,
8481} ;
82+
83+ export const isNextSimpleWithLeadingComments = callWithNext ( createTypeChecker ( [
84+ [ '-: -> !' , hasLeadingComment ] ,
85+ [ '-: -> !ExpressionStatement' ] ,
86+ [ '+: node.expression -> TemplateLiteral' ] ,
87+ [ '+: node.expression -> ArrayExpression' ] ,
88+ [ '+: node.expression -> BooleanLiteral' ] ,
89+ [ '+: node.expression -> StringLiteral' ] ,
90+ ] ) ) ;
You can’t perform that action at this time.
0 commit comments