Skip to content

hue-degree-notation

Reports the hue of hsl(), hsla(), hwb(), lch() or oklch() written as a bare number (120), on the function name. A hue with a unit (120deg) is not reported.

A hue is an angle, and without a unit 120 does not say if it is degrees, radians or turns; CSS reads it as degrees, but the next reader has to know that. Writing 120deg makes the value self-describing and matches the other angle properties.

To fix, add deg to the number.

Reported
...
e { color: hsl(120deg 50% 50%); }
f { color: hsl(120, 50%, 50%); }
g { color: hsla(120 50% 50% / 50%); }
h { color: rgb(0 0 0 / 50%); }
i { color: hsl(120 50% 50% / 0.5); }
j { color: rgb(var(--x), 0.5); }
...
l { color: oklch(50% 0.2 120); }
m { color: oklch(50% 0.2 120deg / 50%); }
n { color: rgb(0 0 0); }
...
css:
lint:
rules:
hue-degree-notation: warn # off (default), warn, error
less:
lint:
rules:
hue-degree-notation: warn # off (default), warn, error
scss:
lint:
rules:
hue-degree-notation: warn # off (default), warn, error

Enabled by the presets: css/stylelint-standard.

Suppress one line with sudsy-disable-next-line hue-degree-notation 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 hue-degree-notation full