-
-
Couldn't load subscription status.
- Fork 732
feat(parse/html): parse svelte shorthand props and spread props #7872
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
Conversation
🦋 Changeset detectedLatest commit: a2c26a0 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 |
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
WalkthroughAdds support for Svelte shorthand attribute syntax (e.g. Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 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 (5)
📒 Files selected for processing (10)
🚧 Files skipped from review as they are similar to previous changes (5)
🧰 Additional context used📓 Path-based instructions (3)**/*.{rs,toml}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.rs📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
.changeset/*.md📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
🧠 Learnings (3)📚 Learning: 2025-10-15T09:22:15.851ZApplied to files:
📚 Learning: 2025-10-15T09:22:15.851ZApplied to files:
📚 Learning: 2025-10-15T09:22:15.851ZApplied to files:
🧬 Code graph analysis (2)crates/biome_html_parser/src/syntax/parse_error.rs (1)
crates/biome_html_formatter/src/html/lists/attribute_list.rs (2)
⏰ 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). (10)
🔇 Additional comments (5)
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: 0
🧹 Nitpick comments (1)
crates/biome_html_parser/src/syntax/mod.rs (1)
305-314: Pre-existing: Consider aligning double text expression handling.Lines 305-314 complete with
HTML_ATTRIBUTE, wrapping the double text expression. Per the grammar,HtmlDoubleTextExpressionshould be a directAnyHtmlAttributealternative (like the new single text expression handling). This is pre-existing and out of scope for this PR, but worth noting for future consistency.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
crates/biome_html_parser/tests/html_specs/error/interpolation-attributes.html.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/dynamic-prop.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-prop.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-spread-props.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_syntax/src/generated/kind.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_html_syntax/src/generated/nodes.rsis excluded by!**/generated/**,!**/generated/**and included by**
📒 Files selected for processing (10)
.changeset/odd-lizards-build.md(1 hunks)crates/biome_html_formatter/src/html/any/attribute.rs(1 hunks)crates/biome_html_formatter/src/html/lists/attribute_list.rs(1 hunks)crates/biome_html_parser/src/syntax/mod.rs(2 hunks)crates/biome_html_parser/tests/html_specs/error/interpolation-attributes.html(1 hunks)crates/biome_html_parser/tests/html_specs/ok/svelte/dynamic-prop.svelte(1 hunks)crates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-prop.svelte(1 hunks)crates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-spread-props.svelte(1 hunks)xtask/codegen/html.ungram(1 hunks)xtask/codegen/src/html_kinds_src.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_html_formatter/src/html/lists/attribute_list.rscrates/biome_html_parser/tests/html_specs/ok/svelte/dynamic-prop.sveltecrates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-prop.sveltecrates/biome_html_parser/tests/html_specs/error/interpolation-attributes.htmlcrates/biome_html_formatter/src/html/any/attribute.rscrates/biome_html_parser/src/syntax/mod.rscrates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-spread-props.svelte
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_html_formatter/src/html/lists/attribute_list.rscrates/biome_html_parser/tests/html_specs/ok/svelte/dynamic-prop.sveltecrates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-prop.sveltecrates/biome_html_parser/tests/html_specs/error/interpolation-attributes.htmlcrates/biome_html_formatter/src/html/any/attribute.rscrates/biome_html_parser/src/syntax/mod.rscrates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-spread-props.svelte
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Format Rust files before committing (e.g., viajust fwhich formats Rust)
Document rules, assists, and options with inline rustdoc in source
Files:
crates/biome_html_formatter/src/html/lists/attribute_list.rscrates/biome_html_formatter/src/html/any/attribute.rscrates/biome_html_parser/src/syntax/mod.rsxtask/codegen/src/html_kinds_src.rs
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_html_parser/tests/html_specs/ok/svelte/dynamic-prop.sveltecrates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-prop.sveltecrates/biome_html_parser/tests/html_specs/error/interpolation-attributes.htmlcrates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-spread-props.svelte
xtask/codegen/*.ungram
📄 CodeRabbit inference engine (CLAUDE.md)
Define and modify language grammars in .ungram files; ASTs are generated from these
Files:
xtask/codegen/html.ungram
.changeset/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/*.md: In changesets, only use #### or ##### headers; other header levels are not allowed
Changesets should cover user-facing changes only; internal changes do not need changesets
Use past tense for what you did and present tense for current Biome behavior in changesets
When fixing a bug in a changeset, start with an issue link (e.g., “Fixed #1234: …”)
When referencing a rule or assist in a changeset, include a link to its page on the website
Include code blocks in changesets when applicable to illustrate changes
End every sentence in a changeset with a period
Files:
.changeset/odd-lizards-build.md
🧠 Learnings (4)
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/cst.rs : Create FormatHtmlSyntaxNode in cst.rs implementing FormatRule<HtmlSyntaxNode> and AsFormat/IntoFormat for HtmlSyntaxNode using the provided plumbing
Applied to files:
crates/biome_html_formatter/src/html/any/attribute.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/lib.rs : Implement FormatLanguage for HtmlFormatLanguage with associated types: SyntaxLanguage=HtmlLanguage, Context=HtmlFormatContext, FormatRule=FormatHtmlSyntaxNode
Applied to files:
crates/biome_html_formatter/src/html/any/attribute.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/language.rs : Create tests/language.rs defining `HtmlTestFormatLanguage` and implement the TestFormatLanguage trait
Applied to files:
crates/biome_html_formatter/src/html/any/attribute.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import and use the `FormatNode` trait for AST nodes
Applied to files:
crates/biome_html_formatter/src/html/any/attribute.rs
🧬 Code graph analysis (2)
crates/biome_html_formatter/src/html/lists/attribute_list.rs (2)
crates/biome_html_formatter/src/generated.rs (16)
format(28-33)format(66-71)format(104-109)format(142-144)format(174-179)format(212-217)format(250-255)format(288-293)format(326-331)format(364-370)format(404-409)format(442-447)format(480-485)format(512-517)format(550-555)format(588-594)crates/biome_html_formatter/src/html/any/attribute.rs (1)
fmt(9-16)
crates/biome_html_parser/src/syntax/mod.rs (1)
crates/biome_html_parser/src/syntax/parse_error.rs (1)
disabled_interpolation(12-14)
⏰ 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: Documentation
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Check Dependencies
- GitHub Check: Test Node.js API
- GitHub Check: autofix
- GitHub Check: Parser conformance
🔇 Additional comments (11)
.changeset/odd-lizards-build.md (1)
1-5: LGTM!The changeset follows all the guidelines: starts with the issue link, uses present tense for current behaviour, and ends with a period.
crates/biome_html_formatter/src/html/lists/attribute_list.rs (1)
66-68: LGTM!The handling for
HtmlSingleTextExpressionmirrors the existingHtmlDoubleTextExpressionpattern consistently.crates/biome_html_formatter/src/html/any/attribute.rs (1)
14-14: LGTM!The new variant follows the established pattern for formatting HTML attributes.
crates/biome_html_parser/tests/html_specs/ok/svelte/dynamic-prop.svelte (1)
1-1: LGTM!Valid Svelte syntax for dynamic property binding.
crates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-spread-props.svelte (1)
1-1: LGTM!Valid Svelte syntax for spread props.
crates/biome_html_parser/tests/html_specs/ok/svelte/shorthand-prop.svelte (1)
1-1: LGTM!This fixture tests the exact Svelte shorthand syntax reported in issue #7861.
xtask/codegen/src/html_kinds_src.rs (1)
52-53: LGTM!The new node kinds follow the existing naming conventions and appropriately support the Svelte-specific syntax.
crates/biome_html_parser/tests/html_specs/error/interpolation-attributes.html (1)
1-1: No action required—the test is correctly positioned.This file is intentionally in the
error/directory because.htmlfiles should reject Svelte-specific syntax like{disabled}. The corresponding.snapfile contains expected parse diagnostics, confirming the error behaviour is deliberate. Svelte shorthand syntax is properly tested separately in theok/svelte/directory (e.g.,shorthand-prop.svelte), which confirms the parser distinguishes correctly between file types.xtask/codegen/html.ungram (1)
162-162: LGTM!Grammar correctly extended to support Svelte shorthand props as direct attributes.
crates/biome_html_parser/src/syntax/mod.rs (2)
315-321: Correct handling of shorthand props.The marker abandonment and direct return properly align with the grammar, where
HtmlSingleTextExpressionis a directAnyHtmlAttributealternative rather than being wrapped inHtmlAttribute.
334-334: Clean refactor with token_set!More idiomatic and efficient than multiple
at()checks, whilst correctly covering all attribute start tokens.
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.
It seems we aren't parsing the error part correctly, because we aren't emitting the exclusive syntax diagnostic.
Also, it seems we aren't parsing the spread props as expected (we have the nodes, not the logic). I'm fine either way
c5ca396 to
a9de064
Compare
35a6813 to
a2c26a0
Compare
Summary
The HTML parser now accepts single text expressions in attributes.
Example:
fixes #7861
Test Plan
added tests
Docs