Skip to content

number-max-precision

Reports a number with more decimal places than the max option.

Long decimals (1.23456789px) are almost always the output of a calculator, and a browser rounds lengths to a fraction of a pixel anyway, so the extra digits only add bytes and noise.

To fix, round the number to the precision that is needed.

Reported
...
.i {
color: red; margin: 0;
}
.j { width: 1.23456px; height: 10.5%; opacity: 0.12345 }
css:
lint:
rules:
number-max-precision:
level: warn # off (default), warn, error
options:
max: 4
less:
lint:
rules:
number-max-precision:
level: warn # off (default), warn, error
options:
max: 4
scss:
lint:
rules:
number-max-precision:
level: warn # off (default), warn, error
options:
max: 4
Option Type Default Description
max int 4 The most decimal places a number may have.

Enabled by the presets: css/stylelint-standard.

Suppress one line with sudsy-disable-next-line number-max-precision in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
stylelint number-max-precision partial numbers in a Less variable declaration (an at-rule prelude) are not checked, named gap