@@ -130,42 +130,6 @@ function isBlockLikeStatement(sourceCode, node) {
130
130
) ;
131
131
}
132
132
133
- /**
134
- * Check whether the given node is a directive or not.
135
- * @param {ASTNode } node The node to check.
136
- * @param {SourceCode } sourceCode The source code object to get tokens.
137
- * @returns {boolean } `true` if the node is a directive.
138
- */
139
- function isDirective ( node , sourceCode ) {
140
- return (
141
- astUtils . isTopLevelExpressionStatement ( node ) &&
142
- node . expression . type === "Literal" &&
143
- typeof node . expression . value === "string" &&
144
- ! astUtils . isParenthesised ( sourceCode , node . expression )
145
- ) ;
146
- }
147
-
148
- /**
149
- * Check whether the given node is a part of directive prologue or not.
150
- * @param {ASTNode } node The node to check.
151
- * @param {SourceCode } sourceCode The source code object to get tokens.
152
- * @returns {boolean } `true` if the node is a part of directive prologue.
153
- */
154
- function isDirectivePrologue ( node , sourceCode ) {
155
- if ( isDirective ( node , sourceCode ) ) {
156
- for ( const sibling of node . parent . body ) {
157
- if ( sibling === node ) {
158
- break ;
159
- }
160
- if ( ! isDirective ( sibling , sourceCode ) ) {
161
- return false ;
162
- }
163
- }
164
- return true ;
165
- }
166
- return false ;
167
- }
168
-
169
133
/**
170
134
* Gets the actual last token.
171
135
*
@@ -359,12 +323,10 @@ const StatementTypes = {
359
323
CJS_IMPORT . test ( sourceCode . getText ( node . declarations [ 0 ] . init ) )
360
324
} ,
361
325
directive : {
362
- test : isDirectivePrologue
326
+ test : astUtils . isDirective
363
327
} ,
364
328
expression : {
365
- test : ( node , sourceCode ) =>
366
- node . type === "ExpressionStatement" &&
367
- ! isDirectivePrologue ( node , sourceCode )
329
+ test : node => node . type === "ExpressionStatement" && ! astUtils . isDirective ( node )
368
330
} ,
369
331
iife : {
370
332
test : isIIFEStatement
@@ -375,10 +337,10 @@ const StatementTypes = {
375
337
isBlockLikeStatement ( sourceCode , node )
376
338
} ,
377
339
"multiline-expression" : {
378
- test : ( node , sourceCode ) =>
340
+ test : node =>
379
341
node . loc . start . line !== node . loc . end . line &&
380
342
node . type === "ExpressionStatement" &&
381
- ! isDirectivePrologue ( node , sourceCode )
343
+ ! astUtils . isDirective ( node )
382
344
} ,
383
345
384
346
"multiline-const" : newMultilineKeywordTester ( "const" ) ,
0 commit comments