feat(css): add support for SCSS @function and @return at-rules#9431
feat(css): add support for SCSS @function and @return at-rules#9431denbezrukov merged 4 commits intomainfrom
@function and @return at-rules#9431Conversation
|
Parser conformance results onjs/262
jsx/babel
markdown/commonmark
symbols/microsoft
ts/babel
ts/microsoft
|
Merging this PR will not alter performance
Comparing Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR adds SCSS support for two at-rules: Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 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: 2
🧹 Nitpick comments (1)
crates/biome_css_parser/src/lexer/tests.rs (1)
312-341: Add aRETURNS_KWcheck while you’re here.
returnandreturnsare easy neighbours to trip over. One extra assertion would make this smoke test a bit less trusting.🧪 Tiny follow-up
- "media keyframes important from through sass each debug warn error for function include mixin return", + "media keyframes important from through sass each debug warn error for function include mixin return returns", @@ - RETURN_KW:6 + RETURN_KW:6, + WHITESPACE:1, + RETURNS_KW:7🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_css_parser/src/lexer/tests.rs` around lines 312 - 341, Add an additional assertion for the "returns" keyword in the token counts: locate the token list in crates/biome_css_parser/src/lexer/tests.rs (the block containing RETURN_KW:6) and add a RETURNS_KW entry with an appropriate count (e.g., RETURNS_KW:7) and a following WHITESPACE:1 to mirror the existing pattern (so the sequence includes RETURN_KW:6, WHITESPACE:1, RETURNS_KW:7, WHITESPACE: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_formatter/src/scss/statements/function_at_rule.rs`:
- Around line 17-27: The formatting emits an unconditional space between the
name and the block even when `parameters: Option<ScssParameterList>` is None,
causing a double space; update the formatter in the `write!(..., [
function_token.format(), space(), name.format(), parameters.format(), space(),
block.format() ])` sequence so the space before `block.format()` is only emitted
when `parameters` is Some — e.g., conditionally include the `space()` element
(or replace `parameters.format()` with a compact conditional that includes the
preceding space) so that when `parameters` is None you get a single space
between `name` and `block`.
In `@crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/return.scss`:
- Around line 1-2: The test fixture contains top-level `@return` statements
which are invalid per the Sass spec ( `@return` is only allowed inside
`@function` bodies ); update the test so the top-level `@return 42;` and
`@return $width * 2;` are moved from the `ok` suite into the `error` suite (or
replace one with a valid case by wrapping it inside a proper `@function`
definition) so that `@return` appears only inside `@function` bodies in any `ok`
fixtures and top-level `@return` examples live in the error fixtures.
---
Nitpick comments:
In `@crates/biome_css_parser/src/lexer/tests.rs`:
- Around line 312-341: Add an additional assertion for the "returns" keyword in
the token counts: locate the token list in
crates/biome_css_parser/src/lexer/tests.rs (the block containing RETURN_KW:6)
and add a RETURNS_KW entry with an appropriate count (e.g., RETURNS_KW:7) and a
following WHITESPACE:1 to mirror the existing pattern (so the sequence includes
RETURN_KW:6, WHITESPACE:1, RETURNS_KW:7, WHITESPACE:1).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a7221914-3876-4da2-91ef-5368d219367d
⛔ Files ignored due to path filters (13)
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/css/scss/at-rule/function.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_formatter/tests/specs/css/scss/at-rule/return.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/error/at_rule/at_rule_function_error.css.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/function.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/return.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/function.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/return.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_syntax/src/generated/kind.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_syntax/src/generated/macros.rsis excluded by!**/generated/**,!**/generated/**and 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 (26)
crates/biome_css_formatter/src/css/any/at_rule.rscrates/biome_css_formatter/src/generated.rscrates/biome_css_formatter/src/scss/statements/function_at_rule.rscrates/biome_css_formatter/src/scss/statements/mod.rscrates/biome_css_formatter/src/scss/statements/return_at_rule.rscrates/biome_css_formatter/tests/specs/css/scss/at-rule/function.scsscrates/biome_css_formatter/tests/specs/css/scss/at-rule/return.scsscrates/biome_css_parser/src/lexer/mod.rscrates/biome_css_parser/src/lexer/tests.rscrates/biome_css_parser/src/syntax/at_rule/mod.rscrates/biome_css_parser/src/syntax/scss/at_rule/function_at_rule.rscrates/biome_css_parser/src/syntax/scss/at_rule/mixin_at_rule.rscrates/biome_css_parser/src/syntax/scss/at_rule/mod.rscrates/biome_css_parser/src/syntax/scss/at_rule/parameter.rscrates/biome_css_parser/src/syntax/scss/at_rule/return_at_rule.rscrates/biome_css_parser/src/syntax/scss/mod.rscrates/biome_css_parser/tests/css_test_suite/error/at_rule/at_rule_function_error.css.snap.newcrates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/function.scsscrates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/function.scss.snap.newcrates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/return.scsscrates/biome_css_parser/tests/css_test_suite/error/scss/at-rule/return.scss.snap.newcrates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/function.scsscrates/biome_css_parser/tests/css_test_suite/ok/scss/at-rule/return.scsscrates/biome_grit_patterns/src/grit_target_language/css_target_language/generated_mappings.rsxtask/codegen/css.ungramxtask/codegen/src/css_kinds_src.rs
Summary
Adds SCSS
@functionand@returnat-rule support to the CSS parser and formatter.Test Plan