Thanks to visit codestin.com
Credit goes to github.com

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: 13dd0b9

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 enhances the Tailwind lexer's base name handling by implementing boundary validation after matched bases. When a base name is found in consume_base, the lexer now verifies that the following byte is either a dash (indicating a value modifier), whitespace, or end of input before emitting the token. Additionally, five new dash-containing base names (break-after, break-before, inset-x, inset-y, mix-blend) are registered in the metadata, with corresponding test fixtures validating the new parsing behaviour.

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 accurately describes the main changes: fixing Tailwind lexing bugs for specific base names like inset-x and border-slate-500.
Description check ✅ Passed The description clearly explains the motivation and problems being solved, including missing base names and aggressive parsing issues, with tests added as validation.
✨ 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

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

@dyc3 dyc3 force-pushed the dyc3/fix-inset-parsing branch from 564d878 to 13dd0b9 Compare November 4, 2025 11:21
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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_tailwind_parser/src/lexer/mod.rs (1)

143-151: Consider combining the duplicate branches.

Both arms perform identical operations. You could simplify slightly:

     match self.byte_at(base_name.len()) {
-        Some(b'-') | None => {
-            self.advance(base_name.len());
-            return TW_BASE;
-        }
-        Some(b) if b.is_ascii_whitespace() => {
+        Some(b'-') | None | Some(b) if b.is_ascii_whitespace() => {
             self.advance(base_name.len());
             return TW_BASE;
         }
         _ => {}
     }

Though the current explicit form is perfectly clear.

📜 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 564d878 and 13dd0b9.

⛔ Files ignored due to path filters (4)
  • 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 **
📒 Files selected for processing (6)
  • 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_syntax/src/metadata.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • crates/biome_tailwind_parser/tests/tailwind_specs/ok/brackets/inset.txt
  • crates/biome_tailwind_syntax/src/metadata.rs
  • 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/simple/basic-2.txt
🧰 Additional context used
🧠 Learnings (2)
📚 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-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
⏰ 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). (7)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: autofix
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test Node.js API
🔇 Additional comments (2)
crates/biome_tailwind_parser/src/lexer/mod.rs (2)

132-165: Solid boundary validation fix.

The implementation correctly solves the false-match problem described in the PR. The fallthrough to generic logic ensures border-slate-500 parses as border (not border-s), whilst dash-containing bases like inset-x are properly recognised when followed by valid delimiters.


142-153: No action required—byte_at exists via the Lexer trait.

The byte_at method is defined as a default implementation in the Lexer trait, which TailwindLexer implements. The boundary validation logic is sound and correctly prevents false matches like border-s in border-slate-500.

Copy link
Contributor Author

dyc3 commented Nov 8, 2025

Merge activity

  • Nov 8, 7:23 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 8, 7:23 PM UTC: @dyc3 merged this pull request with Graphite.

@dyc3 dyc3 merged commit 846feee into main Nov 8, 2025
13 checks passed
@dyc3 dyc3 deleted the dyc3/fix-inset-parsing branch November 8, 2025 19:23
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