Repository navigation
feat(css_parser): parse interpolated scss media conditions - #10573
Conversation
|
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
Parser conformance results onjs/262
jsx/babel
markdown/commonmark
symbols/microsoft
ts/babel
ts/microsoft
|
WalkthroughThis 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
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)
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. Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (9)
crates/biome_css_analyze/tests/specs/correctness/noUnknownMediaFeatureName/valid.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_factory/src/generated/node_factory.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_factory/src/generated/syntax_factory.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_formatter/tests/specs/scss/at-rule/media-interpolated-logic.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/error/at_rule/at_rule_media_and_not_condition.css.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/media-and-not-condition.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_syntax/src/generated/nodes.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_syntax/src/generated/nodes_mut.rsis excluded by!**/generated/**,!**/generated/**and included by**
📒 Files selected for processing (19)
crates/biome_css_analyze/src/lint/correctness/no_unknown_media_feature_name.rscrates/biome_css_analyze/tests/specs/correctness/noUnknownMediaFeatureName/valid.scsscrates/biome_css_formatter/src/css/any/media_and_combinable_condition.rscrates/biome_css_formatter/src/css/any/media_condition.rscrates/biome_css_formatter/src/css/any/media_condition_operand.rscrates/biome_css_formatter/src/css/any/media_or_combinable_condition.rscrates/biome_css_formatter/src/css/any/media_type_condition.rscrates/biome_css_formatter/src/css/any/mod.rscrates/biome_css_formatter/src/generated.rscrates/biome_css_formatter/tests/specs/scss/at-rule/media-interpolated-logic.scsscrates/biome_css_parser/src/syntax/at_rule/media.rscrates/biome_css_parser/src/syntax/scss/at_rule/media.rscrates/biome_css_parser/src/syntax/scss/at_rule/mod.rscrates/biome_css_parser/src/syntax/scss/at_rule/query_feature.rscrates/biome_css_parser/src/syntax/scss/mod.rscrates/biome_css_parser/tests/css_test_suite/error/at_rule/at_rule_media_and_not_condition.csscrates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/media-and-not-condition.scsscrates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scssxtask/codegen/css.ungram
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss (1)
25-29: ⚡ Quick winAdd one parenthesised
orsibling case for this new branch.Line 25 validates
(#{$query} and not (color)), but the new parser path also branches onor. 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
⛔ Files ignored due to path filters (2)
crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolation.scss.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (7)
crates/biome_css_parser/src/syntax/at_rule/media.rscrates/biome_css_parser/src/syntax/scss/at_rule/media.rscrates/biome_css_parser/src/syntax/scss/at_rule/mod.rscrates/biome_css_parser/src/syntax/scss/at_rule/query_feature.rscrates/biome_css_parser/src/syntax/scss/mod.rscrates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/media-interpolated-logic.scsscrates/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
Summary
Adds support for SCSS media conditions where interpolation participates in media logic, for example:
Test Plan
cargo test -p biome_css_parsercargo test -p biome_css_formatter