Skip to content

function-calc-no-unspaced-operator

Reports + and - inside calc() that lack whitespace on one or both sides (calc(1px+2px)), on the operator.

CSS requires whitespace around + and - in calc(); 1px+2px is read as a number with a sign, not as a sum, so the whole declaration is invalid and the browser drops it. * and / do not need the space.

To fix, put a space on each side of the operator.

Reported
...
width: calc(-#{$x} + 10px);
width: calc(10px + -#{$x});
width: calc(10px - -$x);
width: calc(10px -#{$x});
}
css:
lint:
rules:
function-calc-no-unspaced-operator: warn # off, warn (default), error
less:
lint:
rules:
function-calc-no-unspaced-operator: warn # off, warn (default), error
scss:
lint:
rules:
function-calc-no-unspaced-operator: warn # off, warn (default), error

Enabled by the presets: css/stylelint-recommended.

Suppress one line with sudsy-disable-next-line function-calc-no-unspaced-operator in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
stylelint function-calc-no-unspaced-operator full