Skip to content

Conversation

@ematipico
Copy link
Member

Summary

This is an internal code change that doesn't effect formatting and lint rules yet.

This PR updates the CssFileSource type to new variants: CssModules and TailwindCss. These variants are computed when opening the file from the Workspace.

This information will allow us to better target lint rules, such as #8083

Test Plan

CI should stay green

Docs

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

⚠️ No Changeset found

Latest commit: e17d3b7

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

@github-actions github-actions bot added A-Project Area: project A-Parser Area: parser L-CSS Language: CSS labels Nov 13, 2025
@ematipico ematipico requested review from a team November 13, 2025 15:11
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

This PR establishes CSS variant support infrastructure by introducing a CssVariant enum with CssModules and TailwindCss variants, adding query methods on CssFileSource, implementing a From<&CssFileSource> conversion to CssParserOptions, and updating the workspace server to set CSS variants based on configuration. The changes enable the parser to derive configuration from file source characteristics at runtime.

Possibly related PRs

Suggested reviewers

  • dyc3

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: adding CSS variant information (CssModules and TailwindCss variants) to the CssFileSource type.
Description check ✅ Passed The description clearly explains the internal change to CssFileSource with new variants and their purpose for targeted lint rules, directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
✨ 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 chore/add-variants-to-css

📜 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 b406db6 and 1049fe3.

📒 Files selected for processing (4)
  • crates/biome_css_parser/src/parser.rs (2 hunks)
  • crates/biome_css_syntax/src/file_source.rs (3 hunks)
  • crates/biome_css_syntax/src/lib.rs (1 hunks)
  • crates/biome_service/src/workspace/server.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-20T16:24:59.781Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7266
File: crates/biome_js_type_info/src/type.rs:94-102
Timestamp: 2025-08-20T16:24:59.781Z
Learning: In crates/biome_js_type_info/src/type.rs, the flattened_union_variants() method returns TypeReference instances that already have the correct module IDs applied to them. These references should be used directly with resolver.resolve_reference() without applying additional module ID transformations, as variant references may originate from nested unions in different modules.

Applied to files:

  • crates/biome_css_syntax/src/lib.rs
  • crates/biome_service/src/workspace/server.rs
📚 Learning: 2025-11-09T12:47:46.298Z
Learnt from: ematipico
Repo: biomejs/biome PR: 8031
File: crates/biome_html_parser/src/syntax/svelte.rs:140-147
Timestamp: 2025-11-09T12:47:46.298Z
Learning: In the Biome HTML parser, `expect` and `expect_with_context` consume the current token and then lex the next token. The context parameter in `expect_with_context` controls how the next token (after the consumed one) is lexed, not the current token being consumed. For example, in Svelte parsing, after `bump_with_context(T!["{:"], HtmlLexContext::Svelte)`, the next token is already lexed in the Svelte context, so `expect(T![else])` is sufficient unless the token after `else` also needs to be lexed in a specific context.

Applied to files:

  • crates/biome_css_parser/src/parser.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_css_parser/src/parser.rs
🧬 Code graph analysis (1)
crates/biome_service/src/workspace/server.rs (1)
crates/biome_css_syntax/src/file_source.rs (1)
  • css (35-39)
⏰ 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: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Check Dependencies
  • GitHub Check: autofix
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
🔇 Additional comments (8)
crates/biome_service/src/workspace/server.rs (2)

25-25: LGTM!

Import added to support CSS variant handling below.


356-377: CSS variant selection looks good.

The if-else structure means CSS Modules takes precedence if both css_modules_enabled and tailwind_directives are true. This is likely intentional since these represent different tooling approaches, but worth confirming.

crates/biome_css_syntax/src/lib.rs (1)

15-15: LGTM!

Public export enables external usage of the CSS variant API.

crates/biome_css_parser/src/parser.rs (2)

4-4: LGTM!

Imports added to support the From implementation below.


174-186: Clean conversion implementation.

The From trait correctly derives parser options from file source characteristics, enabling the appropriate CSS variant features.

crates/biome_css_syntax/src/file_source.rs (3)

25-32: LGTM!

CssVariant is now public with new variants properly documented. This establishes the foundation for CSS variant support.


41-57: Helper methods look good.

The constructors and predicates follow consistent naming patterns and provide a clean API for working with CSS variants.


83-83: LGTM!

Language ID mapping for "tailwindcss" is a useful addition for LSP integration.


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

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 13, 2025

CodSpeed Performance Report

Merging #8095 will not alter performance

Comparing chore/add-variants-to-css (e17d3b7) with main (963dbaf)

Summary

✅ 29 untouched
⏩ 126 skipped1

Footnotes

  1. 126 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Makes sense to me

@ematipico ematipico merged commit 6f5b876 into main Nov 13, 2025
17 checks passed
@ematipico ematipico deleted the chore/add-variants-to-css branch November 13, 2025 15:45
ematipico added a commit to hamirmahal/biome that referenced this pull request Nov 19, 2025
…8095)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
l0ngvh pushed a commit to l0ngvh/biome that referenced this pull request Dec 21, 2025
…8095)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser A-Project Area: project L-CSS Language: CSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants