Skip to content

fix(html): fmt svelte children#8539

Merged
ematipico merged 1 commit intomainfrom
fix/fmt-svelte-children
Dec 21, 2025
Merged

fix(html): fmt svelte children#8539
ematipico merged 1 commit intomainfrom
fix/fmt-svelte-children

Conversation

@ematipico
Copy link
Member

Summary

Closes #8515

Test Plan

Added a test

Docs

@changeset-bot
Copy link

changeset-bot bot commented Dec 21, 2025

⚠️ No Changeset found

Latest commit: ca1cc99

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ematipico ematipico requested a review from dyc3 December 21, 2025 21:47
@github-actions github-actions bot added A-Formatter Area: formatter L-HTML Language: HTML and super languages labels Dec 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 21, 2025

Walkthrough

This PR updates the HTML formatter's element list configuration approach. The public API method with_group_id() on FormatHtmlElementList is replaced with with_multiline(), changing how child element layout is configured from group-ID assignment to explicit multiline formatting. This change is applied across multiple Svelte auxiliary formatters (await, else, if, key, and snippet blocks), with associated comments about formatting order removed. Tests are updated to validate Svelte snippet syntax handling.

Possibly related PRs

  • PR #8509: Introduced the with_group_id() usage patterns across Svelte auxiliary formatters that this PR directly replaces with with_multiline() calls.

Suggested labels

A-Formatter, L-HTML

Suggested reviewers

  • dyc3

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(html): fmt svelte children' directly summarises the main change: fixing HTML formatting for Svelte children nodes.
Description check ✅ Passed The description links to issue #8515 and mentions adding a test, which are directly related to the changeset fixing Svelte children formatting.
Linked Issues check ✅ Passed The PR successfully addresses issue #8515 by replacing group-id-based formatting with multiline formatting across all Svelte auxiliary block files, preventing the panic when encountering {#snippet} syntax with expressions as first children.
Out of Scope Changes check ✅ Passed All changes are focused on Svelte child formatting: public API change to FormatHtmlElementList and updates to eight Svelte block handlers plus a test, all directly addressing the linked issue.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/fmt-svelte-children

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c422e5 and ca1cc99.

⛔ Files ignored due to path filters (1)
  • crates/biome_html_formatter/tests/specs/html/svelte/issue_8515.svelte.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (11)
  • crates/biome_html_formatter/src/html/lists/element_list.rs (1 hunks)
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs (1 hunks)
  • crates/biome_html_formatter/src/svelte/auxiliary/await_opening_block.rs (1 hunks)
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs (1 hunks)
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs (1 hunks)
  • crates/biome_html_formatter/src/svelte/auxiliary/else_if_clause.rs (1 hunks)
  • crates/biome_html_formatter/src/svelte/auxiliary/if_opening_block.rs (1 hunks)
  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs (1 hunks)
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs (1 hunks)
  • crates/biome_html_formatter/tests/quick_test.rs (1 hunks)
  • crates/biome_html_formatter/tests/specs/html/svelte/issue_8515.svelte (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use inline rustdoc documentation for rules, assists, and their options
Use the dbg!() macro for debugging output in Rust tests and code
Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests

Files:

  • crates/biome_html_formatter/src/html/lists/element_list.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/if_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/tests/quick_test.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_if_clause.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
🧠 Learnings (28)
📓 Common learnings
Learnt from: dyc3
Repo: biomejs/biome PR: 8291
File: crates/biome_html_formatter/tests/specs/prettier/vue/html-vue/elastic-header.html:10-10
Timestamp: 2025-12-04T13:29:49.287Z
Learning: Files under `crates/biome_html_formatter/tests/specs/prettier` are test fixtures synced from Prettier and should not receive detailed code quality reviews (e.g., HTTP vs HTTPS, formatting suggestions, etc.). These files are test data meant to validate formatter behavior and should be preserved as-is.
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.782Z
Learning: For formatter changes in changesets, show formatting changes using diff code blocks
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Define `FormatHtmlSyntaxNode` struct in a `cst.rs` file implementing `FormatRule<HtmlSyntaxNode>`, `AsFormat<HtmlFormatContext>`, and `IntoFormat<HtmlFormatContext>` traits using the provided boilerplate code

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/if_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/tests/quick_test.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_if_clause.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Implement the `FormatNodeRule<N>` trait with `fmt_fields` as the only required method; default implementations of `fmt`, `is_suppressed`, `fmt_leading_comments`, `fmt_dangling_comments`, and `fmt_trailing_comments` are provided

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/if_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_if_clause.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/context.rs : Define `<Language>FormatContext` struct in a `context.rs` file containing `comments` and `source_map` fields, implementing `FormatContext` and `CstFormatContext` traits

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/tests/quick_test.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `full_options` code block property for complete biome.json configuration snippets in documentation

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `options` code block property for rule-specific configuration snippets in documentation

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Prefix line with `#` in documentation code examples sparingly; prefer concise complete snippets

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/tests/quick_test.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Rule documentation code blocks should be ordered as language, expect_diagnostic, options/full_options/use_options, ignore, file

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/tests/quick_test.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Wrap rule options fields in `Option<>` to properly track set and unset options during merge

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Rule documentation code blocks must have a language defined for syntax highlighting

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
📚 Learning: 2025-12-21T21:15:03.782Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.782Z
Learning: For formatter changes in changesets, show formatting changes using diff code blocks

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/lib.rs : Expose a public `format_node` function that accepts formatting options and a root syntax node, returning a `FormatResult<Formatted<Context>>` with appropriate documentation

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/tests/quick_test.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Lines prefixed with `#` in rule documentation code examples will be hidden from output

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to 'fix' the code; if a token/node is known to be mandatory but is missing, return `None` instead

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/language.rs : Implement `TestFormatLanguage` trait in `tests/language.rs` for the formatter's test language

Applied to files:

  • crates/biome_html_formatter/tests/quick_test.rs
📚 Learning: 2025-12-04T13:29:49.287Z
Learnt from: dyc3
Repo: biomejs/biome PR: 8291
File: crates/biome_html_formatter/tests/specs/prettier/vue/html-vue/elastic-header.html:10-10
Timestamp: 2025-12-04T13:29:49.287Z
Learning: Files under `crates/biome_html_formatter/tests/specs/prettier` are test fixtures synced from Prettier and should not receive detailed code quality reviews (e.g., HTTP vs HTTPS, formatting suggestions, etc.). These files are test data meant to validate formatter behavior and should be preserved as-is.

Applied to files:

  • crates/biome_html_formatter/tests/quick_test.rs
  • crates/biome_html_formatter/tests/specs/html/svelte/issue_8515.svelte
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/spec_tests.rs : Use the `tests_macros::gen_tests!` macro in `spec_tests.rs` to generate test functions for each specification file matching the pattern `tests/specs/<language>/**/*.<ext>`

Applied to files:

  • crates/biome_html_formatter/tests/quick_test.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/Cargo.toml : Include development dependencies in `Cargo.toml` for formatter tests: `biome_formatter_test`, `biome_<language>_factory`, `biome_<language>_parser`, `biome_parser`, `biome_service`, `countme`, `iai`, `quickcheck`, `quickcheck_macros`, and `tests_macros`

Applied to files:

  • crates/biome_html_formatter/tests/quick_test.rs
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Implement watcher tests for workspace methods in watcher.tests.rs and end-to-end tests in LSP tests

Applied to files:

  • crates/biome_html_formatter/tests/quick_test.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced

Applied to files:

  • crates/biome_html_formatter/tests/quick_test.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Assist rules should detect refactoring opportunities and emit code action signals

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Set `version` field to `next` in `declare_lint_rule!` macro

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `let else` trick when `run` function returns `Vec` to reduce code branching

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/else_if_clause.rs
  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/comments.rs : Define `<Language>CommentStyle` as a public type alias for `Comments<<Language>Language>` in a `comments.rs` file

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : For tokens that are not mandatory, use helper functions instead of hardcoding

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : The first paragraph of rule documentation must be a single line describing what the rule does

Applied to files:

  • crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs
🧬 Code graph analysis (1)
crates/biome_html_formatter/tests/quick_test.rs (1)
crates/biome_html_syntax/src/file_source.rs (1)
  • svelte (96-100)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: End-to-end tests
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Documentation
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
🔇 Additional comments (11)
crates/biome_html_formatter/tests/specs/html/svelte/issue_8515.svelte (1)

1-3: LGTM! Test fixture appropriately covers the reported issue.

This minimal Svelte 5 snippet syntax test case validates the fix for issue #8515.

crates/biome_html_formatter/src/svelte/auxiliary/await_opening_block.rs (1)

44-46: LGTM! Formatting configuration updated consistently.

The switch from group-based to explicit multiline formatting aligns with the broader refactoring across all Svelte auxiliary blocks.

crates/biome_html_formatter/tests/quick_test.rs (1)

23-30: LGTM! Test input updated to Svelte snippet syntax.

Appropriately covers the Svelte 5 snippet formatting scenario.

crates/biome_html_formatter/src/svelte/auxiliary/if_opening_block.rs (1)

29-31: LGTM! Consistent formatting change.

Aligns with the multiline formatting refactoring across Svelte auxiliary blocks.

crates/biome_html_formatter/src/svelte/auxiliary/snippet_opening_block.rs (1)

33-35: LGTM! Core fix for snippet formatting.

This change directly addresses the reported panic with Svelte 5 {#snippet} syntax.

crates/biome_html_formatter/src/svelte/auxiliary/key_block.rs (1)

17-19: LGTM! Consistent with the refactoring pattern.

crates/biome_html_formatter/src/html/lists/element_list.rs (1)

35-38: LGTM! Cleaner API for multiline formatting.

The new with_multiline() method provides a more direct way to configure multiline layout compared to the previous group-based approach.

crates/biome_html_formatter/src/svelte/auxiliary/else_if_clause.rs (1)

32-34: LGTM! Completes the consistent refactoring.

All Svelte auxiliary blocks now use the unified multiline formatting approach.

crates/biome_html_formatter/src/svelte/auxiliary/else_clause.rs (1)

25-26: Consistent formatter API update.

The change mirrors the pattern across other Svelte auxiliary formatters and should contribute to fixing the {#snippet} syntax issue.

crates/biome_html_formatter/src/svelte/auxiliary/await_then_block.rs (1)

28-29: All Svelte auxiliary formatters successfully migrated to with_multiline().

Verified that no remaining usages of with_group_id() exist in the Svelte formatters. The change at lines 28-29 is correct and completes the migration.

crates/biome_html_formatter/src/svelte/auxiliary/await_catch_block.rs (1)

29-30: The with_multiline() API is available and correctly used.

The change from group-ID-based to multiline formatting is sound.

let source_type = HtmlFileSource::html();
let source_type = HtmlFileSource::svelte();
let tree = parse_html(src, HtmlParseOptions::from(&source_type));
let options = HtmlFormatOptions::new(HtmlFileSource::html())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inconsistent source type in formatting options.

Line 31 correctly uses HtmlFileSource::svelte() for parsing, but Line 33 uses HtmlFileSource::html() for format options. These should match to ensure consistent formatting behaviour.

🔎 Proposed fix
-    let options = HtmlFormatOptions::new(HtmlFileSource::html())
+    let options = HtmlFormatOptions::new(source_type)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let options = HtmlFormatOptions::new(HtmlFileSource::html())
let source_type = HtmlFileSource::svelte()
let parsed = parse_html(input, source_type)
let options = HtmlFormatOptions::new(source_type)
🤖 Prompt for AI Agents
In crates/biome_html_formatter/tests/quick_test.rs around lines 31 to 33, the
HtmlFormatOptions is created with HtmlFileSource::html() while the parser uses
HtmlFileSource::svelte(); change the format options to use
HtmlFileSource::svelte() so the source type matches the parser (i.e., replace
HtmlFileSource::html() with HtmlFileSource::svelte()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter L-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 HTML formatter trips up on {#snippet} Svelte 5 syntax

2 participants