Skip to content

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Nov 3, 2025

Summary

Fixes misc lexing bugs

  • some base names like inset-x and inset-y were missing
  • some candidates like border-slate-500 would get aggressively interpreted as border-s as the base name, when it should be border.

Test Plan

added tests

Docs

@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2025

⚠️ No Changeset found

Latest commit: 564d878

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

Copy link
Contributor Author

dyc3 commented Nov 3, 2025

@github-actions github-actions bot added A-Parser Area: parser L-Tailwind Language: Tailwind CSS labels Nov 3, 2025
@dyc3 dyc3 marked this pull request as ready for review November 3, 2025 21:53
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

This PR modifies the Tailwind lexer's base name consumption logic to add boundary validation, ensuring a matched base is emitted as a token only when followed by a dash, whitespace, or end of input. Five new dash-containing utility names are registered in the metadata: break-after, break-before, inset-x, inset-y, and mix-blend. Multiple test fixtures are added to validate parsing of inset, spacing, border, and mixed utility classes with bracketed arbitrary values and responsive/state variations.

Possibly related PRs

Suggested reviewers

  • ematipico
  • siketyan

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main changes: fixing lexing bugs for Tailwind base names like inset-x and multi-part names like border-slate-500.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation (missing base names and incorrect parsing) and noting that tests were added.
✨ 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 dyc3/fix-inset-parsing

📜 Recent 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 c9e20c3 and 564d878.

⛔ Files ignored due to path filters (5)
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/inset.txt.snap is excluded by !**/*.snap and included by **
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/misc-xy.txt.snap is excluded by !**/*.snap and included by **
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/basic-2.txt.snap is excluded by !**/*.snap and included by **
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/border.txt.snap is excluded by !**/*.snap and included by **
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/stress/stress-3.txt.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (7)
  • crates/biome_tailwind_parser/src/lexer/mod.rs (1 hunks)
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/inset.txt (1 hunks)
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/misc-xy.txt (1 hunks)
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/basic-2.txt (1 hunks)
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/border.txt (1 hunks)
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/stress/stress-3.txt (1 hunks)
  • crates/biome_tailwind_syntax/src/metadata.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files before committing (e.g., via just f)

Files:

  • crates/biome_tailwind_syntax/src/metadata.rs
  • crates/biome_tailwind_parser/src/lexer/mod.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and their options with inline rustdoc in the Rust source

Files:

  • crates/biome_tailwind_syntax/src/metadata.rs
  • crates/biome_tailwind_parser/src/lexer/mod.rs
🧠 Learnings (9)
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/spec_tests.rs : In tests/spec_tests.rs, generate tests with `tests_macros::gen_tests! {"tests/specs/html/**/*.html", crate::spec_test::run, ""}`

Applied to files:

  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/misc-xy.txt
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/border.txt
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/inset.txt
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/stress/stress-3.txt
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/basic-2.txt
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/** : Create a tests directory containing a specs subfolder and the files spec_test.rs, spec_tests.rs, and language.rs

Applied to files:

  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/misc-xy.txt
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/border.txt
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/inset.txt
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/specs/html/**/*.html : Place HTML test cases under tests/specs/html as .html files discovered by the test macro

Applied to files:

  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/misc-xy.txt
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/border.txt
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/inset.txt
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 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 : Do not attempt to fix code; if a mandatory token/node is missing, return `None` instead

Applied to files:

  • crates/biome_tailwind_parser/src/lexer/mod.rs
📚 Learning: 2025-10-15T09:24:31.042Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:24:31.042Z
Learning: Applies to crates/biome_parser/crates/**/src/lexer/mod.rs : Create a lexer module at crates/<parser_crate>/src/lexer/mod.rs

Applied to files:

  • crates/biome_tailwind_parser/src/lexer/mod.rs
📚 Learning: 2025-10-25T07:22:18.540Z
Learnt from: ematipico
Repo: biomejs/biome PR: 7852
File: crates/biome_css_parser/src/syntax/property/mod.rs:161-168
Timestamp: 2025-10-25T07:22:18.540Z
Learning: 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.

Applied to files:

  • crates/biome_tailwind_parser/src/lexer/mod.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 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 : For non-mandatory tokens, use the provided helper constructors (e.g., `token`, `space_token`, `dynamic_token`)

Applied to files:

  • crates/biome_tailwind_parser/src/lexer/mod.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 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 : When a token is mandatory and present in the AST, use the AST-provided token (e.g., `node.l_paren_token().format()`) instead of emitting a static token

Applied to files:

  • crates/biome_tailwind_parser/src/lexer/mod.rs
📚 Learning: 2025-10-15T09:24:31.042Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:24:31.042Z
Learning: Lexer must implement the biome_parser::Lexer trait

Applied to files:

  • crates/biome_tailwind_parser/src/lexer/mod.rs
🪛 LanguageTool
crates/biome_tailwind_parser/tests/tailwind_specs/ok/stress/stress-3.txt

[uncategorized] ~59-~59: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...t-slate-600 only-of-type:text-slate-500 only-child:text-slate-400 checked:bg-blue-500 che...

(HYPHENATED_LY_ADVERB_ADJECTIVE)

⏰ 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). (3)
  • GitHub Check: Test Node.js API
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
🔇 Additional comments (7)
crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/misc-xy.txt (1)

1-1: Test fixture looks good.

Covers spacing utilities with bracketed arbitrary values.

crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/border.txt (1)

1-1: Test fixture looks good.

Demonstrates the fix for border-slate-500 being incorrectly interpreted as border-s.

crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/inset.txt (1)

1-1: Test fixture looks good.

Covers the newly added inset-x and inset-y bases with bracketed arbitrary values.

crates/biome_tailwind_parser/tests/tailwind_specs/ok/stress/stress-3.txt (1)

1-131: Comprehensive stress test fixture.

Excellent coverage of responsive variants, state modifiers, and the newly supported dash-containing bases. The LanguageTool hint about only-child is a false positive—it's a valid CSS pseudo-class.

crates/biome_tailwind_parser/tests/tailwind_specs/ok/simple/basic-2.txt (1)

1-1: Test fixture looks good.

Covers the newly added break-before, break-after, and mix-blend bases.

crates/biome_tailwind_parser/src/lexer/mod.rs (1)

142-153: Boundary validation fixes the parsing issue.

The logic correctly ensures that a matched base is only emitted when followed by a dash, whitespace, or end of input. This prevents border-slate-500 from incorrectly matching border-s. Well done!

crates/biome_tailwind_syntax/src/metadata.rs (1)

32-33: Metadata additions are correct and properly sorted.

The five new dash-containing bases (break-after, break-before, inset-x, inset-y, mix-blend) are properly positioned alphabetically, which is essential for the lexer's longest-match logic.

Also applies to: 48-49, 80-80


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

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

If possible, I would remove the stress file from the usual testing suite for performance reasons

Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to use this in codspeed? Otherwise everyone would need to run this every time, who knows how long it takes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair enough, ill remove it

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

Labels

A-Parser Area: parser L-Tailwind Language: Tailwind CSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants