-
-
Notifications
You must be signed in to change notification settings - Fork 791
fix(format/html): add space before />
#8557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: a9e1a65 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 |
WalkthroughThis patch adds a release note for Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (7)
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧠 Learnings (4)📓 Common learnings📚 Learning: 2025-12-04T13:29:49.287ZApplied to files:
📚 Learning: 2025-12-21T21:15:03.782ZApplied to files:
📚 Learning: 2025-12-21T21:15:03.782ZApplied to files:
🪛 LanguageTool.changeset/rotten-pans-ring.md[style] ~4-~4: Consider using a different verb for a more formal wording. (FIX_RESOLVE) [misspelling] ~5-~5: This word is normally spelled with a hyphen. (EN_COMPOUNDS_SELF_CLOSING) ⏰ 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)
🔇 Additional comments (1)
Comment |
There was a problem hiding this 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
🧹 Nitpick comments (2)
.changeset/rotten-pans-ring.md (1)
1-5: Consider adding a formatting example.Per coding guidelines, showing the before/after formatting behaviour with a diff block would clarify the fix for users.
Based on learnings, formatter changes in changesets benefit from formatting examples.
💡 Example addition
--- "@biomejs/biome": patch --- Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self-closing elements. This brings the HTML formatter more in line with Prettier. + +Before: +```html +<Button label="test"/> +``` + +After: +```html +<Button label="test" /> +```crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs (1)
70-73: Consider simplifying the pattern match.Since you're not using the inner value (indicated by
_),slash_token.is_some()might be clearer thanif let Some(_).💡 Alternative approach
- } else { - if let Some(_) = &slash_token { - // only add a space before the slash if it exists. - write!(f, [space()])?; - } - write!(f, [slash_token.format()])?; - } + } else { + if slash_token.is_some() { + // only add a space before the slash if it exists. + write!(f, [space()])?; + } + write!(f, [slash_token.format()])?; + }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (7)
crates/biome_html_formatter/tests/specs/html/component-frameworks/astro-component-casing.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_formatter/tests/specs/html/component-frameworks/large-self-closing.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_formatter/tests/specs/html/component-frameworks/svelte-component-casing.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_formatter/tests/specs/html/component-frameworks/vue-component-casing.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_formatter/tests/specs/html/svelte/await_dynamic_import.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_formatter/tests/specs/html/vue/event-with-colon.vue.snapis excluded by!**/*.snapand included by**crates/biome_html_formatter/tests/specs/html/vue/issue-8174.vue.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (3)
.changeset/rotten-pans-ring.mdcrates/biome_html_formatter/src/html/auxiliary/self_closing_element.rscrates/biome_html_formatter/tests/specs/html/component-frameworks/large-self-closing.svelte
🧰 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 thedbg!()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/auxiliary/self_closing_element.rs
🧠 Learnings (13)
📓 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-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/specs/html/component-frameworks/large-self-closing.svelte.changeset/rotten-pans-ring.md
📚 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:
.changeset/rotten-pans-ring.md
📚 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/html/auxiliary/self_closing_element.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/html/auxiliary/self_closing_element.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/html/auxiliary/self_closing_element.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/html/auxiliary/self_closing_element.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `p.eat(token)` for optional tokens, `p.expect(token)` for required tokens, `parse_rule(p).ok(p)` for optional nodes, and `parse_rule(p).or_add_diagnostic(p, error)` for required nodes
Applied to files:
crates/biome_html_formatter/src/html/auxiliary/self_closing_element.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/html/auxiliary/self_closing_element.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 : Avoid string allocations by comparing against `&str` or using `TokenText`
Applied to files:
crates/biome_html_formatter/src/html/auxiliary/self_closing_element.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/html/auxiliary/self_closing_element.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `ConditionalParsedSyntax` for syntax that is only valid in specific contexts (e.g., strict mode, file types, language versions) and call `or_invalid_to_bogus()` to convert to a bogus node if not supported
Applied to files:
crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Implement a token source struct that wraps the lexer and implements `TokenSourceWithBufferedLexer` and `LexerWithCheckpoint` for lookahead and re-lexing capabilities
Applied to files:
crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs
🧬 Code graph analysis (1)
crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs (1)
crates/biome_formatter/src/builders.rs (3)
if_group_fits_on_line(2024-2033)space(606-608)token(251-259)
🪛 LanguageTool
.changeset/rotten-pans-ring.md
[style] ~4-~4: Consider using a different verb for a more formal wording.
Context: --- "@biomejs/biome": patch --- Fixed an issue with the HTML formatter where ...
(FIX_RESOLVE)
[misspelling] ~5-~5: This word is normally spelled with a hyphen.
Context: ...wouldn't add a space before the /> in self closing elements. This brings the HTML formatte...
(EN_COMPOUNDS_SELF_CLOSING)
⏰ 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). (8)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Documentation
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: End-to-end tests
- GitHub Check: Check Dependencies
- GitHub Check: Test Node.js API
- GitHub Check: autofix
🔇 Additional comments (2)
crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs (1)
59-59: Conditional spacing logic looks correct.The use of
if_group_fits_on_line(&space())appropriately adds space before the slash only when the group fits on a single line, maintaining alignment with Prettier's behaviour.Also applies to: 61-61
crates/biome_html_formatter/tests/specs/html/component-frameworks/large-self-closing.svelte (1)
1-6: Test fixture looks appropriate.The test case appropriately covers a large self-closing component to validate the spacing fix.
| "@biomejs/biome": patch | ||
| --- | ||
|
|
||
| Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self closing elements. This brings the HTML formatter more in line with Prettier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hyphenate "self-closing".
The term should be "self-closing" with a hyphen.
🔎 Proposed fix
-Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self closing elements. This brings the HTML formatter more in line with Prettier.
+Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self-closing elements. This brings the HTML formatter more in line with Prettier.📝 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.
| Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self closing elements. This brings the HTML formatter more in line with Prettier. | |
| Fixed an issue with the HTML formatter where it wouldn't add a space before the `/>` in self-closing elements. This brings the HTML formatter more in line with Prettier. |
🧰 Tools
🪛 LanguageTool
[misspelling] ~5-~5: This word is normally spelled with a hyphen.
Context: ...wouldn't add a space before the /> in self closing elements. This brings the HTML formatte...
(EN_COMPOUNDS_SELF_CLOSING)
🤖 Prompt for AI Agents
In .changeset/rotten-pans-ring.md around line 5, the phrase "self closing
elements" should be hyphenated; change it to "self-closing elements" so the
changelog uses the correct term and punctuation.
372dd60 to
7f92868
Compare
7f92868 to
a9e1a65
Compare
Summary
Fixes a minor formatting diff with prettier in the HTML formatter. Now, if a
/is going to be printed and the group doesn't break, a space will preceed it.Test Plan
snapshots
Docs