-
-
Notifications
You must be signed in to change notification settings - Fork 760
fix(parse/css): add @slot tailwind at rule
#7918
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: 7da217f 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
|
CodSpeed Performance ReportMerging #7918 will not alter performanceComparing Summary
Footnotes
|
WalkthroughThis pull request adds parsing, formatting, and lexer support for the Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 (1)
crates/biome_css_formatter/src/generated.rs (1)
5753-5786: Add a tiny rustdoc blurb to the real rule (not here).Generated file is fine. Please add a brief rustdoc on
FormatTwSlotAtRuleintailwind/statements/slot_at_rule.rsdescribing that it formats Tailwind v4@slotand any spacing/semicolon policy. Keeps docs consistent with other rules. As per coding guidelines.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (8)
crates/biome_css_factory/src/generated/node_factory.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_factory/src/generated/syntax_factory.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_parser/tests/css_test_suite/error/tailwind/when-disabled/slot.css.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/tailwind/custom-variants/block-slot.css.snapis excluded by!**/*.snapand included by**crates/biome_css_syntax/src/generated/kind.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_syntax/src/generated/macros.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_syntax/src/generated/nodes.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_syntax/src/generated/nodes_mut.rsis excluded by!**/generated/**,!**/generated/**and included by**
📒 Files selected for processing (12)
.changeset/some-walls-decide.md(1 hunks)crates/biome_css_formatter/src/css/any/at_rule.rs(1 hunks)crates/biome_css_formatter/src/generated.rs(1 hunks)crates/biome_css_formatter/src/tailwind/statements/mod.rs(1 hunks)crates/biome_css_formatter/src/tailwind/statements/slot_at_rule.rs(1 hunks)crates/biome_css_parser/src/lexer/mod.rs(1 hunks)crates/biome_css_parser/src/syntax/at_rule/mod.rs(2 hunks)crates/biome_css_parser/src/syntax/at_rule/tailwind.rs(1 hunks)crates/biome_css_parser/tests/css_test_suite/error/tailwind/when-disabled/slot.css(1 hunks)crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs(1 hunks)xtask/codegen/css.ungram(2 hunks)xtask/codegen/src/css_kinds_src.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Format Rust and TOML files before committing (e.g., via
just f)
Files:
crates/biome_css_formatter/src/tailwind/statements/mod.rscrates/biome_css_formatter/src/css/any/at_rule.rscrates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rscrates/biome_css_parser/src/syntax/at_rule/tailwind.rscrates/biome_css_formatter/src/tailwind/statements/slot_at_rule.rscrates/biome_css_parser/src/lexer/mod.rsxtask/codegen/src/css_kinds_src.rscrates/biome_css_parser/src/syntax/at_rule/mod.rscrates/biome_css_formatter/src/generated.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and their options with inline rustdoc in the Rust source
Files:
crates/biome_css_formatter/src/tailwind/statements/mod.rscrates/biome_css_formatter/src/css/any/at_rule.rscrates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rscrates/biome_css_parser/src/syntax/at_rule/tailwind.rscrates/biome_css_formatter/src/tailwind/statements/slot_at_rule.rscrates/biome_css_parser/src/lexer/mod.rsxtask/codegen/src/css_kinds_src.rscrates/biome_css_parser/src/syntax/at_rule/mod.rscrates/biome_css_formatter/src/generated.rs
.changeset/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/*.md: In changeset files, only use #### or ##### headers
Changesets should describe user-facing changes; internal-only changes do not need changesets
Use past tense for what you did in the changeset description and present tense for current behavior
For bug fixes, start the changeset description with a link to the issue (e.g., Fixed #1234: ...)
When referencing a rule or assist in a changeset, include a link to the rule/assist page on the website
Include a code block in the changeset when applicable to illustrate the change
End every sentence in a changeset with a full stop (.)
Files:
.changeset/some-walls-decide.md
🧠 Learnings (5)
📚 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_css_formatter/src/tailwind/statements/slot_at_rule.rscrates/biome_css_formatter/src/generated.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_css_formatter/src/tailwind/statements/slot_at_rule.rscrates/biome_css_formatter/src/generated.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 : Implement the `Format` trait for your node type and use `JsFormatter` with `write!`/`format_args!` to define formatting
Applied to files:
crates/biome_css_formatter/src/tailwind/statements/slot_at_rule.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_css_formatter/src/tailwind/statements/slot_at_rule.rscrates/biome_css_formatter/src/generated.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 : Expose a documented public function `format_node(options: HtmlFormatOptions, root: &HtmlSyntaxNode) -> FormatResult<Formatted<HtmlFormatContext>>` delegating to `biome_formatter::format_node`
Applied to files:
crates/biome_css_formatter/src/tailwind/statements/slot_at_rule.rs
🧬 Code graph analysis (2)
crates/biome_css_formatter/src/tailwind/statements/slot_at_rule.rs (1)
crates/biome_css_syntax/src/generated/nodes.rs (16)
slot_token(7230-7232)semicolon_token(347-349)semicolon_token(1553-1555)semicolon_token(1684-1686)semicolon_token(2234-2236)semicolon_token(2788-2790)semicolon_token(3444-3446)semicolon_token(6489-6491)semicolon_token(6624-6626)semicolon_token(6912-6914)semicolon_token(6957-6959)semicolon_token(7051-7053)semicolon_token(7146-7148)semicolon_token(7192-7194)semicolon_token(7233-7235)semicolon_token(7281-7283)
crates/biome_css_parser/src/syntax/at_rule/mod.rs (2)
crates/biome_css_parser/src/syntax/at_rule/tailwind.rs (1)
parse_slot_at_rule(252-262)crates/biome_css_parser/src/syntax/parse_error.rs (1)
tailwind_disabled(236-241)
🔇 Additional comments (13)
crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs (1)
214-214: LGTM!The mapping for
TwSlotAtRuleis correctly placed and follows the established pattern for other Tailwind at-rules..changeset/some-walls-decide.md (1)
1-5: Changeset looks good!Follows all the coding guidelines: uses past tense, links to the issue, ends with a full stop, and clearly describes the user-facing fix.
crates/biome_css_formatter/src/css/any/at_rule.rs (1)
40-40: LGTM!The formatting delegation for
TwSlotAtRuleis correctly positioned and follows the established pattern.crates/biome_css_parser/tests/css_test_suite/error/tailwind/when-disabled/slot.css (1)
1-1: Test case looks appropriate.This negative test correctly validates error handling when
@slotis used withouttailwindDirectivesenabled.crates/biome_css_formatter/src/tailwind/statements/mod.rs (1)
8-8: LGTM!The module declaration is correctly placed alphabetically and follows the established pattern.
xtask/codegen/src/css_kinds_src.rs (2)
131-131: LGTM!The "slot" keyword is correctly placed within the Tailwind CSS 4.0 keywords section.
513-513: LGTM!The
TW_SLOT_AT_RULEnode is correctly positioned within the Tailwind CSS 4.0 nodes section.crates/biome_css_parser/src/syntax/at_rule/mod.rs (2)
50-51: LGTM!The import of
parse_slot_at_ruleis correctly placed alphabetically amongst the other Tailwind at-rule parsers.
165-169: LGTM!The
T![slot]case correctly follows the established pattern for Tailwind at-rules, with proper feature gating and error handling.crates/biome_css_parser/src/lexer/mod.rs (1)
942-942: LGTM!The keyword mapping for
slotis correctly placed within the Tailwind CSS 4.0 keywords section and follows the established pattern.xtask/codegen/css.ungram (1)
663-663: LGTM!The grammar definition for
@slotis clean and follows the established pattern for simple Tailwind at-rules. The placement in theAnyCssAtRuleunion is consistent, and the syntax definition correctly captures the directive structure.Also applies to: 1979-1983
crates/biome_css_parser/src/syntax/at_rule/tailwind.rs (1)
250-262: LGTM!The parser implementation mirrors the pattern used for other simple Tailwind at-rules (e.g.,
@reference). The logic is straightforward: token check, marker start, bump, require semicolon, and complete. Perfect for a directive with no parameters.crates/biome_css_formatter/src/tailwind/statements/slot_at_rule.rs (1)
1-16: LGTM!The formatter follows Biome's established patterns for formatting rules. The implementation extracts the two required tokens via
as_fields()and emits them in sequence—exactly what's needed for this simple directive.
| impl FormatRule<biome_css_syntax::TwSlotAtRule> | ||
| for crate::tailwind::statements::slot_at_rule::FormatTwSlotAtRule | ||
| { | ||
| type Context = CssFormatContext; | ||
| #[inline(always)] | ||
| fn fmt(&self, node: &biome_css_syntax::TwSlotAtRule, f: &mut CssFormatter) -> FormatResult<()> { | ||
| FormatNodeRule::<biome_css_syntax::TwSlotAtRule>::fmt(self, node, f) | ||
| } | ||
| } | ||
| impl AsFormat<CssFormatContext> for biome_css_syntax::TwSlotAtRule { | ||
| type Format<'a> = FormatRefWithRule< | ||
| 'a, | ||
| biome_css_syntax::TwSlotAtRule, | ||
| crate::tailwind::statements::slot_at_rule::FormatTwSlotAtRule, | ||
| >; | ||
| fn format(&self) -> Self::Format<'_> { | ||
| FormatRefWithRule::new( | ||
| self, | ||
| crate::tailwind::statements::slot_at_rule::FormatTwSlotAtRule::default(), | ||
| ) | ||
| } | ||
| } | ||
| impl IntoFormat<CssFormatContext> for biome_css_syntax::TwSlotAtRule { | ||
| type Format = FormatOwnedWithRule< | ||
| biome_css_syntax::TwSlotAtRule, | ||
| crate::tailwind::statements::slot_at_rule::FormatTwSlotAtRule, | ||
| >; | ||
| fn into_format(self) -> Self::Format { | ||
| FormatOwnedWithRule::new( | ||
| self, | ||
| crate::tailwind::statements::slot_at_rule::FormatTwSlotAtRule::default(), | ||
| ) | ||
| } | ||
| } |
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.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
Solid wiring for @slot — formatter glue matches the house style.
Impls for FormatRule, AsFormat, and IntoFormat mirror neighbouring Tailwind at‑rules. Ordering alongside TwReference/TwSource also looks tidy. Nice one.
Run a quick cross‑check to ensure the rule type exists and the module is exported:
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Formatter rule type present?
rg -nS "FormatTwSlotAtRule" crates -C2
# Syntax node present?
rg -nS "\bTwSlotAtRule\b" crates -C3
# Module wired in tailwind statements?
rg -nS "mod\s+slot_at_rule|pub\(crate\)\s+mod\s+slot_at_rule" crates/biome_css_formatter/src/tailwind/statements -C1Length of output: 23745
Verification passed—all three checks confirmed.
FormatTwSlotAtRule is properly defined, TwSlotAtRule syntax node exists throughout the crate, and the module is correctly exported at crates/biome_css_formatter/src/tailwind/statements/mod.rs. The generated.rs impls wire up cleanly alongside sibling Tailwind at-rules.
One remaining item per coding guidelines: add inline rustdoc to crates/biome_css_formatter/src/tailwind/statements/slot_at_rule.rs to document what FormatTwSlotAtRule does.
🤖 Prompt for AI Agents
crates/biome_css_formatter/src/generated.rs lines 5753-5786: add an inline
rustdoc comment in
crates/biome_css_formatter/src/tailwind/statements/slot_at_rule.rs for the
FormatTwSlotAtRule type explaining its purpose and behavior; specifically, place
a /// doc comment immediately above the FormatTwSlotAtRule definition that
concisely states that it formats TwSlotAtRule Tailwind at-rules into the crate's
CSS output, notes any important formatting behaviors or context types used
(CssFormatContext), and optionally gives a short usage example or reference to
the generated impls; keep the comment brief and idiomatic Rust doc style.
|
I ran the relevant tests locally and they pass. The CI failure looks unrelated to this PR. |
Summary
fixes #7913
Test Plan
added a new negative test, updated existing snapshots
Docs