feat(css): support unquoted concatenation in SCSS interpolation expressions - #10020
Conversation
|
WalkthroughThis PR enhances the SCSS formatter to properly handle unquoted concatenation scenarios. It introduces a customisable separator rule for component value list formatting, allowing callers to conditionally suppress whitespace insertion between specific adjacent items. The change specifically targets SCSS variable and interpolation pairs, preserving formatting fidelity for patterns like Possibly related PRs
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.
🧹 Nitpick comments (1)
crates/biome_css_formatter/src/utils/component_value_list.rs (1)
201-230: Minor:omit_separatoralso suppresses thePreserveInline/OnePerLine/at_group_boundaryhard-line-break paths.Because the whole
if !is_comma && !omit_separator { … }block is skipped, a future caller that combines a non-Filllayout with a predicate that returnstruewould silently drop a hard line break between those items. It's a non-issue for the SCSS expression-item-list caller (Fill, no commas between the var/interp pair), so no change is required here.If you want to future-proof, consider letting the predicate only suppress the
soft_line_break_or_space()branch while still honouring the leading-newline / group-boundary hard breaks — e.g. computeomit_separatorper-branch rather than gating the outerif. Totally optional.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_css_formatter/src/utils/component_value_list.rs` around lines 201 - 230, The current outer guard if !is_comma && !omit_separator prevents hard breaks from firing; refactor the condition so omit_separator only suppresses the soft_line_break_or_space() path while still allowing the leading-newline and group-boundary hard-line-break branches to run. Concretely, inside the block guarded by if !is_comma { … } (use is_comma_delimiter(&element) to compute is_comma) keep the PreserveInline/OnePerLine branch and the at_group_boundary branch checking element.syntax().has_leading_newline() and at_group_boundary respectively and write hard_line_break()/space() as before, but only gate the final soft_line_break_or_space() call on !omit_separator (use the existing omit_separator variable) so omit_separator prevents only soft-line separators and not hard-line-breaks.
🤖 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/utils/component_value_list.rs`:
- Around line 201-230: The current outer guard if !is_comma && !omit_separator
prevents hard breaks from firing; refactor the condition so omit_separator only
suppresses the soft_line_break_or_space() path while still allowing the
leading-newline and group-boundary hard-line-break branches to run. Concretely,
inside the block guarded by if !is_comma { … } (use is_comma_delimiter(&element)
to compute is_comma) keep the PreserveInline/OnePerLine branch and the
at_group_boundary branch checking element.syntax().has_leading_newline() and
at_group_boundary respectively and write hard_line_break()/space() as before,
but only gate the final soft_line_break_or_space() call on !omit_separator (use
the existing omit_separator variable) so omit_separator prevents only soft-line
separators and not hard-line-breaks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0a1b8a43-2dc0-464c-bb72-01fd3c97bb48
⛔ Files ignored due to path filters (3)
crates/biome_css_formatter/tests/specs/css/scss/declaration/unquoted-concatenation.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/scss/value/list.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_parser/tests/css_test_suite/ok/scss/value/unquoted-concatenation.scss.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (5)
crates/biome_css_formatter/src/scss/lists/expression_item_list.rscrates/biome_css_formatter/src/utils/component_value_list.rscrates/biome_css_formatter/tests/specs/css/scss/declaration/unquoted-concatenation.scsscrates/biome_css_parser/tests/css_test_suite/ok/scss/value/list.scsscrates/biome_css_parser/tests/css_test_suite/ok/scss/value/unquoted-concatenation.scss
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Fixes SCSS formatting for unquoted interpolation concatenation.
Biome no longer inserts spaces into forms such as
$variable#{something},#{something}$variable,$a#{b}$c, and#{a}$b#{c}. These values now keep their direct adjacency when formatted.Test Plan
new snapshots