Skip to content

feat(css_parser): parse interpolated scss media conditions - #10573

Merged
denbezrukov merged 2 commits into
mainfrom
db/scss-media-interpolation
Jun 7, 2026
Merged

denbezrukov merged 2 commits into
mainfrom
db/scss-media-interpolation

Conversation

@denbezrukov

Copy link
Copy Markdown
Contributor

This PR was created with AI assistance.

Summary

Adds support for SCSS media conditions where interpolation participates in media logic, for example:

@media (color) and #{$query} {}
@media #{$query} and not (color) {}
@media #{$query} or (color) {}

Test Plan

  • cargo test -p biome_css_parser
  • cargo test -p biome_css_formatter

@changeset-bot

changeset-bot Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2d8c159

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 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

✅ Organic activity

No automation signals detected in the analyzed events.

View full analysis →

This is an automated analysis by AgentScan

@github-actions github-actions Bot added A-Linter Area: linter A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-CSS Language: CSS and super languages labels Jun 6, 2026
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 53334 53334 0
Passed 52116 52116 0
Failed 1176 1176 0
Panics 42 42 0
Coverage 97.72% 97.72% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 38 38 0
Passed 37 37 0
Failed 1 1 0
Panics 0 0 0
Coverage 97.37% 97.37% 0.00%

markdown/commonmark

Test result main count This PR count Difference
Total 652 652 0
Passed 652 652 0
Failed 0 0 0
Panics 0 0 0
Coverage 100.00% 100.00% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5467 5467 0
Passed 1915 1915 0
Failed 3552 3552 0
Panics 0 0 0
Coverage 35.03% 35.03% 0.00%

ts/babel

Test result main count This PR count Difference
Total 658 658 0
Passed 574 574 0
Failed 84 84 0
Panics 0 0 0
Coverage 87.23% 87.23% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18876 18876 0
Passed 13010 13010 0
Failed 5865 5865 0
Panics 1 1 0
Coverage 68.92% 68.92% 0.00%

@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR introduces AnyCssMediaConditionOperand as the canonical operand for media conditions, updates the grammar and parser to parse/traverse operands (including SCSS interpolation-led queries), adds SCSS-specific parsing and re-exports, updates the formatter to support the new operand node, refactors the noUnknownMediaFeatureName lint to validate operands via has_invalid_media_condition_operand, and adds tests exercising interpolated and combinable media conditions.

Possibly related PRs

  • biomejs/biome#10181: Touches SCSS media-query interpolation and formatter support for ScssMediaQuery used by the new operand abstraction.

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change—adding SCSS media condition parsing with interpolation support—and directly reflects the core feature across parser, formatter, and linter files.
Description check ✅ Passed The description clearly explains the feature being added (interpolated SCSS media conditions with logical operators) and provides concrete examples that match the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch db/scss-media-interpolation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 547b4b2d-b704-4555-abe5-c9ed9fcf90f8

📥 Commits

Reviewing files that changed from the base of the PR and between 6022c19 and 53677c0.

⛔ Files ignored due to path filters (9)
  • crates/biome_css_analyze/tests/specs/correctness/noUnknownMediaFeatureName/valid.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_factory/src/generated/node_factory.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_css_factory/src/generated/syntax_factory.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_css_formatter/tests/specs/scss/at-rule/media-interpolated-logic.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/at_rule/at_rule_media_and_not_condition.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/media-and-not-condition.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_syntax/src/generated/nodes.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_css_syntax/src/generated/nodes_mut.rs is excluded by !**/generated/**, !**/generated/** and included by **
📒 Files selected for processing (19)
  • crates/biome_css_analyze/src/lint/correctness/no_unknown_media_feature_name.rs
  • crates/biome_css_analyze/tests/specs/correctness/noUnknownMediaFeatureName/valid.scss
  • crates/biome_css_formatter/src/css/any/media_and_combinable_condition.rs
  • crates/biome_css_formatter/src/css/any/media_condition.rs
  • crates/biome_css_formatter/src/css/any/media_condition_operand.rs
  • crates/biome_css_formatter/src/css/any/media_or_combinable_condition.rs
  • crates/biome_css_formatter/src/css/any/media_type_condition.rs
  • crates/biome_css_formatter/src/css/any/mod.rs
  • crates/biome_css_formatter/src/generated.rs
  • crates/biome_css_formatter/tests/specs/scss/at-rule/media-interpolated-logic.scss
  • crates/biome_css_parser/src/syntax/at_rule/media.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/media.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/mod.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/query_feature.rs
  • crates/biome_css_parser/src/syntax/scss/mod.rs
  • crates/biome_css_parser/tests/css_test_suite/error/at_rule/at_rule_media_and_not_condition.css
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/media-and-not-condition.scss
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss
  • xtask/codegen/css.ungram

@codspeed

codspeed Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 227 skipped benchmarks1


Comparing db/scss-media-interpolation (2d8c159) with main (6022c19)

Open in CodSpeed

Footnotes

  1. 227 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. ↩

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss (1)

25-29: ⚡ Quick win

Add one parenthesised or sibling case for this new branch.

Line 25 validates (#{$query} and not (color)), but the new parser path also branches on or. A tiny extra fixture keeps that path locked down.

As per coding guidelines, "All code changes MUST include tests ... parser tests for valid and error cases, and bug fix tests reproducing and validating the fix."

Suggested fixture addition
 `@media` (#{$query} and not (color)) {
   x {
     y: z;
   }
 }
+
+@media (#{$query} or (color)) {
+  x {
+    y: z;
+  }
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss`
around lines 25 - 29, Add a second test case next to the existing `@media` block
that exercises the parenthesised "or" sibling branch: create a new fixture in
the same file using the same structure but with an `@media` condition like
"(#{$query} or (color))" (i.e. a parenthesised or between the query
interpolation and a parenthesised feature) and the same inner rules (x { y: z;
}) so the parser path that handles "or" is covered.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss`:
- Around line 25-29: Add a second test case next to the existing `@media` block
that exercises the parenthesised "or" sibling branch: create a new fixture in
the same file using the same structure but with an `@media` condition like
"(#{$query} or (color))" (i.e. a parenthesised or between the query
interpolation and a parenthesised feature) and the same inner rules (x { y: z;
}) so the parser path that handles "or" is covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 49297e1f-5d87-43c6-8b91-03680412dc71

📥 Commits

Reviewing files that changed from the base of the PR and between 53677c0 and 2d8c159.

⛔ Files ignored due to path filters (2)
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolation.scss.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (7)
  • crates/biome_css_parser/src/syntax/at_rule/media.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/media.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/mod.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/query_feature.rs
  • crates/biome_css_parser/src/syntax/scss/mod.rs
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolation.scss
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_css_parser/src/syntax/scss/mod.rs
  • crates/biome_css_parser/src/syntax/at_rule/media.rs

@denbezrukov
denbezrukov merged commit 80449d6 into main Jun 7, 2026
32 checks passed
@denbezrukov
denbezrukov deleted the db/scss-media-interpolation branch June 7, 2026 18:16
THernandez03 pushed a commit to THernandez03/biome that referenced this pull request Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Linter Area: linter A-Parser Area: parser A-Tooling Area: internal tools L-CSS Language: CSS and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants