@@ -38,10 +38,10 @@ export function analyzeTypeScriptInSvelte(
3838 code : { script : string ; rootScope : string ; render : string } ,
3939 attrs : Record < string , string | undefined > ,
4040 parserOptions : NormalizedParserOptions ,
41- context : AnalyzeTypeScriptContext ,
41+ context : AnalyzeTypeScriptContext
4242) : VirtualTypeScriptContext {
4343 const ctx = new VirtualTypeScriptContext (
44- code . script + code . render + code . rootScope ,
44+ code . script + code . render + code . rootScope
4545 ) ;
4646 ctx . appendOriginal ( / ^ \s * / u. exec ( code . script ) ! [ 0 ] . length ) ;
4747
@@ -52,7 +52,7 @@ export function analyzeTypeScriptInSvelte(
5252 ...parserOptions ,
5353 // Without typings
5454 project : null ,
55- } ,
55+ }
5656 ) as unknown as TSESParseForESLintResult ;
5757
5858 ctx . _beforeResult = result ;
@@ -65,7 +65,7 @@ export function analyzeTypeScriptInSvelte(
6565
6666 applyTransforms (
6767 [ ...analyzeReactiveScopes ( result ) , ...analyzeDollarDerivedScopes ( result ) ] ,
68- ctx ,
68+ ctx
6969 ) ;
7070
7171 analyzeRenderScopes ( code , ctx ) ;
@@ -82,7 +82,7 @@ export function analyzeTypeScriptInSvelte(
8282export function analyzeTypeScript (
8383 code : string ,
8484 attrs : Record < string , string | undefined > ,
85- parserOptions : NormalizedParserOptions ,
85+ parserOptions : NormalizedParserOptions
8686) : VirtualTypeScriptContext {
8787 const ctx = new VirtualTypeScriptContext ( code ) ;
8888 ctx . appendOriginal ( / ^ \s * / u. exec ( code ) ! [ 0 ] . length ) ;
@@ -110,7 +110,7 @@ export function analyzeTypeScript(
110110 */
111111function analyzeStoreReferenceNames (
112112 result : TSESParseForESLintResult ,
113- ctx : VirtualTypeScriptContext ,
113+ ctx : VirtualTypeScriptContext
114114) {
115115 const scopeManager = result . scopeManager ;
116116 const programScope = getProgramScope ( scopeManager as ScopeManager ) ;
@@ -138,7 +138,7 @@ function analyzeStoreReferenceNames(
138138? F extends (value: infer V, ...args: any) => any
139139? V
140140: never
141- : T;` ,
141+ : T;`
142142 ) ;
143143 ctx . restoreContext . addRestoreStatementProcess ( ( node , result ) => {
144144 if (
@@ -162,7 +162,7 @@ function analyzeStoreReferenceNames(
162162 for ( const nm of maybeStoreRefNames ) {
163163 const realName = nm . slice ( 1 ) ;
164164 ctx . appendVirtualScript (
165- `declare let ${ nm } : ${ storeValueTypeName } <typeof ${ realName } >;` ,
165+ `declare let ${ nm } : ${ storeValueTypeName } <typeof ${ realName } >;`
166166 ) ;
167167 ctx . restoreContext . addRestoreStatementProcess ( ( node , result ) => {
168168 if (
@@ -198,13 +198,13 @@ function analyzeStoreReferenceNames(
198198function analyzeDollarDollarVariables (
199199 result : TSESParseForESLintResult ,
200200 ctx : VirtualTypeScriptContext ,
201- slots : Set < SvelteHTMLElement > ,
201+ slots : Set < SvelteHTMLElement >
202202) {
203203 const scopeManager = result . scopeManager ;
204204 for ( const globalName of globals ) {
205205 if (
206206 ! scopeManager . globalScope ! . through . some (
207- ( reference ) => reference . identifier . name === globalName ,
207+ ( reference ) => reference . identifier . name === globalName
208208 )
209209 ) {
210210 continue ;
@@ -221,7 +221,7 @@ function analyzeDollarDollarVariables(
221221 for ( const slot of slots ) {
222222 const nameAttr = slot . startTag . attributes . find (
223223 ( attr ) : attr is SvelteAttribute =>
224- attr . type === "SvelteAttribute" && attr . key . name === "name" ,
224+ attr . type === "SvelteAttribute" && attr . key . name === "name"
225225 ) ;
226226 if ( ! nameAttr || nameAttr . value . length === 0 ) {
227227 nameTypes . add ( '"default"' ) ;
@@ -242,17 +242,17 @@ function analyzeDollarDollarVariables(
242242 . map ( ( value ) =>
243243 value . type === "SvelteLiteral"
244244 ? value . value . replace ( / ( [ $ ` ] ) / gu, "\\$1" )
245- : "${string}" ,
245+ : "${string}"
246246 )
247- . join ( "" ) } \``,
247+ . join ( "" ) } \``
248248 ) ;
249249 }
250250
251251 appendDeclareVirtualScript (
252252 globalName ,
253253 `Record<${
254254 nameTypes . size > 0 ? [ ...nameTypes ] . join ( " | " ) : "any"
255- } , boolean>`,
255+ } , boolean>`
256256 ) ;
257257 break ;
258258 }
@@ -306,13 +306,13 @@ function analyzeDollarDollarVariables(
306306 */
307307function analyzeRuneVariables (
308308 result : TSESParseForESLintResult ,
309- ctx : VirtualTypeScriptContext ,
309+ ctx : VirtualTypeScriptContext
310310) {
311311 const scopeManager = result . scopeManager ;
312312 for ( const globalName of globalsForRunes ) {
313313 if (
314314 ! scopeManager . globalScope ! . through . some (
315- ( reference ) => reference . identifier . name === globalName ,
315+ ( reference ) => reference . identifier . name === globalName
316316 )
317317 ) {
318318 continue ;
@@ -354,7 +354,7 @@ function analyzeRuneVariables(
354354 }
355355 // See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2655
356356 case "$props" : {
357- appendDeclareFunctionVirtualScripts ( globalName , [ "<T> (): T " ] ) ;
357+ appendDeclareFunctionVirtualScripts ( globalName , [ "(): any " ] ) ;
358358 break ;
359359 }
360360 // See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2666
@@ -407,7 +407,7 @@ function analyzeRuneVariables(
407407
408408 function appendDeclareNamespaceVirtualScripts (
409409 name : string ,
410- scripts : string [ ] ,
410+ scripts : string [ ]
411411 ) {
412412 for ( const script of scripts ) {
413413 ctx . appendVirtualScript ( `declare namespace ${ name } { ${ script } }` ) ;
@@ -442,11 +442,11 @@ function analyzeRuneVariables(
442442 * Transform source code to provide the correct type information in the `$:` statements.
443443 */
444444function * analyzeReactiveScopes (
445- result : TSESParseForESLintResult ,
445+ result : TSESParseForESLintResult
446446) : Iterable < TransformInfo > {
447447 const scopeManager = result . scopeManager ;
448448 const throughIds = scopeManager . globalScope ! . through . map (
449- ( reference ) => reference . identifier ,
449+ ( reference ) => reference . identifier
450450 ) ;
451451 for ( const statement of result . ast . body ) {
452452 if ( statement . type === "LabeledStatement" && statement . label . name === "$" ) {
@@ -463,8 +463,7 @@ function* analyzeReactiveScopes(
463463 const left = statement . body . expression . left ;
464464 if (
465465 throughIds . some (
466- ( id ) =>
467- left . range [ 0 ] <= id . range [ 0 ] && id . range [ 1 ] <= left . range [ 1 ] ,
466+ ( id ) => left . range [ 0 ] <= id . range [ 0 ] && id . range [ 1 ] <= left . range [ 1 ]
468467 )
469468 ) {
470469 const node = statement ;
@@ -477,7 +476,7 @@ function* analyzeReactiveScopes(
477476 left ,
478477 expression ,
479478 result . ast . tokens ! ,
480- ctx ,
479+ ctx
481480 ) ,
482481 } ;
483482 continue ;
@@ -496,11 +495,11 @@ function* analyzeReactiveScopes(
496495 * Transform source code to provide the correct type information in the `$derived(...)` expression.
497496 */
498497function * analyzeDollarDerivedScopes (
499- result : TSESParseForESLintResult ,
498+ result : TSESParseForESLintResult
500499) : Iterable < TransformInfo > {
501500 const scopeManager = result . scopeManager ;
502501 const derivedReferences = scopeManager . globalScope ! . through . filter (
503- ( reference ) => reference . identifier . name === "$derived" ,
502+ ( reference ) => reference . identifier . name === "$derived"
504503 ) ;
505504 if ( ! derivedReferences . length ) {
506505 return ;
@@ -528,7 +527,7 @@ function* analyzeDollarDerivedScopes(
528527 */
529528function analyzeRenderScopes (
530529 code : { script : string ; render : string ; rootScope : string } ,
531- ctx : VirtualTypeScriptContext ,
530+ ctx : VirtualTypeScriptContext
532531) {
533532 ctx . appendOriginal ( code . script . length ) ;
534533 const renderFunctionName = ctx . generateUniqueId ( "render" ) ;
@@ -560,7 +559,7 @@ function analyzeRenderScopes(
560559 */
561560function applyTransforms (
562561 transforms : TransformInfo [ ] ,
563- ctx : VirtualTypeScriptContext ,
562+ ctx : VirtualTypeScriptContext
564563) {
565564 transforms . sort ( ( a , b ) => a . node . range [ 0 ] - b . node . range [ 0 ] ) ;
566565
@@ -582,7 +581,7 @@ function transformForDeclareReactiveVar(
582581 id : TSESTree . Identifier | TSESTree . ArrayPattern | TSESTree . ObjectPattern ,
583582 expression : TSESTree . AssignmentExpression ,
584583 tokens : TSESTree . Token [ ] ,
585- ctx : VirtualTypeScriptContext ,
584+ ctx : VirtualTypeScriptContext
586585) : void {
587586 // e.g.
588587 // From:
@@ -626,7 +625,7 @@ function transformForDeclareReactiveVar(
626625 let expressionCloseParen : TSESTree . Token | null = null ;
627626 const startIndex = sortedLastIndex (
628627 tokens ,
629- ( target ) => target . range [ 0 ] - statement . range [ 0 ] ,
628+ ( target ) => target . range [ 0 ] - statement . range [ 0 ]
630629 ) ;
631630 for ( let index = startIndex ; index < tokens . length ; index ++ ) {
632631 const token = tokens [ index ] ;
@@ -666,7 +665,7 @@ function transformForDeclareReactiveVar(
666665 ctx . appendVirtualScript ( "let " ) ;
667666 ctx . appendOriginal ( eq ? eq . range [ 1 ] : expression . right . range [ 0 ] ) ;
668667 ctx . appendVirtualScript (
669- `${ functionId } ();\nfunction ${ functionId } (){let ${ tmpVarId } ;return (${ tmpVarId } = ` ,
668+ `${ functionId } ();\nfunction ${ functionId } (){let ${ tmpVarId } ;return (${ tmpVarId } = `
670669 ) ;
671670 ctx . appendOriginal ( expression . right . range [ 1 ] ) ;
672671 ctx . appendVirtualScript ( `)` ) ;
@@ -772,7 +771,7 @@ function transformForDeclareReactiveVar(
772771 addElementsToSortedArray (
773772 program . tokens ! ,
774773 [ ...openParens , ...closeParens ] ,
775- ( a , b ) => a . range [ 0 ] - b . range [ 0 ] ,
774+ ( a , b ) => a . range [ 0 ] - b . range [ 0 ]
776775 ) ;
777776
778777 const scopeManager = result . scopeManager as ScopeManager ;
@@ -801,7 +800,7 @@ function transformForDeclareReactiveVar(
801800 */
802801function transformForReactiveStatement (
803802 statement : TSESTree . LabeledStatement ,
804- ctx : VirtualTypeScriptContext ,
803+ ctx : VirtualTypeScriptContext
805804) {
806805 const functionId = ctx . generateUniqueId ( "reactiveStatementScopeFunction" ) ;
807806 const originalBody = statement . body ;
@@ -834,13 +833,13 @@ function transformForReactiveStatement(
834833 */
835834function transformForDollarDerived (
836835 derivedCall : TSESTree . CallExpression ,
837- ctx : VirtualTypeScriptContext ,
836+ ctx : VirtualTypeScriptContext
838837) {
839838 const functionId = ctx . generateUniqueId ( "$derivedArgument" ) ;
840839 const expression = derivedCall . arguments [ 0 ] ;
841840 ctx . appendOriginal ( expression . range [ 0 ] ) ;
842841 ctx . appendVirtualScript (
843- `(()=>{return ${ functionId } ();function ${ functionId } (){return ` ,
842+ `(()=>{return ${ functionId } ();function ${ functionId } (){return `
844843 ) ;
845844 ctx . appendOriginal ( expression . range [ 1 ] ) ;
846845 ctx . appendVirtualScript ( `}})()` ) ;
@@ -889,7 +888,7 @@ function transformForDollarDerived(
889888 removeFunctionScope ( arg . callee . body . body [ 1 ] , scopeManager ) ;
890889 removeIdentifierReference (
891890 arg . callee . body . body [ 0 ] . argument . callee ,
892- scopeManager . acquire ( arg . callee ) ! ,
891+ scopeManager . acquire ( arg . callee ) !
893892 ) ;
894893 removeFunctionScope ( arg . callee , scopeManager ) ;
895894 return true ;
@@ -903,7 +902,7 @@ function removeFunctionScope(
903902 | TSESTree . FunctionDeclaration
904903 | TSESTree . FunctionExpression
905904 | TSESTree . ArrowFunctionExpression ,
906- scopeManager : ScopeManager ,
905+ scopeManager : ScopeManager
907906) {
908907 const scope = scopeManager . acquire ( node ) ! ;
909908 const upper = scope . upper ! ;
@@ -925,12 +924,12 @@ function removeFunctionScope(
925924 addElementsToSortedArray (
926925 upperVariable . identifiers ,
927926 variable . identifiers ,
928- ( a , b ) => a . range ! [ 0 ] - b . range ! [ 0 ] ,
927+ ( a , b ) => a . range ! [ 0 ] - b . range ! [ 0 ]
929928 ) ;
930929 addElementsToSortedArray (
931930 upperVariable . defs ,
932931 variable . defs ,
933- ( a , b ) => a . node . range ! [ 0 ] - b . node . range ! [ 0 ] ,
932+ ( a , b ) => a . node . range ! [ 0 ] - b . node . range ! [ 0 ]
934933 ) ;
935934 addAllReferences ( upperVariable . references , variable . references ) ;
936935 } else {
0 commit comments