Skip to content

color-no-hex

Reports a hex color (#fff).

Some projects use named colors or functions only, so a color can be told by its name or channels, not by a code that has to be decoded. The rule is a policy for those; it is off by default.

To fix, write the color as a name or with rgb(), hsl() or another function.

Reported
...
width: calc(0px + 1px);
...
color: #aabbcc;
color: #abc;
border-color: #ab #abcde #abcdef;
...
css:
lint:
rules:
color-no-hex: warn # off (default), warn, error
less:
lint:
rules:
color-no-hex: warn # off (default), warn, error
scss:
lint:
rules:
color-no-hex: warn # off (default), warn, error

Suppress one line with sudsy-disable-next-line color-no-hex 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 color-no-hex full