Skip to main content

function-calc-no-unspaced-operator

禁止 数学函数 中的无效无空格运算符,例如 calc()min()

¥Disallow invalid unspaced operator within math functions, such as calc() or min().

a { top: calc(1px + 2px); }
/** ↑

* The space around this operator */

此规则检查 +- 运算符之前是否有单个空格或换行符加缩进,以及该运算符之后是否有单个空格或换行符。

¥This rule checks that there is a single whitespace or a newline plus indentation before the + or - operator, and a single whitespace or a newline after that operator.

fix 选项 可以自动修复此规则报告的所有问题。

¥The fix option can automatically fix all of the problems reported by this rule.

选项

¥Options

true

以下模式被视为问题:

¥The following patterns are considered problems:

a { top: calc(1px+2px); }
a { top: calc(1px+ 2px); }
a { transform: rotate(atan(-2+1)); }

以下模式不被视为问题:

¥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));
}