@@ -919,25 +919,40 @@ export function parseSlotScopeExpression(
919919 locationCalculator . getSubCalculatorAfter ( - 14 ) ,
920920 parserOptions ,
921921 ) . ast
922+ const statement = ast . body [ 0 ] as ESLintExpressionStatement
923+ const rawExpression = statement . expression as ESLintUnaryExpression
924+ const functionDecl = rawExpression . argument as ESLintFunctionExpression
925+ const params = functionDecl . params
926+
927+ if ( params . length === 0 ) {
928+ return {
929+ expression : null ,
930+ tokens : [ ] ,
931+ comments : [ ] ,
932+ references : [ ] ,
933+ variables : [ ] ,
934+ }
935+ }
936+
922937 const tokens = ast . tokens || [ ]
923938 const comments = ast . comments || [ ]
924939 const scope = analyzeVariablesAndExternalReferences ( ast , parserOptions )
925940 const references = scope . references
926941 const variables = scope . variables
927- const statement = ast . body [ 0 ] as ESLintExpressionStatement
928- const rawExpression = statement . expression as ESLintUnaryExpression
929- const functionDecl = rawExpression . argument as ESLintFunctionExpression
930- const id = functionDecl . params [ 0 ]
942+ const firstParam = first ( params ) !
943+ const lastParam = last ( params ) !
931944 const expression : VSlotScopeExpression = {
932945 type : "VSlotScopeExpression" ,
933- range : [ id . range [ 0 ] , id . range [ 1 ] ] ,
934- loc : { start : id . loc . start , end : id . loc . end } ,
946+ range : [ firstParam . range [ 0 ] , lastParam . range [ 1 ] ] ,
947+ loc : { start : firstParam . loc . start , end : lastParam . loc . end } ,
935948 parent : DUMMY_PARENT ,
936- id ,
949+ params : functionDecl . params ,
937950 }
938951
939952 // Modify parent.
940- id . parent = expression
953+ for ( const param of params ) {
954+ param . parent = expression
955+ }
941956
942957 // Remvoe `void` `function` `(` `)` `{` `}`.
943958 tokens . shift ( )
@@ -947,15 +962,6 @@ export function parseSlotScopeExpression(
947962 tokens . pop ( )
948963 tokens . pop ( )
949964
950- // Verify syntax.
951- const extraToken = tokens . find ( t => t . range [ 0 ] >= id . range [ 1 ] )
952- if ( extraToken ) {
953- throwUnexpectedTokenError ( extraToken . value , extraToken )
954- }
955- if ( id . type === "RestElement" ) {
956- throwUnexpectedTokenError ( "..." , id )
957- }
958-
959965 return { expression, tokens, comments, references, variables }
960966 } catch ( err ) {
961967 return throwErrorAsAdjustingOutsideOfCode ( err , code , locationCalculator )
0 commit comments