Skip to content

color-function-notation

Reports rgb(), rgba(), hsl() or hsla() with the legacy comma-separated arguments (rgb(0, 0, 0)), also when one argument is a call such as var(). The space-separated form (rgb(0 0 0)) is not reported.

The modern notation separates the channels with spaces and the alpha value with /, the way every other color function of Color Level 4 (lab(), oklch(), color()) does, so one rule of writing covers them all. The comma form is kept only for old browsers.

To fix, replace the commas with spaces and put / before the alpha value.

Reported
a { color: rgba(0, 0, 0, 0.5); }
b { color: rgb(0, 0, 0); }
...
e { color: hsl(120deg 50% 50%); }
f { color: hsl(120, 50%, 50%); }
...
h { color: rgb(0 0 0 / 50%); }
...
m { color: oklch(50% 0.2 120deg / 50%); }
n { color: rgb(0 0 0); }
o { color: hsla(var(--h), var(--s), var(--l), 1); }
css:
lint:
rules:
color-function-notation: warn # off (default), warn, error
less:
lint:
rules:
color-function-notation: warn # off (default), warn, error
scss:
lint:
rules:
color-function-notation: warn # off (default), warn, error

Enabled by the presets: css/stylelint-standard.

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