Skip to content

feat(css): add support for sass() in SCSS conditional expressions#9414

Merged
denbezrukov merged 4 commits intomainfrom
db/scss-if
Mar 9, 2026
Merged

feat(css): add support for sass() in SCSS conditional expressions#9414
denbezrukov merged 4 commits intomainfrom
db/scss-if

Conversation

@denbezrukov
Copy link
Contributor

Summary

Improves SCSS expression parsing for two Sass syntax gaps.

Biome now keeps unparenthesized !important inside SCSS variable values instead of misparsing it
as a variable modifier, and it recognizes if(sass(...): ...; else: ...;) in SCSS files.

Test Plan

new tests

@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

⚠️ No Changeset found

Latest commit: 8134566

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-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-CSS Language: CSS L-Grit Language: GritQL labels Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 53009 53009 0
Passed 51789 51789 0
Failed 1178 1178 0
Panics 42 42 0
Coverage 97.70% 97.70% 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 5466 5466 0
Passed 1915 1915 0
Failed 3551 3551 0
Panics 0 0 0
Coverage 35.03% 35.03% 0.00%

ts/babel

Test result main count This PR count Difference
Total 636 636 0
Passed 568 568 0
Failed 68 68 0
Panics 0 0 0
Coverage 89.31% 89.31% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18875 18875 0
Passed 13014 13014 0
Failed 5860 5860 0
Panics 1 1 0
Coverage 68.95% 68.95% 0.00%

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 9, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 187 skipped benchmarks1


Comparing db/scss-if (8134566) with main (77fe3a4)

Open in CodSpeed

Footnotes

  1. 187 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
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 01ca350b-3a96-4d2f-a06c-0deb32454bf9

📥 Commits

Reviewing files that changed from the base of the PR and between 8ceea05 and dcc26fe.

⛔ Files ignored due to path filters (5)
  • crates/biome_css_parser/tests/css_test_suite/error/function/if.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/function/scss_qualified_function.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/property/bracketed_value_separators.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/scss/declaration/invalid-modifier.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/scss/declaration/modifier-recovery.scss.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (3)
  • crates/biome_css_parser/src/syntax/parse_error.rs
  • crates/biome_css_parser/tests/css_test_suite/error/scss/declaration/invalid-modifier.scss
  • crates/biome_css_parser/tests/css_test_suite/error/scss/declaration/modifier-recovery.scss
💤 Files with no reviewable changes (3)
  • crates/biome_css_parser/src/syntax/parse_error.rs
  • crates/biome_css_parser/tests/css_test_suite/error/scss/declaration/invalid-modifier.scss
  • crates/biome_css_parser/tests/css_test_suite/error/scss/declaration/modifier-recovery.scss

Walkthrough

Adds SCSS sass(...) support to the CSS if() pipeline: new grammar node CssIfSassTest, lexer keyword sass, parser detection and parsing for sass tests (with SCSS expression options and variable-modifier awareness), formatter rule and wiring for the new node, test cases exercising the syntax, and small re-exports to share helper predicates across SCSS declaration parsing.

Possibly related PRs

Suggested labels

L-SCSS

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding support for sass() within SCSS conditional expressions, which is reflected throughout the changeset.
Description check ✅ Passed The description relates to the changeset by mentioning SCSS variable value parsing and if(sass(...)) support, though it could be more detailed about the specific implementation.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch db/scss-if

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_css_parser/src/syntax/scss/expression/mod.rs`:
- Around line 63-70: The recovery logic must also stop before variable modifiers
so modifiers like "!default" / "!global" aren't consumed into a malformed
expression: update the recovery boundary to mirror variable_value's boundary
(i.e., respect stops_before_variable_modifiers). Specifically, modify the
recovery path that currently uses recovery_end_ts() so it checks for variable
modifiers and treats them as stopping tokens (or pass the same end_ts that
includes that stop), and apply the same change to the other analogous
constructor(s) referenced around lines 91-93; refer to variable_value,
recovery_end_ts, and the stops_before_variable_modifiers flag when locating
where to add the stop-for-modifiers check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4c76c3bf-7179-407e-8692-bb8c1199d771

📥 Commits

Reviewing files that changed from the base of the PR and between 9c95b13 and 426c6aa.

⛔ Files ignored due to path filters (10)
  • 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/css/scss/expression/edge-cases.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/function/if.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/value/if-disambiguation.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/value/list-important-item.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_syntax/src/generated/kind.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_css_syntax/src/generated/macros.rs is excluded by !**/generated/**, !**/generated/** 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 (21)
  • crates/biome_css_formatter/src/css/any/if_test.rs
  • crates/biome_css_formatter/src/css/auxiliary/if_sass_test.rs
  • crates/biome_css_formatter/src/css/auxiliary/mod.rs
  • crates/biome_css_formatter/src/generated.rs
  • crates/biome_css_formatter/tests/specs/css/scss/expression/edge-cases.scss
  • crates/biome_css_parser/src/lexer/mod.rs
  • crates/biome_css_parser/src/lexer/tests.rs
  • crates/biome_css_parser/src/syntax/scss/declaration/mod.rs
  • crates/biome_css_parser/src/syntax/scss/declaration/variable.rs
  • crates/biome_css_parser/src/syntax/scss/declaration/variable_modifier.rs
  • crates/biome_css_parser/src/syntax/scss/expression/list.rs
  • crates/biome_css_parser/src/syntax/scss/expression/mod.rs
  • crates/biome_css_parser/src/syntax/scss/mod.rs
  • crates/biome_css_parser/src/syntax/value/function/call.rs
  • crates/biome_css_parser/src/syntax/value/if.rs
  • crates/biome_css_parser/tests/css_test_suite/error/function/if.css
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/value/if-disambiguation.scss
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/value/list-important-item.scss
  • crates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rs
  • xtask/codegen/css.ungram
  • xtask/codegen/src/css_kinds_src.rs

@denbezrukov denbezrukov merged commit 0536fd3 into main Mar 9, 2026
18 checks passed
@denbezrukov denbezrukov deleted the db/scss-if branch March 9, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: internal tools L-CSS Language: CSS L-Grit Language: GritQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants