From e355d5c4d1210ae8b74fd50be6263efc08b849e1 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Fri, 3 Feb 2023 23:15:31 +0900 Subject: [PATCH] fix: wrong variable scope in let directive (#271) * fix: wrong variable scope in let directive * Create angry-pumpkins-ring.md * fix --- .changeset/angry-pumpkins-ring.md | 5 + src/context/let-directive-collection.ts | 52 +- src/context/script-let.ts | 111 +- src/parser/converts/block.ts | 85 +- src/parser/converts/element.ts | 109 +- src/parser/index.ts | 14 +- src/parser/sort.ts | 2 +- src/parser/template.ts | 4 +- .../01-scope-output.json | 76 +- .../parser/ast/let-directive03-input.svelte | 9 + .../parser/ast/let-directive03-output.json | 2071 +++++++++++++++ .../ast/let-directive03-scope-output.json | 2325 +++++++++++++++++ tests/src/parser/parser.ts | 4 +- tools/update-fixtures.ts | 26 +- 14 files changed, 4676 insertions(+), 217 deletions(-) create mode 100644 .changeset/angry-pumpkins-ring.md create mode 100644 tests/fixtures/parser/ast/let-directive03-input.svelte create mode 100644 tests/fixtures/parser/ast/let-directive03-output.json create mode 100644 tests/fixtures/parser/ast/let-directive03-scope-output.json diff --git a/.changeset/angry-pumpkins-ring.md b/.changeset/angry-pumpkins-ring.md new file mode 100644 index 00000000..0fa8530a --- /dev/null +++ b/.changeset/angry-pumpkins-ring.md @@ -0,0 +1,5 @@ +--- +"svelte-eslint-parser": minor +--- + +fix: wrong variable scope in let directive diff --git a/src/context/let-directive-collection.ts b/src/context/let-directive-collection.ts index 1f061f46..6f205e38 100644 --- a/src/context/let-directive-collection.ts +++ b/src/context/let-directive-collection.ts @@ -1,45 +1,13 @@ -import type { SvelteLetDirective, SvelteName, SvelteNode } from "../ast"; +import type { SvelteLetDirective, SvelteName } from "../ast"; import type * as ESTree from "estree"; -import type { ScriptLetCallback, ScriptLetCallbackOption } from "./script-let"; +import type { ScriptLetBlockParam, ScriptLetCallback } from "./script-let"; /** A class that collects pattern nodes for Let directives. */ export class LetDirectiveCollection { - private readonly list: { - pattern: ESTree.Pattern | SvelteName; - directive: SvelteLetDirective; - typing: string; - callbacks: ScriptLetCallback[]; - }[] = []; + private readonly list: ScriptLetBlockParam[] = []; - public isEmpty(): boolean { - return this.list.length === 0; - } - - public getLetParams(): (ESTree.Pattern | SvelteName)[] { - return this.list.map((d) => d.pattern); - } - - public getParents(): SvelteNode[] { - return this.list.map((d) => d.directive); - } - - public getCallback(): ( - nodes: ESTree.Pattern[], - options: ScriptLetCallbackOption - ) => void { - return (nodes, options) => { - for (let index = 0; index < nodes.length; index++) { - const node = nodes[index]; - const { callbacks } = this.list[index]; - for (const callback of callbacks) { - callback(node, options); - } - } - }; - } - - public getTypes(): string[] { - return this.list.map((d) => d.typing); + public getLetParams(): ScriptLetBlockParam[] { + return this.list; } public addPattern( @@ -49,10 +17,14 @@ export class LetDirectiveCollection { ...callbacks: ScriptLetCallback[] ): ScriptLetCallback[] { this.list.push({ - pattern, - directive, + node: pattern, + parent: directive, typing, - callbacks, + callback(node, options) { + for (const callback of callbacks) { + callback(node, options); + } + }, }); return callbacks; } diff --git a/src/context/script-let.ts b/src/context/script-let.ts index 335661db..439d81aa 100644 --- a/src/context/script-let.ts +++ b/src/context/script-let.ts @@ -113,6 +113,12 @@ type ObjectShorthandProperty = ESTree.Property & { value: ESTree.Identifier; }; +export type ScriptLetBlockParam = { + node: ESTree.Pattern | SvelteName; + parent: SvelteNode; + typing: string; + callback: (node: ESTree.Pattern, options: ScriptLetCallbackOption) => void; +}; /** * A class that handles script fragments. * The script fragment AST node remaps and connects to the original directive AST node. @@ -408,62 +414,15 @@ export class ScriptLetContext { this.pushScope(restore, "});"); } - public nestBlock(block: SvelteNode): void; - - public nestBlock( - block: SvelteNode, - params: (ESTree.Pattern | SvelteName)[], - parents: SvelteNode[], - callback: ( - nodes: ESTree.Pattern[], - options: ScriptLetCallbackOption - ) => void, - typings: - | string[] - | ((helper: TypeGenHelper) => { - typings: string[]; - preparationScript?: string[]; - }) - ): void; - public nestBlock( block: SvelteNode, - params?: (ESTree.Pattern | SvelteName)[], - parents?: SvelteNode[], - callback?: ( - nodes: ESTree.Pattern[], - options: ScriptLetCallbackOption - ) => void, - typings?: - | string[] - | ((helper: TypeGenHelper) => { - typings: string[]; + params?: + | ScriptLetBlockParam[] + | ((helper: TypeGenHelper | null) => { + param: ScriptLetBlockParam; preparationScript?: string[]; }) ): void { - let arrayTypings: string[] = []; - if (typings && this.ctx.isTypeScript()) { - if (Array.isArray(typings)) { - arrayTypings = typings; - } else { - const generatedTypes = typings({ - generateUniqueId: (base) => this.generateUniqueId(base), - }); - arrayTypings = generatedTypes.typings; - if (generatedTypes.preparationScript) { - for (const preparationScript of generatedTypes.preparationScript) { - this.appendScriptWithoutOffset( - preparationScript, - (node, tokens, comments, result) => { - tokens.length = 0; - comments.length = 0; - removeAllScopeAndVariableAndReference(node, result); - } - ); - } - } - } - } if (!params) { const restore = this.appendScript( `{`, @@ -483,7 +442,44 @@ export class ScriptLetContext { ); this.pushScope(restore, "}"); } else { - const ranges = params.map(getNodeRange).sort(([a], [b]) => a - b); + let resolvedParams; + if (typeof params === "function") { + if (this.ctx.isTypeScript()) { + const generatedTypes = params({ + generateUniqueId: (base) => this.generateUniqueId(base), + }); + resolvedParams = [generatedTypes.param]; + if (generatedTypes.preparationScript) { + for (const preparationScript of generatedTypes.preparationScript) { + this.appendScriptWithoutOffset( + preparationScript, + (node, tokens, comments, result) => { + tokens.length = 0; + comments.length = 0; + removeAllScopeAndVariableAndReference(node, result); + } + ); + } + } + } else { + const generatedTypes = params(null); + resolvedParams = [generatedTypes.param]; + } + } else { + resolvedParams = params; + } + const sortedParams = [...resolvedParams] + .map((d) => { + return { + ...d, + range: getNodeRange(d.node), + }; + }) + .sort((a, b) => { + const [pA] = a.range; + const [pB] = b.range; + return pA - pB; + }); const maps: { index: number; @@ -492,8 +488,9 @@ export class ScriptLetContext { }[] = []; let source = ""; - for (let index = 0; index < ranges.length; index++) { - const range = ranges[index]; + for (let index = 0; index < sortedParams.length; index++) { + const param = sortedParams[index]; + const range = param.range; if (source) { source += ","; } @@ -505,7 +502,7 @@ export class ScriptLetContext { range, }); if (this.ctx.isTypeScript()) { - source += `: (${arrayTypings[index]})`; + source += `: (${param.typing})`; } } const restore = this.appendScript( @@ -517,9 +514,9 @@ export class ScriptLetContext { const scope = result.getScope(fn.body); // Process for nodes - callback!(fn.params, result); for (let index = 0; index < fn.params.length; index++) { const p = fn.params[index]; + sortedParams[index].callback(p, result); if (this.ctx.isTypeScript()) { const typeAnnotation = (p as any).typeAnnotation; delete (p as any).typeAnnotation; @@ -532,7 +529,7 @@ export class ScriptLetContext { removeAllScopeAndVariableAndReference(typeAnnotation, result); } - (p as any).parent = parents![index]; + (p as any).parent = sortedParams[index].parent; } // Process for scope diff --git a/src/parser/converts/block.ts b/src/parser/converts/block.ts index 83a92350..2bdd85a8 100644 --- a/src/parser/converts/block.ts +++ b/src/parser/converts/block.ts @@ -18,6 +18,7 @@ import type { import type { Context } from "../../context"; import { convertChildren } from "./element"; import { getWithLoc, indexOf, lastIndexOf } from "./common"; +import type * as ESTree from "estree"; /** Get start index of block */ function startBlockIndex(code: string, endIndex: number): number { @@ -281,37 +282,52 @@ export function convertAwaitBlock( }), }; if (node.value) { - ctx.scriptLet.nestBlock( - thenBlock, - [node.value], - [thenBlock], - ([value]) => { + const baseParam = { + node: node.value, + parent: thenBlock, + callback(value: ESTree.Pattern) { thenBlock.value = value; }, - ({ generateUniqueId }) => { - const expression = ctx.getText(node.expression); - if (node.expression.type === "Literal") { - return { - typings: [expression], - }; - } - const idAwaitThenValue = generateUniqueId("AwaitThenValue"); - if (node.expression.type === "Identifier") { - return { - preparationScript: [generateAwaitThenValueType(idAwaitThenValue)], - typings: [`${idAwaitThenValue}<(typeof ${expression})>`], - }; - } - const id = generateUniqueId(expression); + typing: "any", + }; + + ctx.scriptLet.nestBlock(thenBlock, (typeCtx) => { + if (!typeCtx) { return { - preparationScript: [ - `const ${id} = ${expression};`, - generateAwaitThenValueType(idAwaitThenValue), - ], - typings: [`${idAwaitThenValue}<(typeof ${id})>`], + param: baseParam, }; } - ); + const expression = ctx.getText(node.expression); + if (node.expression.type === "Literal") { + return { + param: { + ...baseParam, + typing: expression, + }, + }; + } + const idAwaitThenValue = typeCtx.generateUniqueId("AwaitThenValue"); + if (node.expression.type === "Identifier") { + return { + preparationScript: [generateAwaitThenValueType(idAwaitThenValue)], + param: { + ...baseParam, + typing: `${idAwaitThenValue}<(typeof ${expression})>`, + }, + }; + } + const id = typeCtx.generateUniqueId(expression); + return { + preparationScript: [ + `const ${id} = ${expression};`, + generateAwaitThenValueType(idAwaitThenValue), + ], + param: { + ...baseParam, + typing: `${idAwaitThenValue}<(typeof ${id})>`, + }, + }; + }); } else { ctx.scriptLet.nestBlock(thenBlock); } @@ -351,15 +367,16 @@ export function convertAwaitBlock( } as SvelteAwaitCatchBlock; if (node.error) { - ctx.scriptLet.nestBlock( - catchBlock, - [node.error], - [catchBlock], - ([error]) => { - catchBlock.error = error; + ctx.scriptLet.nestBlock(catchBlock, [ + { + node: node.error, + parent: catchBlock, + typing: "Error", + callback: (error) => { + catchBlock.error = error; + }, }, - ["Error"] - ); + ]); } else { ctx.scriptLet.nestBlock(catchBlock); } diff --git a/src/parser/converts/element.ts b/src/parser/converts/element.ts index 0a84eed6..e2c78dc9 100644 --- a/src/parser/converts/element.ts +++ b/src/parser/converts/element.ts @@ -43,6 +43,8 @@ import { import { convertText } from "./text"; import { convertAttributes } from "./attr"; import { convertConstTag } from "./const"; +import { sortNodes } from "../sort"; +import type { ScriptLetBlockParam } from "../../context/script-let"; /* eslint-disable complexity -- X */ /** Convert for Fragment or Element or ... */ @@ -169,6 +171,26 @@ export function* convertChildren( } } +/** Extract `let:` directives. */ +function extractLetDirectives(fragment: { + attributes: SvAST.AttributeOrDirective[]; +}): { + letDirectives: SvAST.LetDirective[]; + attributes: Exclude[]; +} { + const letDirectives: SvAST.LetDirective[] = []; + const attributes: Exclude[] = + []; + for (const attr of fragment.attributes) { + if (attr.type === "Let") { + letDirectives.push(attr); + } else { + attributes.push(attr); + } + } + return { letDirectives, attributes }; +} + /** Check if children needs a scope. */ function needScopeByChildren(fragment: { children: SvAST.TemplateNode[]; @@ -231,21 +253,26 @@ function convertHTMLElement( }; element.startTag.parent = element; - ctx.letDirCollections.beginExtract(); - element.startTag.attributes.push( - ...convertAttributes(node.attributes, element.startTag, ctx) - ); - const lets = ctx.letDirCollections.extract(); - if (lets.isEmpty() && !needScopeByChildren(node)) { + const { letDirectives, attributes } = extractLetDirectives(node); + const letParams: ScriptLetBlockParam[] = []; + if (letDirectives.length) { + ctx.letDirCollections.beginExtract(); + element.startTag.attributes.push( + ...convertAttributes(letDirectives, element.startTag, ctx) + ); + letParams.push(...ctx.letDirCollections.extract().getLetParams()); + } + if (!letParams.length && !needScopeByChildren(node)) { + element.startTag.attributes.push( + ...convertAttributes(attributes, element.startTag, ctx) + ); element.children.push(...convertChildren(node, element, ctx)); } else { - ctx.scriptLet.nestBlock( - element, - lets.getLetParams(), - lets.getParents(), - lets.getCallback(), - lets.getTypes() + ctx.scriptLet.nestBlock(element, letParams); + element.startTag.attributes.push( + ...convertAttributes(attributes, element.startTag, ctx) ); + sortNodes(element.startTag.attributes); element.children.push(...convertChildren(node, element, ctx)); ctx.scriptLet.closeScope(); } @@ -333,21 +360,26 @@ function convertSpecialElement( }; element.startTag.parent = element; - ctx.letDirCollections.beginExtract(); - element.startTag.attributes.push( - ...convertAttributes(node.attributes, element.startTag, ctx) - ); - const lets = ctx.letDirCollections.extract(); - if (lets.isEmpty() && !needScopeByChildren(node)) { + const { letDirectives, attributes } = extractLetDirectives(node); + const letParams: ScriptLetBlockParam[] = []; + if (letDirectives.length) { + ctx.letDirCollections.beginExtract(); + element.startTag.attributes.push( + ...convertAttributes(letDirectives, element.startTag, ctx) + ); + letParams.push(...ctx.letDirCollections.extract().getLetParams()); + } + if (!letParams.length && !needScopeByChildren(node)) { + element.startTag.attributes.push( + ...convertAttributes(attributes, element.startTag, ctx) + ); element.children.push(...convertChildren(node, element, ctx)); } else { - ctx.scriptLet.nestBlock( - element, - lets.getLetParams(), - lets.getParents(), - lets.getCallback(), - lets.getTypes() + ctx.scriptLet.nestBlock(element, letParams); + element.startTag.attributes.push( + ...convertAttributes(attributes, element.startTag, ctx) ); + sortNodes(element.startTag.attributes); element.children.push(...convertChildren(node, element, ctx)); ctx.scriptLet.closeScope(); } @@ -445,21 +477,26 @@ function convertComponentElement( }; element.startTag.parent = element; - ctx.letDirCollections.beginExtract(); - element.startTag.attributes.push( - ...convertAttributes(node.attributes, element.startTag, ctx) - ); - const lets = ctx.letDirCollections.extract(); - if (lets.isEmpty() && !needScopeByChildren(node)) { + const { letDirectives, attributes } = extractLetDirectives(node); + const letParams: ScriptLetBlockParam[] = []; + if (letDirectives.length) { + ctx.letDirCollections.beginExtract(); + element.startTag.attributes.push( + ...convertAttributes(letDirectives, element.startTag, ctx) + ); + letParams.push(...ctx.letDirCollections.extract().getLetParams()); + } + if (!letParams.length && !needScopeByChildren(node)) { + element.startTag.attributes.push( + ...convertAttributes(attributes, element.startTag, ctx) + ); element.children.push(...convertChildren(node, element, ctx)); } else { - ctx.scriptLet.nestBlock( - element, - lets.getLetParams(), - lets.getParents(), - lets.getCallback(), - lets.getTypes() + ctx.scriptLet.nestBlock(element, letParams); + element.startTag.attributes.push( + ...convertAttributes(attributes, element.startTag, ctx) ); + sortNodes(element.startTag.attributes); element.children.push(...convertChildren(node, element, ctx)); ctx.scriptLet.closeScope(); } diff --git a/src/parser/index.ts b/src/parser/index.ts index c39caae3..0bddc014 100644 --- a/src/parser/index.ts +++ b/src/parser/index.ts @@ -11,7 +11,7 @@ import type { ScopeManager } from "eslint-scope"; import { Variable } from "eslint-scope"; import { parseScript } from "./script"; import type * as SvAST from "./svelte-ast-types"; -import { sort } from "./sort"; +import { sortNodes } from "./sort"; import { parseTemplate } from "./template"; import { analyzePropsScope, @@ -93,8 +93,8 @@ export function parseForESLint( ctx.scriptLet.restore(resultScript); ctx.tokens.push(...resultScript.ast.tokens); ctx.comments.push(...resultScript.ast.comments); - sort(ctx.comments); - sort(ctx.tokens); + sortNodes(ctx.comments); + sortNodes(ctx.tokens); extractTokens(ctx); analyzeStoreScope(resultScript.scopeManager!); analyzeReactiveScope(resultScript.scopeManager!); @@ -179,7 +179,9 @@ export function parseForESLint( /** Extract tokens */ function extractTokens(ctx: Context) { - const useRanges = sort([...ctx.tokens, ...ctx.comments]).map((t) => t.range); + const useRanges = sortNodes([...ctx.tokens, ...ctx.comments]).map( + (t) => t.range + ); let range = useRanges.shift(); for (let index = 0; index < ctx.sourceCode.template.length; index++) { while (range && range[1] <= index) { @@ -201,8 +203,8 @@ function extractTokens(ctx: Context) { ctx.addToken("Identifier", { start: index, end: index + 1 }); } } - sort(ctx.comments); - sort(ctx.tokens); + sortNodes(ctx.comments); + sortNodes(ctx.tokens); /** * Checks if the given char is punctuator diff --git a/src/parser/sort.ts b/src/parser/sort.ts index 4a60adf5..ff1919be 100644 --- a/src/parser/sort.ts +++ b/src/parser/sort.ts @@ -1,7 +1,7 @@ /** * Sort tokens */ -export function sort( +export function sortNodes( tokens: T[] | null | undefined ): T[] { if (!tokens) { diff --git a/src/parser/template.ts b/src/parser/template.ts index 16ce0d77..2744e716 100644 --- a/src/parser/template.ts +++ b/src/parser/template.ts @@ -2,7 +2,7 @@ import { parse } from "svelte/compiler"; import type * as SvAST from "./svelte-ast-types"; import type { Context } from "../context"; import { convertSvelteRoot } from "./converts/index"; -import { sort } from "./sort"; +import { sortNodes } from "./sort"; import type { SvelteProgram } from "../ast"; import { ParseError } from ".."; @@ -22,7 +22,7 @@ export function parseTemplate( filename: parserOptions.filePath, }) as SvAST.Ast; const ast = convertSvelteRoot(svelteAst, ctx); - sort(ast.body); + sortNodes(ast.body); return { ast, diff --git a/tests/fixtures/parser/ast/docs/template-syntax/13-slot/03-slot-let-name-value/01-scope-output.json b/tests/fixtures/parser/ast/docs/template-syntax/13-slot/03-slot-let-name-value/01-scope-output.json index 50cd3af0..edb0ab26 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/13-slot/03-slot-let-name-value/01-scope-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/13-slot/03-slot-let-name-value/01-scope-output.json @@ -49,29 +49,6 @@ "init": null, "resolved": null }, - { - "identifier": { - "type": "Identifier", - "name": "items", - "range": [ - 160, - 165 - ], - "loc": { - "start": { - "line": 11, - "column": 12 - }, - "end": { - "line": 11, - "column": 17 - } - } - }, - "from": "module", - "init": null, - "resolved": null - }, { "identifier": { "type": "Identifier", @@ -1083,6 +1060,29 @@ } ], "references": [ + { + "identifier": { + "type": "Identifier", + "name": "items", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 17 + } + } + }, + "from": "function", + "init": null, + "resolved": null + }, { "identifier": { "type": "Identifier", @@ -1125,7 +1125,31 @@ } ], "childScopes": [], - "through": [] + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "items", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 17 + } + } + }, + "from": "function", + "init": null, + "resolved": null + } + ] } ], "through": [ @@ -1171,7 +1195,7 @@ } } }, - "from": "module", + "from": "function", "init": null, "resolved": null }, @@ -1244,7 +1268,7 @@ } } }, - "from": "module", + "from": "function", "init": null, "resolved": null }, diff --git a/tests/fixtures/parser/ast/let-directive03-input.svelte b/tests/fixtures/parser/ast/let-directive03-input.svelte new file mode 100644 index 00000000..c2f1d740 --- /dev/null +++ b/tests/fixtures/parser/ast/let-directive03-input.svelte @@ -0,0 +1,9 @@ + + + {data} +
+ {item.text} +
+
diff --git a/tests/fixtures/parser/ast/let-directive03-output.json b/tests/fixtures/parser/ast/let-directive03-output.json new file mode 100644 index 00000000..5d70d6e6 --- /dev/null +++ b/tests/fixtures/parser/ast/let-directive03-output.json @@ -0,0 +1,2071 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteScriptElement", + "name": { + "type": "SvelteName", + "name": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + "body": [ + { + "type": "ImportDeclaration", + "source": { + "type": "Literal", + "raw": "'mod'", + "value": "mod", + "range": [ + 32, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 28 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "FancyList", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "range": [ + 10, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 28 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 38, + 47 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "range": [ + 0, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "component", + "name": { + "type": "Identifier", + "name": "FancyList", + "range": [ + 49, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "foo", + "range": [ + 63, + 66 + ], + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "modifiers": [], + "range": [ + 59, + 66 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "expression": { + "type": "Identifier", + "name": "data", + "range": [ + 68, + 72 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 24 + } + } + }, + "range": [ + 59, + 73 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 25 + } + } + } + ], + "selfClosing": false, + "range": [ + 48, + 74 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 26 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 74, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "data", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + "range": [ + 76, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 82, + 84 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "div", + "range": [ + 85, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "slot", + "range": [ + 89, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "item", + "range": [ + 95, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 16 + } + } + } + ], + "range": [ + 89, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "modifiers": [], + "range": [ + 101, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "expression": { + "type": "Identifier", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "range": [ + 101, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "modifiers": [], + "range": [ + 110, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "expression": { + "type": "Identifier", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "range": [ + 110, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "class", + "range": [ + 120, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 37 + }, + "end": { + "line": 6, + "column": 42 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "item2", + "range": [ + 127, + 132 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 49 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "class", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 50 + }, + "end": { + "line": 6, + "column": 55 + } + } + }, + "range": [ + 127, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 55 + } + } + }, + "range": [ + 126, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 43 + }, + "end": { + "line": 6, + "column": 56 + } + } + } + ], + "range": [ + 120, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 37 + }, + "end": { + "line": 6, + "column": 56 + } + } + } + ], + "selfClosing": false, + "range": [ + 84, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 57 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 140, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 57 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "item", + "range": [ + 144, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "text", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "range": [ + 144, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "range": [ + 143, + 154 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 13 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 154, + 156 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 8, + "column": 1 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 156, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 7 + } + } + }, + "range": [ + 84, + 162 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 8, + "column": 7 + } + } + }, + { + "type": "SvelteText", + "value": "\n", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 9, + "column": 0 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 163, + 175 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + "range": [ + 48, + 175 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 9, + "column": 12 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + { + "type": "Keyword", + "value": "import", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Identifier", + "value": "FancyList", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "from", + "range": [ + 27, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "String", + "value": "'mod'", + "range": [ + 32, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 28 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 46, + 47 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + { + "type": "Identifier", + "value": "FancyList", + "range": [ + 49, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "let", + "range": [ + 59, + 62 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 15 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "foo", + "range": [ + 63, + 66 + ], + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 66, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 20 + } + } + }, + { + "type": "Identifier", + "value": "data", + "range": [ + 68, + 72 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 72, + 73 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 26 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 74, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + { + "type": "Identifier", + "value": "data", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 82, + 84 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 84, + 85 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "div", + "range": [ + 85, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "slot", + "range": [ + 89, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 93, + 94 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + } + }, + { + "type": "HTMLText", + "value": "item", + "range": [ + 95, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "let", + "range": [ + 101, + 104 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 6, + "column": 21 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + { + "type": "Identifier", + "value": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "let", + "range": [ + 110, + 113 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 6, + "column": 30 + }, + "end": { + "line": 6, + "column": 31 + } + } + }, + { + "type": "Identifier", + "value": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "class", + "range": [ + 120, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 37 + }, + "end": { + "line": 6, + "column": 42 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 6, + "column": 42 + }, + "end": { + "line": 6, + "column": 43 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 6, + "column": 43 + }, + "end": { + "line": 6, + "column": 44 + } + } + }, + { + "type": "Identifier", + "value": "item2", + "range": [ + 127, + 132 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 49 + } + } + }, + { + "type": "Punctuator", + "value": ".", + "range": [ + 132, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 49 + }, + "end": { + "line": 6, + "column": 50 + } + } + }, + { + "type": "Keyword", + "value": "class", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 50 + }, + "end": { + "line": 6, + "column": 55 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 55 + }, + "end": { + "line": 6, + "column": 56 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 56 + }, + "end": { + "line": 6, + "column": 57 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t\t", + "range": [ + 140, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 57 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 143, + 144 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 3 + } + } + }, + { + "type": "Identifier", + "value": "item", + "range": [ + 144, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ".", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + { + "type": "Identifier", + "value": "text", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 153, + 154 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 13 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 154, + 156 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 8, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 156, + 157 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 157, + 158 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 3 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "div", + "range": [ + 158, + 161 + ], + "loc": { + "start": { + "line": 8, + "column": 3 + }, + "end": { + "line": 8, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 7 + } + } + }, + { + "type": "HTMLText", + "value": "\n", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 163, + 164 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 164, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "FancyList", + "range": [ + 165, + 174 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 12 + } + } + } + ], + "range": [ + 0, + 176 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 10, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/let-directive03-scope-output.json b/tests/fixtures/parser/ast/let-directive03-scope-output.json new file mode 100644 index 00000000..8715fb62 --- /dev/null +++ b/tests/fixtures/parser/ast/let-directive03-scope-output.json @@ -0,0 +1,2325 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "FancyList", + "identifiers": [ + { + "type": "Identifier", + "name": "FancyList", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "name": { + "type": "Identifier", + "name": "FancyList", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "node": { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "FancyList", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "FancyList", + "range": [ + 49, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "FancyList", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "FancyList", + "range": [ + 49, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "FancyList", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "data", + "identifiers": [ + { + "type": "Identifier", + "name": "data", + "range": [ + 68, + 72 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 24 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "data", + "range": [ + 68, + 72 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 24 + } + } + }, + "node": { + "type": "SvelteElement", + "kind": "component", + "name": { + "type": "Identifier", + "name": "FancyList", + "range": [ + 49, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "foo", + "range": [ + 63, + 66 + ], + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "modifiers": [], + "range": [ + 59, + 66 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "expression": { + "type": "Identifier", + "name": "data", + "range": [ + 68, + 72 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 24 + } + } + }, + "range": [ + 59, + 73 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 25 + } + } + } + ], + "selfClosing": false, + "range": [ + 48, + 74 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 26 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 74, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "data", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + "range": [ + 76, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 82, + 84 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "div", + "range": [ + 85, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "slot", + "range": [ + 89, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "item", + "range": [ + 95, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 16 + } + } + } + ], + "range": [ + 89, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "modifiers": [], + "range": [ + 101, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "expression": { + "type": "Identifier", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "range": [ + 101, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "modifiers": [], + "range": [ + 110, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "expression": { + "type": "Identifier", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "range": [ + 110, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "class", + "range": [ + 120, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 37 + }, + "end": { + "line": 6, + "column": 42 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "item2", + "range": [ + 127, + 132 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 49 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "class", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 50 + }, + "end": { + "line": 6, + "column": 55 + } + } + }, + "range": [ + 127, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 55 + } + } + }, + "range": [ + 126, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 43 + }, + "end": { + "line": 6, + "column": 56 + } + } + } + ], + "range": [ + 120, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 37 + }, + "end": { + "line": 6, + "column": 56 + } + } + } + ], + "selfClosing": false, + "range": [ + 84, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 57 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 140, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 57 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "item", + "range": [ + 144, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "text", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "range": [ + 144, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "range": [ + 143, + 154 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 13 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 154, + 156 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 8, + "column": 1 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 156, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 7 + } + } + }, + "range": [ + 84, + 162 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 8, + "column": 7 + } + } + }, + { + "type": "SvelteText", + "value": "\n", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 9, + "column": 0 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 163, + 175 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + "range": [ + 48, + 175 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 9, + "column": 12 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "data", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "data", + "range": [ + 68, + 72 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 24 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "data", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "data", + "range": [ + 68, + 72 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 24 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "item", + "identifiers": [ + { + "type": "Identifier", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "node": { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "div", + "range": [ + 85, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "slot", + "range": [ + 89, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "item", + "range": [ + 95, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 16 + } + } + } + ], + "range": [ + 89, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "modifiers": [], + "range": [ + 101, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "expression": { + "type": "Identifier", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "range": [ + 101, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "modifiers": [], + "range": [ + 110, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "expression": { + "type": "Identifier", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "range": [ + 110, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "class", + "range": [ + 120, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 37 + }, + "end": { + "line": 6, + "column": 42 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "item2", + "range": [ + 127, + 132 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 49 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "class", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 50 + }, + "end": { + "line": 6, + "column": 55 + } + } + }, + "range": [ + 127, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 55 + } + } + }, + "range": [ + 126, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 43 + }, + "end": { + "line": 6, + "column": 56 + } + } + } + ], + "range": [ + 120, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 37 + }, + "end": { + "line": 6, + "column": 56 + } + } + } + ], + "selfClosing": false, + "range": [ + 84, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 57 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 140, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 57 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "item", + "range": [ + 144, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "text", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "range": [ + 144, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "range": [ + 143, + 154 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 13 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 154, + 156 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 8, + "column": 1 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 156, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 7 + } + } + }, + "range": [ + 84, + 162 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 8, + "column": 7 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "item", + "range": [ + 144, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + } + } + ] + }, + { + "name": "item2", + "identifiers": [ + { + "type": "Identifier", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "node": { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "div", + "range": [ + 85, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "slot", + "range": [ + 89, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "item", + "range": [ + 95, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 16 + } + } + } + ], + "range": [ + 89, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "modifiers": [], + "range": [ + 101, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "expression": { + "type": "Identifier", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "range": [ + 101, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Let", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "modifiers": [], + "range": [ + 110, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "expression": { + "type": "Identifier", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + "range": [ + 110, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 36 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "class", + "range": [ + 120, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 37 + }, + "end": { + "line": 6, + "column": 42 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "item2", + "range": [ + 127, + 132 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 49 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "class", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 50 + }, + "end": { + "line": 6, + "column": 55 + } + } + }, + "range": [ + 127, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 55 + } + } + }, + "range": [ + 126, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 43 + }, + "end": { + "line": 6, + "column": 56 + } + } + } + ], + "range": [ + 120, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 37 + }, + "end": { + "line": 6, + "column": 56 + } + } + } + ], + "selfClosing": false, + "range": [ + 84, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 57 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 140, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 57 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "item", + "range": [ + 144, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "text", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "range": [ + 144, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "range": [ + 143, + 154 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 13 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 154, + 156 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 8, + "column": 1 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 156, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 7 + } + } + }, + "range": [ + 84, + 162 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 8, + "column": 7 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "item2", + "range": [ + 127, + 132 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 49 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "item2", + "range": [ + 127, + 132 + ], + "loc": { + "start": { + "line": 6, + "column": 44 + }, + "end": { + "line": 6, + "column": 49 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "item2", + "range": [ + 114, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 31 + }, + "end": { + "line": 6, + "column": 36 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "item", + "range": [ + 144, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "item", + "range": [ + 105, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 26 + } + } + } + } + ], + "childScopes": [], + "through": [] + } + ], + "through": [] + } + ], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/src/parser/parser.ts b/tests/src/parser/parser.ts index 971cadd8..7e0ac95e 100644 --- a/tests/src/parser/parser.ts +++ b/tests/src/parser/parser.ts @@ -12,7 +12,7 @@ import { scopeToJSON, } from "./test-utils"; import type { Comment, SvelteProgram, Token } from "../../../src/ast"; -import { sort } from "../../../src/parser/sort"; +import { sortNodes } from "../../../src/parser/sort"; function parse(code: string, filePath: string) { return parseForESLint(code, { @@ -81,7 +81,7 @@ describe("Check for AST.", () => { }); function checkTokens(ast: SvelteProgram, input: string) { - const allTokens = sort([...ast.tokens, ...ast.comments]); + const allTokens = sortNodes([...ast.tokens, ...ast.comments]); // check loc for (const token of allTokens) { diff --git a/tools/update-fixtures.ts b/tools/update-fixtures.ts index 0d926321..8462649e 100644 --- a/tools/update-fixtures.ts +++ b/tools/update-fixtures.ts @@ -44,19 +44,6 @@ function parse(code: string, filePath: string) { }); } -for (const { input, inputFileName, outputFileName } of listupFixtures( - ERROR_FIXTURE_ROOT -)) { - // eslint-disable-next-line no-console -- ignore - console.log(inputFileName); - try { - parse(input, inputFileName); - } catch (e) { - const errorJson = astToJson(normalizeError(e)); - fs.writeFileSync(outputFileName, errorJson, "utf8"); - } -} - for (const { input, inputFileName, @@ -118,6 +105,19 @@ for (const { } } +for (const { input, inputFileName, outputFileName } of listupFixtures( + ERROR_FIXTURE_ROOT +)) { + // eslint-disable-next-line no-console -- ignore + console.log(inputFileName); + try { + parse(input, inputFileName); + } catch (e) { + const errorJson = astToJson(normalizeError(e)); + fs.writeFileSync(outputFileName, errorJson, "utf8"); + } +} + // eslint-disable-next-line require-jsdoc -- X function createLinter() { const linter = new Linter();