Menu

A minus sign before an SCSS interpolation that Biome read as math
📰

A minus sign before an SCSS interpolation that Biome read as math

DEV Community: css·Ashok Ram·about 14 hours ago
#wG7CMX4q
#devtocss#devto#dev#unary#sass
Long article (838 words) — no AI summary yet.
Reading 0:00
15s threshold

Minus signs in SCSS are a little tricky. $a - $b is a subtraction, -$b is a negative value, and 1px 2px is a list. A formatter has to read every minus sign exactly the way Sass does, or it quietly changes your CSS.

That's what issue #12957 was about. The reporter had this:

$s : 8px ; .a { margin : - # { $s } - # { $s } - # { $s } auto ; }

Enter fullscreen mode

Exit fullscreen mode

and Biome formatted the value as -#{$s} - #{$s} - #{$s} auto . Looks like a spacing tweak. It isn't. The reporter checked with Dart Sass: the original compiles to margin: -8px -8px -8px auto; , the formatted file to margin: -8px-8px-8px auto; . That's invalid CSS, so the browser drops the whole declaration.

I picked it up, and the fix was merged in biomejs/biome#12983 .

Why it happened

The formatter wasn't really the problem. It prints the tree the parser gives it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.