Skip to content

unit-disallowed-list

Reports a unit (% included) that is in the list option, in values and at-rule preludes.

A project can forbid a unit that does not fit its design, for example px where text has to follow the user’s font size. The rule is a policy: with no list it reports nothing.

Reported
...
@media (min-width: 40em) and (color) {
a { float: left; width: 1em }
}
a:hover::before > b[style] { color: red; width: calc(1px + 2px); --x: 1em }
.c { margin: 0 0 1px 2em; height: 50%; font-size: 12PX }
css:
lint:
rules:
unit-disallowed-list:
level: warn # off (default), warn, error
options:
list: []
less:
lint:
rules:
unit-disallowed-list:
level: warn # off (default), warn, error
options:
list: []
scss:
lint:
rules:
unit-disallowed-list:
level: warn # off (default), warn, error
options:
list: []
Option Type Default Description
list list [] The disallowed units: names, or /regex/.

Suppress one line with sudsy-disable-next-line unit-disallowed-list 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 unit-disallowed-list full