You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[SCSS] Put unary boolean operator in front of expression when wrapping #16232
@if ($verylonglonglonglonglonglonglonglonglonglonglonglonglonglongvariabletoforceabreak and $a and not $b) {
color: red;
}
Output:
@if (
$verylonglonglonglonglonglonglonglonglonglonglonglonglonglongvariabletoforceabreak and
$a and not
$b
) {
color: red;
}
Expected behavior:
@if (
$verylonglonglonglonglonglonglonglonglonglonglonglonglonglongvariabletoforceabreak and
$a and
not $b
) {
color: red;
}
Hi,
It is pretty confusing, that the unary not is placed in the line above instead of in front of the expression it is affecting.
That makes it really hard to read long if statements with multiple terms correctly.
This seems like a canonical way to write a conjunctive normal form, as every boolean segment is in one line, including their identity check or unary operators.
@guilhermetod I would like your proposal even more. 👍
Edit: one of the big advantages of your proposal is that you only have on changed line when adding a new term to the @if. Same argument as trailing commas, basically.
@mixin fluid-prop($property, $min-vw, $max-vw, $min-value, $max-value){@if $property != null {@iftype-of($min-value)=="number" and not unitless($min-value){#{$property}: $min-value; // Fallback for older browsers
}@iftype-of($min-vw)=="number" and not unitless($min-value) and
type-of($max-vw)=="number" and
not unitless($min-value) and
type-of($min-value)=="number" and
not unitless($min-value) and
type-of($max-value)=="number" and
not unitless($min-value) and
unit($min-vw)== unit($max-vw)and
unit($min-vw)== unit($min-value)and
unit($min-vw)== unit($max-value){
$factor: math.div(1, $max-vw - $min-vw)*($max-value - $min-value);
$calc-value: unquote("#{$min-value - ($min-vw * $factor)} + #{100vw * $factor}");#{$property}:clamp(#{if($min-value > $max-value, $max-value, $min-value)},#{$calc-value},#{if($min-value > $max-value, $min-value, $max-value)});}}}
Activity
apfelbox commentedon Apr 25, 2024
Actually, looking deeper into it, the whole segmentation of the CNF seems pretty chopped up:
Prettier 3.2.5
Playground link
Input:
Output:
Expected output:
Why?
This seems like a canonical way to write a conjunctive normal form, as every boolean segment is in one line, including their identity check or unary operators.
guilhermetod commentedon Apr 29, 2024
Given #3806 is also highly requested, i suggest going for another strategy:
apfelbox commentedon Apr 29, 2024
@guilhermetod I would like your proposal even more. 👍
Edit: one of the big advantages of your proposal is that you only have on changed line when adding a new term to the
@if. Same argument as trailing commas, basically.g-plane commentedon May 18, 2024
Would you like to give a try to Malva (another CSS formatter)? It supports both @apfelbox 's and @guilhermetod 's suggestions with configuration.
Input
When
operatorLinebreakis"after"It formats as @apfelbox suggests.
playground
When
operatorLinebreakis"before"It formats as @guilhermetod suggests.
playground
Complex input
It also works with #16232 (comment) . Result:
playground