Skip to content

feat(css): add scss keyword and arbitrary arguments#9227

Merged
denbezrukov merged 2 commits intomainfrom
db/arbitary-argument
Feb 24, 2026
Merged

feat(css): add scss keyword and arbitrary arguments#9227
denbezrukov merged 2 commits intomainfrom
db/arbitary-argument

Conversation

@denbezrukov
Copy link
Contributor

Summary

Adds SCSS keyword and arbitrary argument support in function call argument context.

  • $name: value and $args... as SCSS expression items in arguments.

Test Plan

  • cargo test -p biome_css_parser -p biome_css_formatter

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2026

⚠️ No Changeset found

Latest commit: 9ecb514

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 Feb 24, 2026
@github-actions
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 52915 52915 0
Passed 51695 51695 0
Failed 1178 1178 0
Panics 42 42 0
Coverage 97.69% 97.69% 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 5464 5464 0
Passed 1915 1915 0
Failed 3549 3549 0
Panics 0 0 0
Coverage 35.05% 35.05% 0.00%

ts/babel

Test result main count This PR count Difference
Total 635 635 0
Passed 567 567 0
Failed 68 68 0
Panics 0 0 0
Coverage 89.29% 89.29% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18871 18871 0
Passed 13012 13012 0
Failed 5858 5858 0
Panics 1 1 0
Coverage 68.95% 68.95% 0.00%

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 24, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 187 skipped benchmarks1


Comparing db/arbitary-argument (9ecb514) with main (9cad748)

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 Feb 24, 2026

Walkthrough

Adds parsing and formatting support for two new SCSS constructs: ScssArbitraryArgument and ScssKeywordArgument. Changes include grammar additions, lexer adjustments for SCSS ellipsis and tokens, parser updates with SCSS expression options and argument parsing, new formatter node rules and wiring into any-expression dispatch, generated-kind mappings, and tests for keyword/variadic argument contexts.

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 title clearly and concisely describes the main change: adding SCSS keyword and arbitrary argument support. It accurately reflects the changeset's primary objective.
Description check ✅ Passed The description is directly related to the changeset, explaining the addition of SCSS keyword and arbitrary argument support in function call contexts with concrete examples.

✏️ 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/arbitary-argument

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.

🧹 Nitpick comments (2)
xtask/codegen/src/css_kinds_src.rs (1)

575-576: Minor ordering nitSCSS_KEYWORD_ARGUMENT is listed before SCSS_ARBITRARY_ARGUMENT, which is the reverse of alphabetical order. The SCSS section here isn't strictly sorted, so no functional impact, but the rest of the codebase (e.g. generated_mappings.rs, expression_item.rs) lists Arbitrary before Keyword. Worth flipping for consistency, but totally optional.

🔀 Suggested order
-        "SCSS_KEYWORD_ARGUMENT",
-        "SCSS_ARBITRARY_ARGUMENT",
+        "SCSS_ARBITRARY_ARGUMENT",
+        "SCSS_KEYWORD_ARGUMENT",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@xtask/codegen/src/css_kinds_src.rs` around lines 575 - 576, Minor ordering
mismatch: swap "SCSS_KEYWORD_ARGUMENT" and "SCSS_ARBITRARY_ARGUMENT" in the SCSS
list so that SCSS_ARBITRARY_ARGUMENT comes before SCSS_KEYWORD_ARGUMENT; locate
the SCSS enum/array in css_kinds_src.rs (the entries "SCSS_KEYWORD_ARGUMENT" and
"SCSS_ARBITRARY_ARGUMENT") and reorder those two entries to match the rest of
the codebase's alphabetical/Arbitrary-before-Keyword convention.
crates/biome_css_parser/src/syntax/scss/expression/mod.rs (1)

136-168: Subtle CST concern on the standalone ... error path.

Lines 145–150: when ... appears without a preceding expression, the token is bumped and Absent is returned. The bumped ... token won't be wrapped in any child node — it becomes a bare token inside SCSS_EXPRESSION_ITEM_LIST. The recovery layer then runs on Absent but the token is already consumed.

This is fine for error recovery (parser advances, diagnostic emitted), but the unattached token could confuse downstream consumers of the CST. Consider wrapping it in a bogus node instead:

Possible approach
         Absent => {
             if p.at(T![...]) {
+                let bogus = p.start();
                 let range = p.cur_range();
                 p.error(scss_ellipsis_not_allowed(p, range));
                 p.bump(T![...]);
+                return Present(bogus.complete(p, CSS_BOGUS_PROPERTY_VALUE));
             }
             return Absent;
         }
🤖 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/expression/mod.rs` around lines 136 -
168, When `T![...]` appears with no preceding expression in
parse_scss_expression_item, don't just bump and return Absent (which leaves the
token unattached); instead, create and complete a small bogus node that contains
the `...` token so the token is represented in the CST. Concretely, in
parse_scss_expression_item where the match arm currently does p.error(...);
p.bump(T![...]); return Absent;, use the parser node API (start/precede +
complete) to wrap the bumped `T![...]` into a completed node (e.g.,
SCSS_BOGUS_EXPRESSION or a clearly named bogus/placeholder node) and return
Present of that node while still emitting the same scss_ellipsis_not_allowed
error; ensure you use the same parser helpers used elsewhere (precede/complete
or start/complete) so the node is attached under SCSS_EXPRESSION_ITEM_LIST.
🤖 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/expression/mod.rs`:
- Around line 136-168: When `T![...]` appears with no preceding expression in
parse_scss_expression_item, don't just bump and return Absent (which leaves the
token unattached); instead, create and complete a small bogus node that contains
the `...` token so the token is represented in the CST. Concretely, in
parse_scss_expression_item where the match arm currently does p.error(...);
p.bump(T![...]); return Absent;, use the parser node API (start/precede +
complete) to wrap the bumped `T![...]` into a completed node (e.g.,
SCSS_BOGUS_EXPRESSION or a clearly named bogus/placeholder node) and return
Present of that node while still emitting the same scss_ellipsis_not_allowed
error; ensure you use the same parser helpers used elsewhere (precede/complete
or start/complete) so the node is attached under SCSS_EXPRESSION_ITEM_LIST.

In `@xtask/codegen/src/css_kinds_src.rs`:
- Around line 575-576: Minor ordering mismatch: swap "SCSS_KEYWORD_ARGUMENT" and
"SCSS_ARBITRARY_ARGUMENT" in the SCSS list so that SCSS_ARBITRARY_ARGUMENT comes
before SCSS_KEYWORD_ARGUMENT; locate the SCSS enum/array in css_kinds_src.rs
(the entries "SCSS_KEYWORD_ARGUMENT" and "SCSS_ARBITRARY_ARGUMENT") and reorder
those two entries to match the rest of the codebase's
alphabetical/Arbitrary-before-Keyword convention.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between edb536a and 637e6ab.

⛔ Files ignored due to path filters (8)
  • 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_parser/tests/css_test_suite/ok/scss/expression/keyword-argument-context.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/value/keyword-args-ellipsis.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 (16)
  • crates/biome_css_formatter/src/generated.rs
  • crates/biome_css_formatter/src/scss/any/expression.rs
  • crates/biome_css_formatter/src/scss/any/expression_item.rs
  • crates/biome_css_formatter/src/scss/auxiliary/arbitrary_argument.rs
  • crates/biome_css_formatter/src/scss/auxiliary/keyword_argument.rs
  • crates/biome_css_formatter/src/scss/auxiliary/mod.rs
  • crates/biome_css_parser/src/lexer/mod.rs
  • crates/biome_css_parser/src/syntax/parse_error.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.rs
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/expression/keyword-argument-context.scss
  • crates/biome_css_parser/tests/css_test_suite/ok/scss/value/keyword-args-ellipsis.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

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

🧹 Nitpick comments (1)
crates/biome_css_parser/src/lexer/mod.rs (1)

1145-1204: Consider not gating // lexing on parser options.

Right now allow_wrong_line_comments changes token emission, which can hide invalid syntax and reduce diagnostic quality. Consider always lexing line comments and surfacing a diagnostic when not permitted.

Based on learnings, "In the Biome CSS parser, lexer token emission should not be gated behind parser options like is_tailwind_directives_enabled(). The lexer must emit correct tokens regardless of parser options to enable accurate diagnostics and error messages when the syntax is used incorrectly."

🤖 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/lexer/mod.rs`:
- Around line 251-277: The rustdoc examples in the comments for the methods
is_scss and is_line_comment_enabled are plain code blocks and must be converted
into doctest format; change the examples to fenced ```rust blocks containing
small, compilable assertions (e.g., create a string like let scss = "@if $a ==
$b { `@include` foo($args...); }"; assert!(scss.contains("...")); and let scss =
"// overrides\n$color: red;"; assert!(scss.starts_with("//"));), so the doc
comments become runnable doctests and satisfy the repo guideline.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 637e6ab and 9ecb514.

📒 Files selected for processing (2)
  • crates/biome_css_parser/src/lexer/mod.rs
  • crates/biome_css_parser/src/syntax/value/function.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_css_parser/src/syntax/value/function.rs

Comment on lines +251 to +277
/// Returns true when lexing SCSS so SCSS-only tokens (`==`, `!=`, `...`, `//`) are enabled.
///
/// Example:
/// ```scss
/// @if $a == $b { @include foo($args...); }
/// ```
///
/// Docs: https://sass-lang.com/documentation/operators
#[inline]
fn is_scss(&self) -> bool {
self.source_type.is_scss()
}

/// Enables `//` line-comment lexing only for SCSS (or permissive mode), since
/// plain CSS treats `//` as two delimiters, not a comment.
///
/// Example:
/// ```scss
/// // overrides
/// $color: red;
/// ```
///
/// Docs: https://sass-lang.com/documentation/syntax/comments
#[inline]
fn is_line_comment_enabled(&self) -> bool {
self.options.allow_wrong_line_comments || self.is_scss()
}
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 | 🟡 Minor

Convert the rustdoc examples to doctest format.

These code blocks are in rustdoc but aren’t in doctest form. This breaks the repo guideline and leaves the examples unverified.

💡 Proposed update
-    /// ```scss
-    /// `@if` $a == $b { `@include` foo($args...); }
-    /// ```
+    /// ```rust
+    /// let scss = "@if $a == $b { `@include` foo($args...); }";
+    /// assert!(scss.contains("..."));
+    /// ```
-    /// ```scss
-    /// // overrides
-    /// $color: red;
-    /// ```
+    /// ```rust
+    /// let scss = "// overrides\n$color: red;";
+    /// assert!(scss.starts_with("//"));
+    /// ```

As per coding guidelines, "Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests".

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

In `@crates/biome_css_parser/src/lexer/mod.rs` around lines 251 - 277, The rustdoc
examples in the comments for the methods is_scss and is_line_comment_enabled are
plain code blocks and must be converted into doctest format; change the examples
to fenced ```rust blocks containing small, compilable assertions (e.g., create a
string like let scss = "@if $a == $b { `@include` foo($args...); }";
assert!(scss.contains("...")); and let scss = "// overrides\n$color: red;";
assert!(scss.starts_with("//"));), so the doc comments become runnable doctests
and satisfy the repo guideline.

@denbezrukov denbezrukov merged commit 97c92a1 into main Feb 24, 2026
18 checks passed
@denbezrukov denbezrukov deleted the db/arbitary-argument branch February 24, 2026 20:07
@Netail Netail added the L-SCSS Language: SCSS label Feb 24, 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-Parser Area: parser A-Tooling Area: internal tools L-CSS Language: CSS L-Grit Language: GritQL L-SCSS Language: SCSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants