diff --git a/.changeset/blue-eggs-work.md b/.changeset/blue-eggs-work.md new file mode 100644 index 00000000..d76e8111 --- /dev/null +++ b/.changeset/blue-eggs-work.md @@ -0,0 +1,5 @@ +--- +"svelte-eslint-parser": minor +--- + +feat: improve scoping of snippet declarations acting as slot properties diff --git a/src/parser/analyze-scope.ts b/src/parser/analyze-scope.ts index 3f69b665..01fc9ab4 100644 --- a/src/parser/analyze-scope.ts +++ b/src/parser/analyze-scope.ts @@ -7,7 +7,12 @@ import type { SvelteScriptElement, SvelteSnippetBlock, } from "../ast/index.js"; -import { addReference, addVariable, getScopeFromNode } from "../scope/index.js"; +import { + addReference, + addVariable, + getScopeFromNode, + removeIdentifierVariable, +} from "../scope/index.js"; import { addElementToSortedArray } from "../utils/index.js"; import type { NormalizedParserOptions } from "./parser-options.js"; import type { SvelteParseContext } from "./svelte-parse-context.js"; @@ -304,11 +309,27 @@ export function analyzeSnippetsScope( if (!upperScope) continue; const variable = upperScope.set.get(snippet.id.name); if (!variable) continue; - // Add the virtual reference for reading. - const reference = addVirtualReference(snippet.id, variable, upperScope, { - read: true, - }); - (reference as any).svelteSnippetReference = true; + const defIds = variable.defs.map((d) => d.name); + const refs = variable.references.filter( + (id) => !defIds.includes(id.identifier), + ); + + if (refs.length <= 0) { + // If the snippet is not referenced, + // remove the a variable from the upperScope. + removeIdentifierVariable(snippet.id, upperScope); + } else { + // Add the virtual reference for reading. + const reference = addVirtualReference( + snippet.id, + variable, + upperScope, + { + read: true, + }, + ); + (reference as any).svelteSnippetReference = true; + } } } } diff --git a/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-input.svelte b/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-input.svelte new file mode 100644 index 00000000..dc87daf6 --- /dev/null +++ b/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-input.svelte @@ -0,0 +1,43 @@ + + +
+ + {#snippet children()} + fruit + qty + price + total + {/snippet} +
+ + + + {#snippet children(arg)} +

{arg}

+ {/snippet} + {#snippet c()} + + + {#snippet children(arg)} +

{arg}

+ {/snippet} +
+ {/snippet} +
+ + +{#snippet bar(arg)} +

{arg}

+{/snippet} + + {#snippet c()} + + {#snippet bar(arg)} +

{arg}

+ {/snippet} + + + {/snippet} +
diff --git a/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-output.json b/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-output.json new file mode 100644 index 00000000..943d855e --- /dev/null +++ b/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-output.json @@ -0,0 +1,23 @@ +[ + { + "ruleId": "no-unused-vars", + "code": "children", + "line": 7, + "column": 12, + "message": "'children' is defined but never used." + }, + { + "ruleId": "no-shadow", + "code": "bar", + "line": 37, + "column": 13, + "message": "'bar' is already declared in the upper scope on line 31 column 11." + }, + { + "ruleId": "@typescript-eslint/no-shadow", + "code": "bar", + "line": 37, + "column": 13, + "message": "'bar' is already declared in the upper scope on line 31 column 11." + } +] \ No newline at end of file diff --git a/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-requirements.json b/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-requirements.json new file mode 100644 index 00000000..809a4e1f --- /dev/null +++ b/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-requirements.json @@ -0,0 +1,5 @@ +{ + "parse": { + "svelte": ">=5.0.0-0" + } +} \ No newline at end of file diff --git a/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-setup.ts b/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-setup.ts new file mode 100644 index 00000000..303b59e4 --- /dev/null +++ b/tests/fixtures/integrations/snippet-scope/snippet-shadow-scope-setup.ts @@ -0,0 +1,32 @@ +import type { Linter } from "eslint"; +import { generateParserOptions } from "../../../src/parser/test-utils.js"; +import { rules } from "@typescript-eslint/eslint-plugin"; +import * as parser from "../../../../src/index.js"; +import globals from "globals"; + +export function getConfig(): Linter.Config { + return { + plugins: { + "@typescript-eslint": { + rules: rules as any, + }, + }, + languageOptions: { + parser, + parserOptions: { + ...generateParserOptions(), + svelteFeatures: { runes: true }, + }, + globals: { + ...globals.browser, + ...globals.es2021, + }, + }, + rules: { + "no-shadow": "error", + "@typescript-eslint/no-shadow": "error", + "no-undef": "error", + "no-unused-vars": "error", + }, + }; +} diff --git a/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-setup.ts b/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-setup.ts index e14f8589..9b7181f5 100644 --- a/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-setup.ts +++ b/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-setup.ts @@ -1,7 +1,7 @@ import type { Linter } from "eslint"; -import { generateParserOptions } from "../../../src/parser/test-utils"; +import { generateParserOptions } from "../../../src/parser/test-utils.js"; import { rules } from "@typescript-eslint/eslint-plugin"; -import * as parser from "../../../../src"; +import * as parser from "../../../../src/index.js"; import globals from "globals"; export function getConfig(): Linter.Config { diff --git a/tests/fixtures/parser/ast/svelte5/docs/snippets/07-passing-snippets-to-components-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/snippets/07-passing-snippets-to-components-scope-output.json index 44953fc4..7acf4256 100644 --- a/tests/fixtures/parser/ast/svelte5/docs/snippets/07-passing-snippets-to-components-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/docs/snippets/07-passing-snippets-to-components-scope-output.json @@ -95,1416 +95,7 @@ "childScopes": [ { "type": "block", - "variables": [ - { - "name": "header", - "identifiers": [ - { - "type": "Identifier", - "name": "header", - "range": [ - 85, - 91 - ], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 17 - } - } - } - ], - "defs": [ - { - "type": "FunctionName", - "name": { - "type": "Identifier", - "name": "header", - "range": [ - 85, - 91 - ], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 17 - } - } - }, - "node": { - "type": "SvelteSnippetBlock", - "id": { - "type": "Identifier", - "name": "header", - "range": [ - 85, - 91 - ], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 17 - } - } - }, - "params": [], - "children": [ - { - "type": "SvelteElement", - "kind": "html", - "name": { - "type": "SvelteName", - "name": "th", - "range": [ - 98, - 100 - ], - "loc": { - "start": { - "line": 4, - "column": 3 - }, - "end": { - "line": 4, - "column": 5 - } - } - }, - "startTag": { - "type": "SvelteStartTag", - "attributes": [], - "selfClosing": false, - "range": [ - 97, - 101 - ], - "loc": { - "start": { - "line": 4, - "column": 2 - }, - "end": { - "line": 4, - "column": 6 - } - } - }, - "children": [ - { - "type": "SvelteText", - "value": "fruit", - "range": [ - 101, - 106 - ], - "loc": { - "start": { - "line": 4, - "column": 6 - }, - "end": { - "line": 4, - "column": 11 - } - } - } - ], - "endTag": { - "type": "SvelteEndTag", - "range": [ - 106, - 111 - ], - "loc": { - "start": { - "line": 4, - "column": 11 - }, - "end": { - "line": 4, - "column": 16 - } - } - }, - "range": [ - 97, - 111 - ], - "loc": { - "start": { - "line": 4, - "column": 2 - }, - "end": { - "line": 4, - "column": 16 - } - } - }, - { - "type": "SvelteText", - "value": "\n\t\t", - "range": [ - 111, - 114 - ], - "loc": { - "start": { - "line": 4, - "column": 16 - }, - "end": { - "line": 5, - "column": 2 - } - } - }, - { - "type": "SvelteElement", - "kind": "html", - "name": { - "type": "SvelteName", - "name": "th", - "range": [ - 115, - 117 - ], - "loc": { - "start": { - "line": 5, - "column": 3 - }, - "end": { - "line": 5, - "column": 5 - } - } - }, - "startTag": { - "type": "SvelteStartTag", - "attributes": [], - "selfClosing": false, - "range": [ - 114, - 118 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 6 - } - } - }, - "children": [ - { - "type": "SvelteText", - "value": "qty", - "range": [ - 118, - 121 - ], - "loc": { - "start": { - "line": 5, - "column": 6 - }, - "end": { - "line": 5, - "column": 9 - } - } - } - ], - "endTag": { - "type": "SvelteEndTag", - "range": [ - 121, - 126 - ], - "loc": { - "start": { - "line": 5, - "column": 9 - }, - "end": { - "line": 5, - "column": 14 - } - } - }, - "range": [ - 114, - 126 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 14 - } - } - }, - { - "type": "SvelteText", - "value": "\n\t\t", - "range": [ - 126, - 129 - ], - "loc": { - "start": { - "line": 5, - "column": 14 - }, - "end": { - "line": 6, - "column": 2 - } - } - }, - { - "type": "SvelteElement", - "kind": "html", - "name": { - "type": "SvelteName", - "name": "th", - "range": [ - 130, - 132 - ], - "loc": { - "start": { - "line": 6, - "column": 3 - }, - "end": { - "line": 6, - "column": 5 - } - } - }, - "startTag": { - "type": "SvelteStartTag", - "attributes": [], - "selfClosing": false, - "range": [ - 129, - 133 - ], - "loc": { - "start": { - "line": 6, - "column": 2 - }, - "end": { - "line": 6, - "column": 6 - } - } - }, - "children": [ - { - "type": "SvelteText", - "value": "price", - "range": [ - 133, - 138 - ], - "loc": { - "start": { - "line": 6, - "column": 6 - }, - "end": { - "line": 6, - "column": 11 - } - } - } - ], - "endTag": { - "type": "SvelteEndTag", - "range": [ - 138, - 143 - ], - "loc": { - "start": { - "line": 6, - "column": 11 - }, - "end": { - "line": 6, - "column": 16 - } - } - }, - "range": [ - 129, - 143 - ], - "loc": { - "start": { - "line": 6, - "column": 2 - }, - "end": { - "line": 6, - "column": 16 - } - } - }, - { - "type": "SvelteText", - "value": "\n\t\t", - "range": [ - 143, - 146 - ], - "loc": { - "start": { - "line": 6, - "column": 16 - }, - "end": { - "line": 7, - "column": 2 - } - } - }, - { - "type": "SvelteElement", - "kind": "html", - "name": { - "type": "SvelteName", - "name": "th", - "range": [ - 147, - 149 - ], - "loc": { - "start": { - "line": 7, - "column": 3 - }, - "end": { - "line": 7, - "column": 5 - } - } - }, - "startTag": { - "type": "SvelteStartTag", - "attributes": [], - "selfClosing": false, - "range": [ - 146, - 150 - ], - "loc": { - "start": { - "line": 7, - "column": 2 - }, - "end": { - "line": 7, - "column": 6 - } - } - }, - "children": [ - { - "type": "SvelteText", - "value": "total", - "range": [ - 150, - 155 - ], - "loc": { - "start": { - "line": 7, - "column": 6 - }, - "end": { - "line": 7, - "column": 11 - } - } - } - ], - "endTag": { - "type": "SvelteEndTag", - "range": [ - 155, - 160 - ], - "loc": { - "start": { - "line": 7, - "column": 11 - }, - "end": { - "line": 7, - "column": 16 - } - } - }, - "range": [ - 146, - 160 - ], - "loc": { - "start": { - "line": 7, - "column": 2 - }, - "end": { - "line": 7, - "column": 16 - } - } - } - ], - "range": [ - 75, - 172 - ], - "loc": { - "start": { - "line": 3, - "column": 1 - }, - "end": { - "line": 8, - "column": 11 - } - } - } - } - ], - "references": [ - { - "identifier": { - "type": "Identifier", - "name": "header", - "range": [ - 85, - 91 - ], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 17 - } - } - }, - "from": "block", - "init": null, - "resolved": { - "type": "Identifier", - "name": "header", - "range": [ - 85, - 91 - ], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 17 - } - } - } - } - ] - }, - { - "name": "row", - "identifiers": [ - { - "type": "Identifier", - "name": "row", - "range": [ - 185, - 188 - ], - "loc": { - "start": { - "line": 10, - "column": 11 - }, - "end": { - "line": 10, - "column": 14 - } - } - } - ], - "defs": [ - { - "type": "FunctionName", - "name": { - "type": "Identifier", - "name": "row", - "range": [ - 185, - 188 - ], - "loc": { - "start": { - "line": 10, - "column": 11 - }, - "end": { - "line": 10, - "column": 14 - } - } - }, - "node": { - "type": "SvelteSnippetBlock", - "id": { - "type": "Identifier", - "name": "row", - "range": [ - 185, - 188 - ], - "loc": { - "start": { - "line": 10, - "column": 11 - }, - "end": { - "line": 10, - "column": 14 - } - } - }, - "params": [ - { - "type": "Identifier", - "name": "d", - "range": [ - 189, - 190 - ], - "loc": { - "start": { - "line": 10, - "column": 15 - }, - "end": { - "line": 10, - "column": 16 - } - } - } - ], - "children": [ - { - "type": "SvelteElement", - "kind": "html", - "name": { - "type": "SvelteName", - "name": "td", - "range": [ - 196, - 198 - ], - "loc": { - "start": { - "line": 11, - "column": 3 - }, - "end": { - "line": 11, - "column": 5 - } - } - }, - "startTag": { - "type": "SvelteStartTag", - "attributes": [], - "selfClosing": false, - "range": [ - 195, - 199 - ], - "loc": { - "start": { - "line": 11, - "column": 2 - }, - "end": { - "line": 11, - "column": 6 - } - } - }, - "children": [ - { - "type": "SvelteMustacheTag", - "kind": "text", - "expression": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "d", - "range": [ - 200, - 201 - ], - "loc": { - "start": { - "line": 11, - "column": 7 - }, - "end": { - "line": 11, - "column": 8 - } - } - }, - "optional": false, - "property": { - "type": "Identifier", - "name": "name", - "range": [ - 202, - 206 - ], - "loc": { - "start": { - "line": 11, - "column": 9 - }, - "end": { - "line": 11, - "column": 13 - } - } - }, - "range": [ - 200, - 206 - ], - "loc": { - "start": { - "line": 11, - "column": 7 - }, - "end": { - "line": 11, - "column": 13 - } - } - }, - "range": [ - 199, - 207 - ], - "loc": { - "start": { - "line": 11, - "column": 6 - }, - "end": { - "line": 11, - "column": 14 - } - } - } - ], - "endTag": { - "type": "SvelteEndTag", - "range": [ - 207, - 212 - ], - "loc": { - "start": { - "line": 11, - "column": 14 - }, - "end": { - "line": 11, - "column": 19 - } - } - }, - "range": [ - 195, - 212 - ], - "loc": { - "start": { - "line": 11, - "column": 2 - }, - "end": { - "line": 11, - "column": 19 - } - } - }, - { - "type": "SvelteText", - "value": "\n\t\t", - "range": [ - 212, - 215 - ], - "loc": { - "start": { - "line": 11, - "column": 19 - }, - "end": { - "line": 12, - "column": 2 - } - } - }, - { - "type": "SvelteElement", - "kind": "html", - "name": { - "type": "SvelteName", - "name": "td", - "range": [ - 216, - 218 - ], - "loc": { - "start": { - "line": 12, - "column": 3 - }, - "end": { - "line": 12, - "column": 5 - } - } - }, - "startTag": { - "type": "SvelteStartTag", - "attributes": [], - "selfClosing": false, - "range": [ - 215, - 219 - ], - "loc": { - "start": { - "line": 12, - "column": 2 - }, - "end": { - "line": 12, - "column": 6 - } - } - }, - "children": [ - { - "type": "SvelteMustacheTag", - "kind": "text", - "expression": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "d", - "range": [ - 220, - 221 - ], - "loc": { - "start": { - "line": 12, - "column": 7 - }, - "end": { - "line": 12, - "column": 8 - } - } - }, - "optional": false, - "property": { - "type": "Identifier", - "name": "qty", - "range": [ - 222, - 225 - ], - "loc": { - "start": { - "line": 12, - "column": 9 - }, - "end": { - "line": 12, - "column": 12 - } - } - }, - "range": [ - 220, - 225 - ], - "loc": { - "start": { - "line": 12, - "column": 7 - }, - "end": { - "line": 12, - "column": 12 - } - } - }, - "range": [ - 219, - 226 - ], - "loc": { - "start": { - "line": 12, - "column": 6 - }, - "end": { - "line": 12, - "column": 13 - } - } - } - ], - "endTag": { - "type": "SvelteEndTag", - "range": [ - 226, - 231 - ], - "loc": { - "start": { - "line": 12, - "column": 13 - }, - "end": { - "line": 12, - "column": 18 - } - } - }, - "range": [ - 215, - 231 - ], - "loc": { - "start": { - "line": 12, - "column": 2 - }, - "end": { - "line": 12, - "column": 18 - } - } - }, - { - "type": "SvelteText", - "value": "\n\t\t", - "range": [ - 231, - 234 - ], - "loc": { - "start": { - "line": 12, - "column": 18 - }, - "end": { - "line": 13, - "column": 2 - } - } - }, - { - "type": "SvelteElement", - "kind": "html", - "name": { - "type": "SvelteName", - "name": "td", - "range": [ - 235, - 237 - ], - "loc": { - "start": { - "line": 13, - "column": 3 - }, - "end": { - "line": 13, - "column": 5 - } - } - }, - "startTag": { - "type": "SvelteStartTag", - "attributes": [], - "selfClosing": false, - "range": [ - 234, - 238 - ], - "loc": { - "start": { - "line": 13, - "column": 2 - }, - "end": { - "line": 13, - "column": 6 - } - } - }, - "children": [ - { - "type": "SvelteMustacheTag", - "kind": "text", - "expression": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "d", - "range": [ - 239, - 240 - ], - "loc": { - "start": { - "line": 13, - "column": 7 - }, - "end": { - "line": 13, - "column": 8 - } - } - }, - "optional": false, - "property": { - "type": "Identifier", - "name": "price", - "range": [ - 241, - 246 - ], - "loc": { - "start": { - "line": 13, - "column": 9 - }, - "end": { - "line": 13, - "column": 14 - } - } - }, - "range": [ - 239, - 246 - ], - "loc": { - "start": { - "line": 13, - "column": 7 - }, - "end": { - "line": 13, - "column": 14 - } - } - }, - "range": [ - 238, - 247 - ], - "loc": { - "start": { - "line": 13, - "column": 6 - }, - "end": { - "line": 13, - "column": 15 - } - } - } - ], - "endTag": { - "type": "SvelteEndTag", - "range": [ - 247, - 252 - ], - "loc": { - "start": { - "line": 13, - "column": 15 - }, - "end": { - "line": 13, - "column": 20 - } - } - }, - "range": [ - 234, - 252 - ], - "loc": { - "start": { - "line": 13, - "column": 2 - }, - "end": { - "line": 13, - "column": 20 - } - } - }, - { - "type": "SvelteText", - "value": "\n\t\t", - "range": [ - 252, - 255 - ], - "loc": { - "start": { - "line": 13, - "column": 20 - }, - "end": { - "line": 14, - "column": 2 - } - } - }, - { - "type": "SvelteElement", - "kind": "html", - "name": { - "type": "SvelteName", - "name": "td", - "range": [ - 256, - 258 - ], - "loc": { - "start": { - "line": 14, - "column": 3 - }, - "end": { - "line": 14, - "column": 5 - } - } - }, - "startTag": { - "type": "SvelteStartTag", - "attributes": [], - "selfClosing": false, - "range": [ - 255, - 259 - ], - "loc": { - "start": { - "line": 14, - "column": 2 - }, - "end": { - "line": 14, - "column": 6 - } - } - }, - "children": [ - { - "type": "SvelteMustacheTag", - "kind": "text", - "expression": { - "type": "BinaryExpression", - "left": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "d", - "range": [ - 260, - 261 - ], - "loc": { - "start": { - "line": 14, - "column": 7 - }, - "end": { - "line": 14, - "column": 8 - } - } - }, - "optional": false, - "property": { - "type": "Identifier", - "name": "qty", - "range": [ - 262, - 265 - ], - "loc": { - "start": { - "line": 14, - "column": 9 - }, - "end": { - "line": 14, - "column": 12 - } - } - }, - "range": [ - 260, - 265 - ], - "loc": { - "start": { - "line": 14, - "column": 7 - }, - "end": { - "line": 14, - "column": 12 - } - } - }, - "operator": "*", - "right": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "d", - "range": [ - 268, - 269 - ], - "loc": { - "start": { - "line": 14, - "column": 15 - }, - "end": { - "line": 14, - "column": 16 - } - } - }, - "optional": false, - "property": { - "type": "Identifier", - "name": "price", - "range": [ - 270, - 275 - ], - "loc": { - "start": { - "line": 14, - "column": 17 - }, - "end": { - "line": 14, - "column": 22 - } - } - }, - "range": [ - 268, - 275 - ], - "loc": { - "start": { - "line": 14, - "column": 15 - }, - "end": { - "line": 14, - "column": 22 - } - } - }, - "range": [ - 260, - 275 - ], - "loc": { - "start": { - "line": 14, - "column": 7 - }, - "end": { - "line": 14, - "column": 22 - } - } - }, - "range": [ - 259, - 276 - ], - "loc": { - "start": { - "line": 14, - "column": 6 - }, - "end": { - "line": 14, - "column": 23 - } - } - } - ], - "endTag": { - "type": "SvelteEndTag", - "range": [ - 276, - 281 - ], - "loc": { - "start": { - "line": 14, - "column": 23 - }, - "end": { - "line": 14, - "column": 28 - } - } - }, - "range": [ - 255, - 281 - ], - "loc": { - "start": { - "line": 14, - "column": 2 - }, - "end": { - "line": 14, - "column": 28 - } - } - } - ], - "range": [ - 175, - 293 - ], - "loc": { - "start": { - "line": 10, - "column": 1 - }, - "end": { - "line": 15, - "column": 11 - } - } - } - } - ], - "references": [ - { - "identifier": { - "type": "Identifier", - "name": "row", - "range": [ - 185, - 188 - ], - "loc": { - "start": { - "line": 10, - "column": 11 - }, - "end": { - "line": 10, - "column": 14 - } - } - }, - "from": "block", - "init": null, - "resolved": { - "type": "Identifier", - "name": "row", - "range": [ - 185, - 188 - ], - "loc": { - "start": { - "line": 10, - "column": 11 - }, - "end": { - "line": 10, - "column": 14 - } - } - } - } - ] - } - ], + "variables": [], "references": [ { "identifier": { diff --git a/tests/fixtures/parser/ast/svelte5/docs/svelte-boundary/02-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/svelte-boundary/02-scope-output.json index 300d188e..67530720 100644 --- a/tests/fixtures/parser/ast/svelte5/docs/svelte-boundary/02-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/docs/svelte-boundary/02-scope-output.json @@ -71,338 +71,7 @@ "childScopes": [ { "type": "block", - "variables": [ - { - "name": "failed", - "identifiers": [ - { - "type": "Identifier", - "name": "failed", - "range": [ - 50, - 56 - ], - "loc": { - "start": { - "line": 4, - "column": 11 - }, - "end": { - "line": 4, - "column": 17 - } - } - } - ], - "defs": [ - { - "type": "FunctionName", - "name": { - "type": "Identifier", - "name": "failed", - "range": [ - 50, - 56 - ], - "loc": { - "start": { - "line": 4, - "column": 11 - }, - "end": { - "line": 4, - "column": 17 - } - } - }, - "node": { - "type": "SvelteSnippetBlock", - "id": { - "type": "Identifier", - "name": "failed", - "range": [ - 50, - 56 - ], - "loc": { - "start": { - "line": 4, - "column": 11 - }, - "end": { - "line": 4, - "column": 17 - } - } - }, - "params": [ - { - "type": "Identifier", - "name": "error", - "range": [ - 57, - 62 - ], - "loc": { - "start": { - "line": 4, - "column": 18 - }, - "end": { - "line": 4, - "column": 23 - } - } - }, - { - "type": "Identifier", - "name": "reset", - "range": [ - 64, - 69 - ], - "loc": { - "start": { - "line": 4, - "column": 25 - }, - "end": { - "line": 4, - "column": 30 - } - } - } - ], - "children": [ - { - "type": "SvelteElement", - "kind": "html", - "name": { - "type": "SvelteName", - "name": "button", - "range": [ - 75, - 81 - ], - "loc": { - "start": { - "line": 5, - "column": 3 - }, - "end": { - "line": 5, - "column": 9 - } - } - }, - "startTag": { - "type": "SvelteStartTag", - "attributes": [ - { - "type": "SvelteAttribute", - "key": { - "type": "SvelteName", - "name": "onclick", - "range": [ - 82, - 89 - ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 17 - } - } - }, - "boolean": false, - "value": [ - { - "type": "SvelteMustacheTag", - "kind": "text", - "expression": { - "type": "Identifier", - "name": "reset", - "range": [ - 91, - 96 - ], - "loc": { - "start": { - "line": 5, - "column": 19 - }, - "end": { - "line": 5, - "column": 24 - } - } - }, - "range": [ - 90, - 97 - ], - "loc": { - "start": { - "line": 5, - "column": 18 - }, - "end": { - "line": 5, - "column": 25 - } - } - } - ], - "range": [ - 82, - 97 - ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 25 - } - } - } - ], - "selfClosing": false, - "range": [ - 74, - 98 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 26 - } - } - }, - "children": [ - { - "type": "SvelteText", - "value": "oops! try again", - "range": [ - 98, - 113 - ], - "loc": { - "start": { - "line": 5, - "column": 26 - }, - "end": { - "line": 5, - "column": 41 - } - } - } - ], - "endTag": { - "type": "SvelteEndTag", - "range": [ - 113, - 122 - ], - "loc": { - "start": { - "line": 5, - "column": 41 - }, - "end": { - "line": 5, - "column": 50 - } - } - }, - "range": [ - 74, - 122 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 50 - } - } - } - ], - "range": [ - 40, - 134 - ], - "loc": { - "start": { - "line": 4, - "column": 1 - }, - "end": { - "line": 6, - "column": 11 - } - } - } - } - ], - "references": [ - { - "identifier": { - "type": "Identifier", - "name": "failed", - "range": [ - 50, - 56 - ], - "loc": { - "start": { - "line": 4, - "column": 11 - }, - "end": { - "line": 4, - "column": 17 - } - } - }, - "from": "block", - "init": null, - "resolved": { - "type": "Identifier", - "name": "failed", - "range": [ - 50, - 56 - ], - "loc": { - "start": { - "line": 4, - "column": 11 - }, - "end": { - "line": 4, - "column": 17 - } - } - } - } - ] - } - ], + "variables": [], "references": [ { "identifier": {