fix(parse/css): parse tailwind @utility with slash in the name#9043
fix(parse/css): parse tailwind @utility with slash in the name#9043
@utility with slash in the name#9043Conversation
🦋 Changeset detectedLatest commit: b6f8a3d 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 |
Merging this PR will not alter performance
Comparing Footnotes
|
1bfb213 to
12f0722
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds support for Tailwind 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)
Comment |
|
@dyc3 should this PR be merged? |
|
Ah, yes. Slipped through. I'll fix the ci |
12f0722 to
51d7636
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/biome_css_parser/src/lexer/mod.rs`:
- Around line 1098-1108: The lexer branch currently gates handling of sequences
like `--*` on self.options.is_tailwind_directives_enabled(), which makes token
emission option-dependent; remove that option check so the logic always runs:
whenever dispatched == MIN and peek_byte().map(lookup_byte) == Some(MUL) perform
the same handling — if prev_byte().map(lookup_byte) == Some(MIN) then call
advance(1) and return Some(current as char), otherwise return None — while
keeping the same uses of dispatched, MIN, MUL, peek_byte, prev_byte, advance,
and current so token emission no longer depends on
is_tailwind_directives_enabled().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 069f830f-2d37-4c61-b60e-3edd57cfd92d
📒 Files selected for processing (3)
.changeset/fix-tailwind-utility-slash.mdcrates/biome_css_parser/src/lexer/mod.rscrates/biome_css_parser/src/syntax/at_rule/tailwind.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- .changeset/fix-tailwind-utility-slash.md
- crates/biome_css_parser/src/syntax/at_rule/tailwind.rs
| if self.options.is_tailwind_directives_enabled() | ||
| && current == b'-' | ||
| && self.peek_byte() == Some(b'*') | ||
| && dispatched == MIN | ||
| && self.peek_byte().map(lookup_byte) == Some(MUL) | ||
| { | ||
| // HACK: handle `--*` | ||
| if self.prev_byte() == Some(b'-') { | ||
| if self.prev_byte().map(lookup_byte) == Some(MIN) { | ||
| self.advance(1); | ||
| return Some(current as char); | ||
| } | ||
| // otherwise, handle cases like `--color-*` | ||
| return None; |
There was a problem hiding this comment.
Please don’t make lexer output depend on is_tailwind_directives_enabled().
This branch still tokenises the same bytes differently depending on a parser option. That’s a nasty way to make disabled-mode diagnostics go sideways.
Based on learnings: "In the Biome CSS parser, lexer token emission should not be gated behind parser options like is_tailwind_directives_enabled(). The lexer must emit correct tokens regardless of parser options to enable accurate diagnostics and error messages when the syntax is used incorrectly."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/biome_css_parser/src/lexer/mod.rs` around lines 1098 - 1108, The lexer
branch currently gates handling of sequences like `--*` on
self.options.is_tailwind_directives_enabled(), which makes token emission
option-dependent; remove that option check so the logic always runs: whenever
dispatched == MIN and peek_byte().map(lookup_byte) == Some(MUL) perform the same
handling — if prev_byte().map(lookup_byte) == Some(MIN) then call advance(1) and
return Some(current as char), otherwise return None — while keeping the same
uses of dispatched, MIN, MUL, peek_byte, prev_byte, advance, and current so
token emission no longer depends on is_tailwind_directives_enabled().
51d7636 to
b6f8a3d
Compare
Summary
Allows the css parser to parse
@utility a/b {}.fixes #8897
Test Plan
snapshots
Docs