fix(embeds): track attributes text expressions#9526
Conversation
🦋 Changeset detectedLatest commit: cea0b22 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 |
32beab6 to
bda1ac8
Compare
WalkthroughThis PR fixes tracking of attribute expressions with text values in Svelte files. The changes extend the HTML file handler to parse and embed text-expression initializers in HTML attributes (e.g., 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)
📝 Coding Plan
Comment Tip CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.OpenGrep is compatible with Semgrep configurations. Add an |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/biome_test_utils/src/lib.rs (1)
901-912:⚠️ Potential issue | 🟠 MajorThis de-scopes module-graph coverage for all HTML-ish tests.
analyze_with_workspace()still mirrors sibling sources into the in-memory FS for module-graph rules, butModuleGraphResolutionKind::Nonemeans that context is never resolved here. Together withScanKind::NoScanner, this helper no longer exercises the same project context as the non-workspace path. I’d only disable these knobs when the selected rule does not need the graph, mirroringNeedsModuleGraphincrates/biome_js_analyze/tests/spec_tests.rs.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_test_utils/src/lib.rs` around lines 901 - 912, The test helper analyze_with_workspace currently forces ModuleGraphResolutionKind::None and ScanKind::NoScanner which disables module-graph resolution for all HTML-ish tests; change it to only disable those when the selected rule does not require a module graph (mirror the NeedsModuleGraph check used in crates/biome_js_analyze/tests/spec_tests.rs). In practice, update analyze_with_workspace() to inspect the rule metadata (or accept a flag) and set module_graph_resolution_kind to the normal resolution mode and scan_kind to the real scanner unless the rule indicates it does not need the module graph (i.e., when NeedsModuleGraph is false), otherwise keep ModuleGraphResolutionKind::None and ScanKind::NoScanner.
🧹 Nitpick comments (1)
crates/biome_js_analyze/tests/specs/style/useImportType/valid-issue-9358.svelte (1)
1-7: Nice regression; please add the event-handler twin too.This covers
class={...}, but the PR also closes the unused-handler case. A sibling fixture with<svelte:window onscroll={handleScroll} />would keep#9375from sneaking back in.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_js_analyze/tests/specs/style/useImportType/valid-issue-9358.svelte` around lines 1 - 7, Add a sibling test fixture that mirrors the existing class-binding case but for event handlers to cover the unused-handler regression: create a new .svelte test file next to valid-issue-9358.svelte that defines a handleScroll function (e.g. function handleScroll() {}) and uses it in a top-level window handler like <svelte:window onscroll={handleScroll} /> (and include any minimal markup/ts script similar to the original fixture), ensuring the file name indicates it’s the event-handler twin so the test runner picks it up.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/poor-spies-switch.md:
- Line 5: Update the changeset .changeset/poor-spies-switch.md to use the repo
changeset format and a user-facing lead: replace the implementation-style
sentence with a bug-fix entry that starts "Fixed
[`#9358`](https://github.com/biomejs/biome/issues/9358) and
[`#9375`](https://github.com/biomejs/biome/issues/9375): ..." and then a concise
user-visible description such as "Svelte template references (e.g.,
class={buttonClass()}) are no longer misclassified as type-only or unused, so
attributes with text expressions are tracked correctly in Svelte files." Ensure
the file follows the project’s changeset/body formatting (leading Fixed
[`#NUMBER`]: ... line and a short explanatory sentence).
In `@crates/biome_js_analyze/tests/spec_tests.rs`:
- Line 96: Remove the stray debug print statement dbg!("Running HTML-ish test
{input_file:?}"); from the HTML-ish spec test so it no longer writes to stderr
during every test run; locate the invocation in the spec_tests.rs test function
and either delete the dbg! call or replace it with a non-verbose logger call
(e.g., a trace/debug via the test harness logger) if you need retained
diagnostics.
In
`@crates/biome_service/src/workspace/document/services/embedded_value_references.rs`:
- Line 56: Remove the stray dbg!(&self.references) call that prints every
reference to stderr; locate the occurrence of dbg!(&self.references) in
embedded_value_references.rs (inside the implementation that owns
self.references) and delete it or replace it with a non-allocating logging call
such as debug!(target: "embedded_value_references", "references = {:?}",
self.references) or trace!(...) if you need the information only for debugging,
ensuring you import and use the project's logging/tracing facade instead of
dbg!.
---
Outside diff comments:
In `@crates/biome_test_utils/src/lib.rs`:
- Around line 901-912: The test helper analyze_with_workspace currently forces
ModuleGraphResolutionKind::None and ScanKind::NoScanner which disables
module-graph resolution for all HTML-ish tests; change it to only disable those
when the selected rule does not require a module graph (mirror the
NeedsModuleGraph check used in crates/biome_js_analyze/tests/spec_tests.rs). In
practice, update analyze_with_workspace() to inspect the rule metadata (or
accept a flag) and set module_graph_resolution_kind to the normal resolution
mode and scan_kind to the real scanner unless the rule indicates it does not
need the module graph (i.e., when NeedsModuleGraph is false), otherwise keep
ModuleGraphResolutionKind::None and ScanKind::NoScanner.
---
Nitpick comments:
In
`@crates/biome_js_analyze/tests/specs/style/useImportType/valid-issue-9358.svelte`:
- Around line 1-7: Add a sibling test fixture that mirrors the existing
class-binding case but for event handlers to cover the unused-handler
regression: create a new .svelte test file next to valid-issue-9358.svelte that
defines a handleScroll function (e.g. function handleScroll() {}) and uses it in
a top-level window handler like <svelte:window onscroll={handleScroll} /> (and
include any minimal markup/ts script similar to the original fixture), ensuring
the file name indicates it’s the event-handler twin so the test runner picks it
up.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0b14ccbf-8f97-4066-83b3-62e1565577a0
⛔ Files ignored due to path filters (1)
crates/biome_js_analyze/tests/specs/style/useImportType/valid-issue-9358.svelte.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (6)
.changeset/poor-spies-switch.mdcrates/biome_js_analyze/tests/spec_tests.rscrates/biome_js_analyze/tests/specs/style/useImportType/valid-issue-9358.sveltecrates/biome_service/src/file_handlers/html.rscrates/biome_service/src/workspace/document/services/embedded_value_references.rscrates/biome_test_utils/src/lib.rs
crates/biome_service/src/workspace/document/services/embedded_value_references.rs
Outdated
Show resolved
Hide resolved
Merging this PR will not alter performance
Comparing Footnotes
|
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
They are a tangent. When testing a file, the infrastructure scans all files. It could cause side effects
Summary
Closes #9358
Closes #9375
I used AI to detect the issue.
Test Plan
Added a test
Docs