File tree Expand file tree Collapse file tree 5 files changed +1077
-1
lines changed
test/fixtures/ast/filters-error-2 Expand file tree Collapse file tree 5 files changed +1077
-1
lines changed Original file line number Diff line number Diff line change @@ -485,10 +485,32 @@ function parseFilter(
485
485
parserOptions ,
486
486
)
487
487
const statement = ast . body [ 0 ] as ESLintExpressionStatement
488
- const callExpression = statement . expression as ESLintCallExpression
488
+ const callExpression = statement . expression
489
489
490
490
ast . tokens ! . shift ( )
491
491
492
+ if (
493
+ callExpression . type !== "CallExpression" ||
494
+ callExpression . callee . type !== "Literal"
495
+ ) {
496
+ // Report the next token of `)`.
497
+ let nestCount = 1
498
+ for ( const token of ast . tokens ! . slice ( 1 ) ) {
499
+ if ( nestCount === 0 ) {
500
+ return throwUnexpectedTokenError ( token . value , token )
501
+ }
502
+ if ( token . type === "Punctuator" && token . value === "(" ) {
503
+ nestCount += 1
504
+ }
505
+ if ( token . type === "Punctuator" && token . value === ")" ) {
506
+ nestCount -= 1
507
+ }
508
+ }
509
+
510
+ const token = last ( ast . tokens ) !
511
+ return throwUnexpectedTokenError ( token . value , token )
512
+ }
513
+
492
514
for ( const argument of callExpression . arguments ) {
493
515
argument . parent = expression
494
516
expression . arguments . push ( argument )
You can’t perform that action at this time.
0 commit comments