Skip to content

feat(css): add support for SCSS @at-root at-rule#9461

Merged
denbezrukov merged 4 commits intomainfrom
db/scss-at-rule
Mar 12, 2026
Merged

feat(css): add support for SCSS @at-root at-rule#9461
denbezrukov merged 4 commits intomainfrom
db/scss-at-rule

Conversation

@denbezrukov
Copy link
Contributor

This PR was created with AI assistance (Codex).

Summary

Adds support for SCSS @at-root

Test Plan

cargo test -p biome_css_parser/formatter/analyzer

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

⚠️ No Changeset found

Latest commit: 1bf4793

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-Linter Area: linter A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-CSS Language: CSS and super languages labels Mar 12, 2026
@github-actions
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 53133 53133 0
Passed 51913 51913 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%

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 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: b704d1d0-06ed-4f56-9baa-47f0c60d5fff

📥 Commits

Reviewing files that changed from the base of the PR and between f4e6026 and 1bf4793.

📒 Files selected for processing (1)
  • crates/biome_css_parser/src/syntax/scss/at_rule/at_root_at_rule.rs

Walkthrough

Adds comprehensive SCSS @at-root support: lexer keywords (at-root, without), new AST nodes (ScssAtRootAtRule, ScssAtRootQuery, ScssAtRootQueryList, ScssAtRootSelector), parser with recovery for @at-root, formatter rules and generated Format/AsFormat/IntoFormat bindings, analyzer handling, module registrations, and test fixtures for OK and error cases.

Possibly related PRs

Suggested labels

L-SCSS

Suggested reviewers

  • ematipico
  • siketyan
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarises the main change: adding SCSS @at-root at-rule support to the CSS parser/formatter.
Description check ✅ Passed The description is directly related to the changeset, mentioning the addition of SCSS @at-root support and providing a test plan.

✏️ 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-at-rule
📝 Coding Plan for PR comments
  • Generate coding plan

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

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

7-9: Add one interpolation-based shorthand fixture.

This covers the static selector shorthand, but not the documented @at-root #{...} form. A small case using interpolation or selector.unify() would pin down the SCSS-specific branch much better than another plain selector example. (sass-lang.com)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/at-root.scss`
around lines 7 - 9, Add a new test case that exercises the SCSS interpolation
shorthand form of at-root by using the `@at-root` #{...} syntax (or
selector.unify()) instead of a plain selector; update the existing at-root
fixture to include a line using `@at-root` #{".root-only, .another-root"} (or an
equivalent expression built with selector.unify()) so the parser's SCSS-specific
branch for interpolation-based shorthand is covered.
🤖 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_formatter/src/generated.rs`:
- Around line 10385-10409: The generated impls reference a missing module/type:
crate::scss::lists::at_root_query_list::FormatScssAtRootQueryList used for
biome_css_syntax::ScssAtRootQueryList; create or export that formatter (module
at_root_query_list with a public FormatScssAtRootQueryList type implementing the
expected formatting trait) in the scss lists package or update the generated
path to the correct module, then re-run the formatter generator (just
gen-formatter) to regenerate crates/biome_css_formatter/src/generated.rs so the
impls resolve.

In `@crates/biome_css_parser/src/syntax/scss/at_rule/at_root_at_rule.rs`:
- Around line 125-131: Change parse_scss_at_root_selector to return ParsedSyntax
instead of () and only create/complete the node when a selector is actually
parsed: first attempt to predict/parse the selector by invoking
SelectorList::default().parse_list(p) (or using a lookahead) and check its
ParsedSyntax result; if it is Absent then return ParsedSyntax::Absent without
starting or completing a marker (do not call m.complete), otherwise start the
marker, let the successful parse consume tokens, complete the marker with
SCSS_AT_ROOT_SELECTOR and return ParsedSyntax::Present. Ensure you reference the
existing symbols parse_scss_at_root_selector,
SelectorList::default().parse_list, m.complete, and SCSS_AT_ROOT_SELECTOR when
implementing this change so the helper behaves like other ParsedSyntax rules.

---

Nitpick comments:
In `@crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/at-root.scss`:
- Around line 7-9: Add a new test case that exercises the SCSS interpolation
shorthand form of at-root by using the `@at-root` #{...} syntax (or
selector.unify()) instead of a plain selector; update the existing at-root
fixture to include a line using `@at-root` #{".root-only, .another-root"} (or an
equivalent expression built with selector.unify()) so the parser's SCSS-specific
branch for interpolation-based shorthand is covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 606fa29b-5d20-4c9d-be00-7352322c34ae

📥 Commits

Reviewing files that changed from the base of the PR and between b71292c and 90c5453.

⛔ Files ignored due to path filters (9)
  • 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/at-rule/at-root.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/at-root.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/at-root.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 (20)
  • crates/biome_css_analyze/src/lint/nursery/use_baseline.rs
  • crates/biome_css_formatter/src/css/any/at_rule.rs
  • crates/biome_css_formatter/src/generated.rs
  • crates/biome_css_formatter/src/scss/auxiliary/at_root_query.rs
  • crates/biome_css_formatter/src/scss/auxiliary/mod.rs
  • crates/biome_css_formatter/src/scss/lists/at_root_query_list.rs
  • crates/biome_css_formatter/src/scss/selectors/at_root_selector.rs
  • crates/biome_css_formatter/src/scss/selectors/mod.rs
  • crates/biome_css_formatter/src/scss/statements/at_root_at_rule.rs
  • crates/biome_css_formatter/src/scss/statements/mod.rs
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/at-root.scss
  • crates/biome_css_parser/src/lexer/mod.rs
  • crates/biome_css_parser/src/syntax/at_rule/mod.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/at_root_at_rule.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/mod.rs
  • crates/biome_css_parser/src/syntax/scss/mod.rs
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/at-root.scss
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/at-root.scss
  • xtask/codegen/css.ungram
  • xtask/codegen/src/css_kinds_src.rs

@github-actions github-actions bot added the L-Grit Language: GritQL label Mar 12, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 12, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 187 skipped benchmarks1


Comparing db/scss-at-rule (1bf4793) with main (b71292c)

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.

@denbezrukov denbezrukov merged commit 4305e9d into main Mar 12, 2026
19 checks passed
@denbezrukov denbezrukov deleted the db/scss-at-rule branch March 12, 2026 18:22
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 L-Grit Language: GritQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants