Disallow an unspaced operator within calc
functions.
a { top: calc(1px + 2px); }
/** ↑
* The space around this operator */
Before the operator, there must be a single whitespace or a newline plus indentation. After the operator, there must be a single whitespace or a newline.
Note: The *
and /
operators do not require whitespace (but it is usually recommened for consistency).
The fix
option can automatically fix all of the problems reported by this rule.
The following patterns are considered problems:
a { top: calc(1px+2px); }
a { top: calc(1px+ 2px); }
The following patterns are not considered problems:
a { top: calc(1px + 2px); }
a { top: calc(calc(1em * 2) / 3); }
a { top: calc(calc(1em*2)/3); }
a {
top: calc(var(--foo) +
var(--bar));
}
a {
top: calc(var(--foo)
+ var(--bar));
}