feat(css): parse scss interpolation expressions#9472
Conversation
|
Parser conformance results onjs/262
jsx/babel
markdown/commonmark
symbols/microsoft
ts/babel
ts/microsoft
|
Merging this PR will not alter performance
Comparing Footnotes
|
WalkthroughThis PR introduces comprehensive SCSS interpolation support to the Biome CSS toolchain. It adds a new 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)
📝 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. Comment Tip CodeRabbit can suggest fixes for GitHub Check annotations.Configure the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_css_parser/src/syntax/scss/expression/interpolation.rs (1)
11-11: Please document why comma is intentionally excluded here.Line 11 is a bit of a trapdoor: adding
,later would silently break#{1, 2, 3}list parsing inside interpolation.♻️ Tiny clarity patch
-const SCSS_INTERPOLATION_END_TOKEN_SET: TokenSet<CssSyntaxKind> = token_set![T!['}'], T![;]]; +// Keep `,` out of this set so `#{1, 2, 3}` parses as a SCSS list expression. +const SCSS_INTERPOLATION_END_TOKEN_SET: TokenSet<CssSyntaxKind> = token_set![T!['}'], T![;]];🤖 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/interpolation.rs` at line 11, The constant SCSS_INTERPOLATION_END_TOKEN_SET currently omits the comma on purpose; add an inline comment above SCSS_INTERPOLATION_END_TOKEN_SET explaining that ',' is intentionally excluded because including it would break parsing of comma-separated lists inside interpolation (e.g. "#{1, 2, 3}") and thus must not be treated as an interpolation terminator; reference the constant name SCSS_INTERPOLATION_END_TOKEN_SET and the interpolation example "#{1, 2, 3}" in the comment so future maintainers understand the trapdoor.
🤖 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/interpolation.rs`:
- Line 11: The constant SCSS_INTERPOLATION_END_TOKEN_SET currently omits the
comma on purpose; add an inline comment above SCSS_INTERPOLATION_END_TOKEN_SET
explaining that ',' is intentionally excluded because including it would break
parsing of comma-separated lists inside interpolation (e.g. "#{1, 2, 3}") and
thus must not be treated as an interpolation terminator; reference the constant
name SCSS_INTERPOLATION_END_TOKEN_SET and the interpolation example "#{1, 2, 3}"
in the comment so future maintainers understand the trapdoor.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dd469dd0-57ed-4a10-9451-b4f9b3237494
⛔ Files ignored due to path filters (9)
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/expression/interpolation.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/error/scss/expression/interpolation.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/scss/expression/interpolation.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 (15)
crates/biome_css_formatter/src/generated.rscrates/biome_css_formatter/src/scss/any/expression.rscrates/biome_css_formatter/src/scss/any/expression_item.rscrates/biome_css_formatter/src/scss/auxiliary/interpolation.rscrates/biome_css_formatter/src/scss/auxiliary/mod.rscrates/biome_css_formatter/tests/specs/css/scss/expression/interpolation.scsscrates/biome_css_parser/src/lexer/tests.rscrates/biome_css_parser/src/syntax/scss/expression/interpolation.rscrates/biome_css_parser/src/syntax/scss/expression/mod.rscrates/biome_css_parser/src/syntax/scss/expression/primary.rscrates/biome_css_parser/tests/css_test_suite/error/scss/expression/interpolation.scsscrates/biome_css_parser/tests/css_test_suite/ok/scss/expression/interpolation.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 the first iteration of SCSS interpolation support to the CSS parser and formatter.
Test Plan
cargo test -p biome_css_parser/formatter