fix(html): register {@html} expression as a template reference in Svelte - #10535
Conversation
🦋 Changeset detectedLatest commit: 617b31a The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
…s unused
The `parse_embedded_nodes` function was silently skipping `SvelteHtmlBlock`
nodes (`{@html expr}`), so the JS expression inside them was never added to
the embedded snippet list. As a result, any variable referenced only via
`{@html variable}` was incorrectly reported as unused by `noUnusedVariables`.
Now `SvelteHtmlBlock` is handled the same way as other expression-bearing
blocks (`SvelteIfBlock`, `SvelteKeyBlock`, etc.): the expression is parsed as
a JS snippet and visited so its identifier references are tracked.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
df0ee3c to
f49103e
Compare
WalkthroughThe PR fixes a false positive in the Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
In Svelte files, <pre> was being parsed the same way as <script>/<style>:
its entire content was consumed as a single raw HTML_LITERAL token inside
HtmlEmbeddedContent. That prevented the expression-tracking passes in
parse_embedded_nodes from seeing any Svelte blocks inside <pre>, so
variables referenced only via <pre>{@html expr}</pre> or <pre>{expr}</pre>
were still incorrectly reported as unused by noUnusedVariables.
The formatter already has an independent HTML_VERBATIM_TAGS list that
includes "pre", which causes it to emit <pre> content verbatim regardless
of how the parser represents the children. Skipping the embedded-language
path in the parser for Svelte is therefore safe: formatting is unchanged,
and {@html} / interpolation nodes inside <pre> are now visible as proper
AST descendants.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merging this PR will not alter performance
Comparing Footnotes
|
|
@Mokto CI is failing, do you want to address that? |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@biomejs/biome](https://biomejs.dev) ([source](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome)) | imports | patch | [`2.5.0` -> `2.5.1`](https://renovatebot.com/diffs/npm/@biomejs%2fbiome/2.5.0/2.5.1) | --- ### Release Notes <details> <summary>biomejs/biome (@​biomejs/biome)</summary> ### [`v2.5.1`](https://github.com/biomejs/biome/blob/HEAD/packages/@​biomejs/biome/CHANGELOG.md#251) [Compare Source](https://github.com/biomejs/biome/compare/@biomejs/biome@2.5.0...@biomejs/biome@2.5.1) ##### Patch Changes - [#​10722](biomejs/biome#10722) [`f8a303d`](biomejs/biome@f8a303d) Thanks [@​denbezrukov](https://github.com/denbezrukov)! - Fixed CSS formatter output for comments between import media queries. ```diff -@​import url("print.css") print, -/* comment */ -screen; +@​import url("print.css") print, /* comment */ screen; ``` - [#​10738](biomejs/biome#10738) [`9fdc560`](biomejs/biome@9fdc560) Thanks [@​JamBalaya56562](https://github.com/JamBalaya56562)! - Fixed [#​9899](biomejs/biome#9899): the `json` and `json-pretty` reporters now escape backslashes in a diagnostic's `location.path`. Previously, paths containing backslashes (such as Windows-style paths) were emitted unescaped, producing invalid JSON. ```diff - "path": "src\account\setup-passkey.tsx", + "path": "src\\account\\setup-passkey.tsx", ``` - [#​10626](biomejs/biome#10626) [`5f837df`](biomejs/biome@5f837df) Thanks [@​tom-groves](https://github.com/tom-groves)! - Fixed [#​10625](biomejs/biome#10625): `biome migrate` no longer emits an invalid trailing comma when a renamed rule (such as `noConsoleLog` → `noConsole`) is the last member of its rule group. Previously this produced malformed output that aborted the migration of a strict-JSON `biome.json` with a parsing error. - [#​10535](biomejs/biome#10535) [`c245f9d`](biomejs/biome@c245f9d) Thanks [@​Mokto](https://github.com/Mokto)! - Fixed a false positive in [`noUnusedVariables`](https://biomejs.dev/linter/rules/no-unused-variables/) for Svelte files where variables referenced inside `{@​html expr}` blocks were incorrectly reported as unused. - [#​10668](biomejs/biome#10668) [`a0f197e`](biomejs/biome@a0f197e) Thanks [@​Netail](https://github.com/Netail)! - The `biome init` command has been updated to include a more up-to-date URL to [the first-party extensions page](https://biomejs.dev/editors/first-party-extensions/). - [#​10667](biomejs/biome#10667) [`d8c3e87`](biomejs/biome@d8c3e87) Thanks [@​Netail](https://github.com/Netail)! - Fixed [#​10664](biomejs/biome#10664): [useErrorCause](https://biomejs.dev/linter/rules/use-error-cause/) now correctly detects a shorthand property. - [#​10696](biomejs/biome#10696) [`ef2373f`](biomejs/biome@ef2373f) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​9566](biomejs/biome#9566). Improved how the Biome Language Server loads multiple configuration files inside a workspace. - [#​10705](biomejs/biome#10705) [`4ccb410`](biomejs/biome@4ccb410) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10652](biomejs/biome#10652). Biome plugins are now properly filtered when using `--only` and `--skip` flags. - [#​10669](biomejs/biome#10669) [`aa0a6eb`](biomejs/biome@aa0a6eb) Thanks [@​Netail](https://github.com/Netail)! - Fixed [#​10651](biomejs/biome#10651): [useInlineScriptId](https://biomejs.dev/linter/rules/use-inline-script-id/) now correctly trims trivia to detect if an id attribute has been set. - [#​10689](biomejs/biome#10689) [`844b1be`](biomejs/biome@844b1be) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10658](biomejs/biome#10658). The issue was caused by the "Go-to definition" editor feature, which was enabled by default. The feature is now **disabled by default**. To work, the feature triggers the scanner to build the module graph. This caused memory leak issues in cases where Biome starts in the home directory to modify files. If you relied on this new feature, you must now turn on using the \[editor settings] of the extension e.g. [Zed](https://biomejs.dev/reference/zed/#goto_definition) and [VSCode](https://biomejs.dev/reference/vscode/#biomegotodefinition). - [#​10695](biomejs/biome#10695) [`043fbb5`](biomejs/biome@043fbb5) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10674](biomejs/biome#10674). Biome now throws an error when the field `level` is missing from a rule option. - [#​10712](biomejs/biome#10712) [`5941df2`](biomejs/biome@5941df2) Thanks [@​Conaclos](https://github.com/Conaclos)! - Improved the diagnostic and the documentation of [`useFlatMap`](https://biomejs.dev/linter/rules/use-flat-map/). - [#​10615](biomejs/biome#10615) [`23814f1`](biomejs/biome@23814f1) Thanks [@​qwertycxz](https://github.com/qwertycxz)! - Improved the DX the JSON schema when it's used by certain code editors like VSCode. - [#​10688](biomejs/biome#10688) [`ec69489`](biomejs/biome@ec69489) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed a bug where the Biome Daemon did not correctly shut down when the editor was closed during an in-progress operation, especially while scanning. - [#​10701](biomejs/biome#10701) [`6c2e0d7`](biomejs/biome@6c2e0d7) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10694](biomejs/biome#10694). The Biome Language Server no longer prints an error when the user hovers a variable imported from node\_modules. - [#​10681](biomejs/biome#10681) [`888515b`](biomejs/biome@888515b) Thanks [@​Conaclos](https://github.com/Conaclos)! - Fixed [`useExportType`](https://biomejs.dev/linter/rules/use-export-type/) that reported useless details in some diagnostics. - [#​10220](biomejs/biome#10220) [`3694a13`](biomejs/biome@3694a13) Thanks [@​theBGuy](https://github.com/theBGuy)! - Fixed [`useAnchorContent`](https://biomejs.dev/linter/rules/use-anchor-content/) false positive for `<a>` elements used as render prop values (e.g. `render={<a href="..." />}`), a pattern where the receiving component renders its children inside the anchor element. - [#​10702](biomejs/biome#10702) [`98823fb`](biomejs/biome@98823fb) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10612](biomejs/biome#10612). The Biome parser now correctly parses processing instructions. The following SVG doesn't throw errors anymore: ```svg <?xml version="1.0" encoding="UTF-8" ?> <svg></svg> ``` </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMzQuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIzNC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://git.oirnoir.dev/OIRNOIR/YouTube-Helper-Server/pulls/21
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@biomejs/biome](https://biomejs.dev) ([source](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome)) | imports | patch | [`2.5.0` -> `2.5.1`](https://renovatebot.com/diffs/npm/@biomejs%2fbiome/2.5.0/2.5.1) | --- ### Release Notes <details> <summary>biomejs/biome (@​biomejs/biome)</summary> ### [`v2.5.1`](https://github.com/biomejs/biome/blob/HEAD/packages/@​biomejs/biome/CHANGELOG.md#251) [Compare Source](https://github.com/biomejs/biome/compare/@biomejs/biome@2.5.0...@biomejs/biome@2.5.1) ##### Patch Changes - [#​10722](biomejs/biome#10722) [`f8a303d`](biomejs/biome@f8a303d) Thanks [@​denbezrukov](https://github.com/denbezrukov)! - Fixed CSS formatter output for comments between import media queries. ```diff -@​import url("print.css") print, -/* comment */ -screen; +@​import url("print.css") print, /* comment */ screen; ``` - [#​10738](biomejs/biome#10738) [`9fdc560`](biomejs/biome@9fdc560) Thanks [@​JamBalaya56562](https://github.com/JamBalaya56562)! - Fixed [#​9899](biomejs/biome#9899): the `json` and `json-pretty` reporters now escape backslashes in a diagnostic's `location.path`. Previously, paths containing backslashes (such as Windows-style paths) were emitted unescaped, producing invalid JSON. ```diff - "path": "src\account\setup-passkey.tsx", + "path": "src\\account\\setup-passkey.tsx", ``` - [#​10626](biomejs/biome#10626) [`5f837df`](biomejs/biome@5f837df) Thanks [@​tom-groves](https://github.com/tom-groves)! - Fixed [#​10625](biomejs/biome#10625): `biome migrate` no longer emits an invalid trailing comma when a renamed rule (such as `noConsoleLog` → `noConsole`) is the last member of its rule group. Previously this produced malformed output that aborted the migration of a strict-JSON `biome.json` with a parsing error. - [#​10535](biomejs/biome#10535) [`c245f9d`](biomejs/biome@c245f9d) Thanks [@​Mokto](https://github.com/Mokto)! - Fixed a false positive in [`noUnusedVariables`](https://biomejs.dev/linter/rules/no-unused-variables/) for Svelte files where variables referenced inside `{@​html expr}` blocks were incorrectly reported as unused. - [#​10668](biomejs/biome#10668) [`a0f197e`](biomejs/biome@a0f197e) Thanks [@​Netail](https://github.com/Netail)! - The `biome init` command has been updated to include a more up-to-date URL to [the first-party extensions page](https://biomejs.dev/editors/first-party-extensions/). - [#​10667](biomejs/biome#10667) [`d8c3e87`](biomejs/biome@d8c3e87) Thanks [@​Netail](https://github.com/Netail)! - Fixed [#​10664](biomejs/biome#10664): [useErrorCause](https://biomejs.dev/linter/rules/use-error-cause/) now correctly detects a shorthand property. - [#​10696](biomejs/biome#10696) [`ef2373f`](biomejs/biome@ef2373f) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​9566](biomejs/biome#9566). Improved how the Biome Language Server loads multiple configuration files inside a workspace. - [#​10705](biomejs/biome#10705) [`4ccb410`](biomejs/biome@4ccb410) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10652](biomejs/biome#10652). Biome plugins are now properly filtered when using `--only` and `--skip` flags. - [#​10669](biomejs/biome#10669) [`aa0a6eb`](biomejs/biome@aa0a6eb) Thanks [@​Netail](https://github.com/Netail)! - Fixed [#​10651](biomejs/biome#10651): [useInlineScriptId](https://biomejs.dev/linter/rules/use-inline-script-id/) now correctly trims trivia to detect if an id attribute has been set. - [#​10689](biomejs/biome#10689) [`844b1be`](biomejs/biome@844b1be) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10658](biomejs/biome#10658). The issue was caused by the "Go-to definition" editor feature, which was enabled by default. The feature is now **disabled by default**. To work, the feature triggers the scanner to build the module graph. This caused memory leak issues in cases where Biome starts in the home directory to modify files. If you relied on this new feature, you must now turn on using the \[editor settings] of the extension e.g. [Zed](https://biomejs.dev/reference/zed/#goto_definition) and [VSCode](https://biomejs.dev/reference/vscode/#biomegotodefinition). - [#​10695](biomejs/biome#10695) [`043fbb5`](biomejs/biome@043fbb5) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10674](biomejs/biome#10674). Biome now throws an error when the field `level` is missing from a rule option. - [#​10712](biomejs/biome#10712) [`5941df2`](biomejs/biome@5941df2) Thanks [@​Conaclos](https://github.com/Conaclos)! - Improved the diagnostic and the documentation of [`useFlatMap`](https://biomejs.dev/linter/rules/use-flat-map/). - [#​10615](biomejs/biome#10615) [`23814f1`](biomejs/biome@23814f1) Thanks [@​qwertycxz](https://github.com/qwertycxz)! - Improved the DX the JSON schema when it's used by certain code editors like VSCode. - [#​10688](biomejs/biome#10688) [`ec69489`](biomejs/biome@ec69489) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed a bug where the Biome Daemon did not correctly shut down when the editor was closed during an in-progress operation, especially while scanning. - [#​10701](biomejs/biome#10701) [`6c2e0d7`](biomejs/biome@6c2e0d7) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10694](biomejs/biome#10694). The Biome Language Server no longer prints an error when the user hovers a variable imported from node\_modules. - [#​10681](biomejs/biome#10681) [`888515b`](biomejs/biome@888515b) Thanks [@​Conaclos](https://github.com/Conaclos)! - Fixed [`useExportType`](https://biomejs.dev/linter/rules/use-export-type/) that reported useless details in some diagnostics. - [#​10220](biomejs/biome#10220) [`3694a13`](biomejs/biome@3694a13) Thanks [@​theBGuy](https://github.com/theBGuy)! - Fixed [`useAnchorContent`](https://biomejs.dev/linter/rules/use-anchor-content/) false positive for `<a>` elements used as render prop values (e.g. `render={<a href="..." />}`), a pattern where the receiving component renders its children inside the anchor element. - [#​10702](biomejs/biome#10702) [`98823fb`](biomejs/biome@98823fb) Thanks [@​ematipico](https://github.com/ematipico)! - Fixed [#​10612](biomejs/biome#10612). The Biome parser now correctly parses processing instructions. The following SVG doesn't throw errors anymore: ```svg <?xml version="1.0" encoding="UTF-8" ?> <svg></svg> ``` </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMzQuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIzNC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://git.oirnoir.dev/OIRNOIR/YouTube-Helper-Client/pulls/8
Summary
{@html expr}is a Svelte template tag that renders raw HTML. The expression inside it references script variables, butparse_embedded_nodes.rshad an empty arm forSvelteHtmlBlock:This meant the identifier inside
{@html html}was never registered as a template reference, causingnoUnusedVariablesto falsely flag the variable as unused:Fix: parse the expression inside
SvelteHtmlBlockusingbuild_svelte_text_expression_candidateand push it as an embedded snippet, the same waySvelteIfBlock,SvelteKeyBlock, andSvelteRenderBlockhandle their expressions.Test Plan
New fixture
valid-svelte-at-html.svelteadded tonoUnusedVariablestest specs. All existing tests pass.Docs
N/A