Skip to content

feat(css): add support for SCSS @import and @extend at-rules#9458

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

feat(css): add support for SCSS @import and @extend at-rules#9458
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 @import and @extend at-rules.

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

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 L-Grit Language: GritQL 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%

@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 (f689d42) with main (f4d2073)

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 12, 2026

Walkthrough

Adds SCSS @extend and @import support across parser, formatter and analysis: new SCSS AST nodes (placeholder selector, extend/import at-rules and related items), parser implementations for SCSS extend/import and placeholder selectors, formatter rules and generated bindings, shared import-payload formatter helper, lexer keyword additions (extend, optional), and analyzer/semantic updates to recognise the new nodes.

Possibly related PRs

Suggested labels

L-SCSS

Suggested reviewers

  • ematipico
  • siketyan
  • dyc3
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding support for SCSS @import and @extend at-rules to the CSS implementation.
Description check ✅ Passed The description accurately relates to the changeset, explaining that SCSS @import and @extend at-rules support is being added, with a concrete test plan provided.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/biome_css_parser/src/syntax/selector/mod.rs (1)

309-328: ⚠️ Potential issue | 🟡 Minor

Keep %placeholder on the conditional-syntax path.

By folding the SCSS feature check into simple-selector prediction, plain CSS now sees %foo as “not a selector” rather than “unsupported SCSS syntax”. That skips the usual feature-gated bogus-node path and weakens recovery/diagnostics for CSS files. Please route placeholder parsing through the existing ConditionalParsedSyntax / or_invalid_to_bogus() pattern instead. Based on learnings: Use ConditionalParsedSyntax for syntax that is only valid in specific contexts (e.g., strict mode, file types, language versions) and call or_invalid_to_bogus() to convert to a bogus node if not supported.

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

In `@crates/biome_css_parser/src/syntax/selector/mod.rs` around lines 309 - 328,
The parser currently short-circuits SCSS placeholder parsing in
parse_simple_selector by returning parse_scss_placeholder_selector when
is_nth_at_scss_placeholder_selector is true, which bypasses feature-gating;
instead, remove the direct return and route placeholder parsing through the
conditional-syntax pattern: when is_nth_at_scss_placeholder_selector(p, 0) is
true, wrap the parse_scss_placeholder_selector(p) call in a
ConditionalParsedSyntax (or use ConditionalParsedSyntax::new/appropriate
constructor) and then call .or_invalid_to_bogus() so that if the SCSS feature is
disabled it converts to a bogus node/invalid syntax; keep references to
parse_simple_selector, is_nth_at_scss_placeholder_selector,
parse_scss_placeholder_selector, ConditionalParsedSyntax, and
or_invalid_to_bogus when making the change.
🧹 Nitpick comments (3)
crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/extend.scss (1)

1-4: Add a recovery sentinel after the broken @extends.

At the moment this only proves diagnostics at EOF. A tiny valid rule afterwards would also prove the parser recovers cleanly after malformed @extend statements.

Possible fixture tweak
 `@extend`;
 `@extend` !optional;
 `@extend` .message !;
 `@extend` .message
+
+.after {
+  color: red;
+}

Based on learnings, "All code changes MUST include tests - lint rules need snapshot tests in tests/specs/{group}/{rule}/, formatter changes need snapshot tests with valid/invalid cases, parser changes need test files covering valid and error cases"

🤖 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/error/scss/at-rule/extend.scss`
around lines 1 - 4, Add a small valid CSS rule after the malformed `@extend`
statements in extend.scss so the parser has a recovery sentinel and we can
assert it continues parsing beyond EOF; locate the broken tokens (the lines
containing the `@extend` usages: `@extend;`, `@extend !optional;`, `@extend
.message !;`, and the unterminated `@extend .message`) and append a simple valid
rule (e.g., a selector with a property declaration) to prove recovery and update
snapshots accordingly.
crates/biome_css_formatter/tests/specs/css/scss/at-rule/import.scss (1)

1-22: Please cover the trickier import-classification branches too.

This fixture hits the easy cases, but the new formatter logic also has to tell CSS imports from plain SCSS imports for inputs like .CSS?cache=1#section, protocol-relative URLs, and https://…. Those branches are only pinned in the parser suite right now, which leaves a sneaky formatter regression path open.

Possible additions
 `@import` "print.css"
 print
 ,
 screen;
 
 `@import` url("theme.css");
+
+@import "theme.CSS?cache=1#section";
+
+@import "//example.com/theme";
+
+@import "https://example.com/theme.css";

Based on learnings, "All code changes MUST include tests - lint rules need snapshot tests in tests/specs/{group}/{rule}/, formatter changes need snapshot tests with valid/invalid cases"

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

In `@crates/biome_css_formatter/tests/specs/css/scss/at-rule/import.scss` around
lines 1 - 22, Add snapshot cases to the import.scss fixture to cover the tricky
import-classification branches the formatter must handle: include imports with
query/hash like `@import` "theme.CSS?cache=1#section"; protocol-relative and
absolute URLs like `@import` "//cdn.example.com/library.css"; `@import`
"https://example.com/style.css"; and mixed forms with media lists (e.g., `@import`
"print.css" print, screen;) and url(...) variants (e.g., `@import`
url("//cdn.example.com/x.css?ver=1#a") screen;). Update
tests/specs/css/scss/at-rule/import.scss by adding these lines so the formatter
snapshot verifies CSS vs SCSS import detection for all edge cases.
crates/biome_css_formatter/tests/specs/css/scss/at-rule/extend.scss (1)

1-16: Please add non-rule-body contexts to this formatter spec.

All the @extend samples here live inside qualified rules. The new formatter is also wired into root statement lists and nested directive blocks, so I'd add one top-level @extend and one inside @include to pin those paths as well.

Possible additions
 .alert{
   `@extend`
 .message,.info;
   `@extend`
 a:hover;
 }
+
+@extend .message;
+
+@include themed-button {
+  `@extend` .message;
+}

Based on learnings, "All code changes MUST include tests - lint rules need snapshot tests in tests/specs/{group}/{rule}/, formatter changes need snapshot tests with valid/invalid cases"

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

In `@crates/biome_css_formatter/tests/specs/css/scss/at-rule/extend.scss` around
lines 1 - 16, Add non-rule-body contexts for `@extend` by inserting one
top-level/root statement `@extend` example and one `@extend` nested inside a
directive block (use an `@include` block) alongside the existing qualified-rule
examples; e.g., add a root-level use that extends %toolbelt and an `@include` {
`@extend` %toolbelt; } case to ensure the formatter is exercised in root statement
lists and nested directive blocks, and update the formatter snapshot tests
accordingly.
🤖 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/tests/css_test_suite/error/scss/at-rule/extend_interpolation.scss`:
- Line 1: The test case currently treating "@extend .icon-#{$name};" as an error
is incorrect; update the test organization by moving the case with the
interpolated selector ".icon-#{$name}" out of the error suite and into the
valid/accepted Sass test suite so the parser recognizes interpolation in `@extend`
as valid per Sass spec; ensure the test harness references the same literal
"@extend .icon-#{$name};" content when relocating the file.

---

Outside diff comments:
In `@crates/biome_css_parser/src/syntax/selector/mod.rs`:
- Around line 309-328: The parser currently short-circuits SCSS placeholder
parsing in parse_simple_selector by returning parse_scss_placeholder_selector
when is_nth_at_scss_placeholder_selector is true, which bypasses feature-gating;
instead, remove the direct return and route placeholder parsing through the
conditional-syntax pattern: when is_nth_at_scss_placeholder_selector(p, 0) is
true, wrap the parse_scss_placeholder_selector(p) call in a
ConditionalParsedSyntax (or use ConditionalParsedSyntax::new/appropriate
constructor) and then call .or_invalid_to_bogus() so that if the SCSS feature is
disabled it converts to a bogus node/invalid syntax; keep references to
parse_simple_selector, is_nth_at_scss_placeholder_selector,
parse_scss_placeholder_selector, ConditionalParsedSyntax, and
or_invalid_to_bogus when making the change.

---

Nitpick comments:
In `@crates/biome_css_formatter/tests/specs/css/scss/at-rule/extend.scss`:
- Around line 1-16: Add non-rule-body contexts for `@extend` by inserting one
top-level/root statement `@extend` example and one `@extend` nested inside a
directive block (use an `@include` block) alongside the existing qualified-rule
examples; e.g., add a root-level use that extends %toolbelt and an `@include` {
`@extend` %toolbelt; } case to ensure the formatter is exercised in root statement
lists and nested directive blocks, and update the formatter snapshot tests
accordingly.

In `@crates/biome_css_formatter/tests/specs/css/scss/at-rule/import.scss`:
- Around line 1-22: Add snapshot cases to the import.scss fixture to cover the
tricky import-classification branches the formatter must handle: include imports
with query/hash like `@import` "theme.CSS?cache=1#section"; protocol-relative and
absolute URLs like `@import` "//cdn.example.com/library.css"; `@import`
"https://example.com/style.css"; and mixed forms with media lists (e.g., `@import`
"print.css" print, screen;) and url(...) variants (e.g., `@import`
url("//cdn.example.com/x.css?ver=1#a") screen;). Update
tests/specs/css/scss/at-rule/import.scss by adding these lines so the formatter
snapshot verifies CSS vs SCSS import detection for all edge cases.

In `@crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/extend.scss`:
- Around line 1-4: Add a small valid CSS rule after the malformed `@extend`
statements in extend.scss so the parser has a recovery sentinel and we can
assert it continues parsing beyond EOF; locate the broken tokens (the lines
containing the `@extend` usages: `@extend;`, `@extend !optional;`, `@extend
.message !;`, and the unterminated `@extend .message`) and append a simple valid
rule (e.g., a selector with a property declaration) to prove recovery and update
snapshots accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6580e767-0da1-4dff-855d-885e8e14167f

📥 Commits

Reviewing files that changed from the base of the PR and between b309dde and 80c31b1.

⛔ Files ignored due to path filters (21)
  • crates/biome_css_analyze/tests/specs/suspicious/noUnknownAtRules/valid.css.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/css/scss/at-rule/extend.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/import.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/extend.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/extend_interpolation.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/import.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/selector/pseudo_class/pseudo_class_function_compound_selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/selector/pseudo_class/pseudo_class_function_compound_selector_list.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/selector/pseudo_class/pseudo_class_function_relative_selector_list.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/selector/pseudo_class/pseudo_class_function_selector/disabled/pseudo_class_function_selector_disabled.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/selector/pseudo_class/pseudo_class_function_selector/enabled/pseudo_class_function_selector_enabled.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/error/selector/pseudo_class/pseudo_class_function_selector_list.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/extend.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/import.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/supports-expression.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 (42)
  • 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/css/any/simple_selector.rs
  • crates/biome_css_formatter/src/css/statements/import_at_rule.rs
  • crates/biome_css_formatter/src/generated.rs
  • crates/biome_css_formatter/src/scss/any/import_item.rs
  • crates/biome_css_formatter/src/scss/any/mod.rs
  • crates/biome_css_formatter/src/scss/auxiliary/extend_optional_modifier.rs
  • crates/biome_css_formatter/src/scss/auxiliary/mod.rs
  • crates/biome_css_formatter/src/scss/auxiliary/plain_import.rs
  • crates/biome_css_formatter/src/scss/lists/import_item_list.rs
  • crates/biome_css_formatter/src/scss/lists/mod.rs
  • crates/biome_css_formatter/src/scss/mod.rs
  • crates/biome_css_formatter/src/scss/selectors/mod.rs
  • crates/biome_css_formatter/src/scss/selectors/placeholder_selector.rs
  • crates/biome_css_formatter/src/scss/statements/extend_at_rule.rs
  • crates/biome_css_formatter/src/scss/statements/import_at_rule.rs
  • crates/biome_css_formatter/src/scss/statements/mod.rs
  • crates/biome_css_formatter/src/utils/import.rs
  • crates/biome_css_formatter/src/utils/mod.rs
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/extend.scss
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/import.scss
  • crates/biome_css_parser/src/lexer/mod.rs
  • crates/biome_css_parser/src/syntax/at_rule/import.rs
  • crates/biome_css_parser/src/syntax/at_rule/media.rs
  • crates/biome_css_parser/src/syntax/at_rule/mod.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/extend_at_rule.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/import_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/src/syntax/scss/selector.rs
  • crates/biome_css_parser/src/syntax/selector/mod.rs
  • crates/biome_css_parser/src/syntax/value/url.rs
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/extend.scss
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/extend_interpolation.scss
  • crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/import.scss
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/extend.scss
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/import.scss
  • crates/biome_css_semantic/src/semantic_model/specificity.rs
  • 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

@@ -0,0 +1 @@
@extend .icon-#{$name};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

site:sass-lang.com "@extend" interpolation Sass official docs

💡 Result:

Sass’s official docs explicitly say you can use interpolation (#{...}) inside @extend rules—i.e., the selector you’re extending can be dynamically constructed. Interpolation “can be used almost anywhere,” including “@extends.” [1]

Related official references:

  • @extend language reference (behavior/scope/limitations). [2]
  • sass:selector module: selector.extend() documents @extend-equivalent behavior and shows @extend #{$extendee}; in its definition example (interpolation used in an @extend). [5]

Move this to the valid suite—@extend with interpolation is standard Sass.

Sass docs explicitly permit interpolation in @extend selectors, and the sass:selector module even shows @extend #{$extendee}; as a valid example. Keeping .icon-#{$name} in the error suite flags a false negative.

🧰 Tools
🪛 Stylelint (17.4.0)

[error] 1-1: Expected a placeholder selector (e.g. %placeholder) to be used in @extend (scss/at-extend-no-missing-placeholder)

(scss/at-extend-no-missing-placeholder)

🤖 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/error/scss/at-rule/extend_interpolation.scss`
at line 1, The test case currently treating "@extend .icon-#{$name};" as an
error is incorrect; update the test organization by moving the case with the
interpolated selector ".icon-#{$name}" out of the error suite and into the
valid/accepted Sass test suite so the parser recognizes interpolation in `@extend`
as valid per Sass spec; ensure the test harness references the same literal
"@extend .icon-#{$name};" content when relocating the file.

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.

🧹 Nitpick comments (1)
crates/biome_css_formatter/src/scss/statements/extend_at_rule.rs (1)

16-24: Remove the redundant inner group().

The selector list is unnecessarily wrapped in group() at line 17, since the outer group() at line 31 already keeps the selector list and optional modifier together as a single unit when breaking. Other similar formatters in the codebase (page_at_rule.rs, keyframes_item.rs) use only a single group for the same purpose.

♻️ Suggested simplification
         let target = format_once(|f| {
-            write!(f, [group(&css_selector_list.format())])?;
+            write!(f, [css_selector_list.format()])?;

             if let Some(optional_modifier) = optional_modifier {
                 write!(f, [space(), optional_modifier.format()])?;
             }

             Ok(())
         });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_css_formatter/src/scss/statements/extend_at_rule.rs` around
lines 16 - 24, The selector list is wrapped twice in group(): remove the inner
group() call inside the closure that builds target so the outer group that wraps
format_once already controls breaking; specifically update the format_once
closure used to build target (the code calling format_once with write!(f,
[group(&css_selector_list.format())])?) to write the selector formatter directly
(use css_selector_list.format() without group) while leaving the outer
group(...) around the entire target/optional_modifier intact; ensure
optional_modifier handling and spacing remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/biome_css_formatter/src/scss/statements/extend_at_rule.rs`:
- Around line 16-24: The selector list is wrapped twice in group(): remove the
inner group() call inside the closure that builds target so the outer group that
wraps format_once already controls breaking; specifically update the format_once
closure used to build target (the code calling format_once with write!(f,
[group(&css_selector_list.format())])?) to write the selector formatter directly
(use css_selector_list.format() without group) while leaving the outer
group(...) around the entire target/optional_modifier intact; ensure
optional_modifier handling and spacing remain unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5af7c2c8-b938-412b-aab4-a840de1a15da

📥 Commits

Reviewing files that changed from the base of the PR and between 80c31b1 and 6f17c50.

📒 Files selected for processing (3)
  • crates/biome_css_formatter/src/scss/statements/extend_at_rule.rs
  • crates/biome_css_parser/src/syntax/at_rule/mod.rs
  • crates/biome_css_parser/src/syntax/scss/at_rule/import_at_rule.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_css_parser/src/syntax/scss/at_rule/import_at_rule.rs

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
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.

🧹 Nitpick comments (1)
crates/biome_css_parser/src/syntax/scss/at_rule/extend_at_rule.rs (1)

71-74: Consider adding lookahead for optional keyword.

The predicate only checks for ! without verifying the following token is optional. In the @extend context this works fine, but a more precise check (e.g., p.at(T![!]) && p.nth_at(1, T![optional])) could yield clearer error messages if someone mistakenly writes !important.

That said, the current approach is perfectly functional — just a thought for later polish.

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

In `@crates/biome_css_parser/src/syntax/scss/at_rule/extend_at_rule.rs` around
lines 71 - 74, is_at_scss_extend_optional_modifier currently only checks for a
bang token (p.at(T![!])) which can false-positive for sequences like
"!important"; update the predicate to ensure the bang is followed by the literal
"optional" (e.g., use p.at(T![!]) && p.nth_at(1, T![optional])) so the function
(is_at_scss_extend_optional_modifier) only returns true for the exact "@extend
!optional" modifier and yields clearer diagnostics for cases like "!important".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/biome_css_parser/src/syntax/scss/at_rule/extend_at_rule.rs`:
- Around line 71-74: is_at_scss_extend_optional_modifier currently only checks
for a bang token (p.at(T![!])) which can false-positive for sequences like
"!important"; update the predicate to ensure the bang is followed by the literal
"optional" (e.g., use p.at(T![!]) && p.nth_at(1, T![optional])) so the function
(is_at_scss_extend_optional_modifier) only returns true for the exact "@extend
!optional" modifier and yields clearer diagnostics for cases like "!important".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8c472e92-646b-4fff-94b1-2f6633fd8285

📥 Commits

Reviewing files that changed from the base of the PR and between cfc3ed7 and f689d42.

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

@denbezrukov denbezrukov merged commit b71292c into main Mar 12, 2026
19 checks passed
@denbezrukov denbezrukov deleted the db/scss-at-rule branch March 12, 2026 14:31
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