number-max-precision
What it does
Section titled “What it does”Reports a number with more decimal places than the max option.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”....i { color: red; margin: 0;}.j { width: 1.23456px; height: 10.5%; opacity: 0.12345 }Configuration
Section titled “Configuration”css: lint: rules: number-max-precision: level: warn # off (default), warn, error options: max: 4less: lint: rules: number-max-precision: level: warn # off (default), warn, error options: max: 4scss: 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.
Upstream equivalents
Section titled “Upstream equivalents”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 |