Skip to content

color-function-alias-notation

Reports rgba() and hsla(), the legacy names of rgb() and hsl(), on the function name.

Since Color Level 4 rgb() and hsl() take an optional alpha value, so the a names are aliases that exist only for old code. Two names for one function make a stylesheet read as two styles.

To fix, write rgb(0 0 0 / 50%) instead of rgba(0 0 0 / 50%).

Reported
a { color: rgba(0, 0, 0, 0.5); }
...
c { color: rgba(0 0 0 / 50%); }
...
e { color: hsl(120deg 50% 50%); }
...
g { color: hsla(120 50% 50% / 50%); }
h { color: rgb(0 0 0 / 50%); }
...
j { color: rgb(var(--x), 0.5); }
...
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-alias-notation: warn # off (default), warn, error
less:
lint:
rules:
color-function-alias-notation: warn # off (default), warn, error
scss:
lint:
rules:
color-function-alias-notation: warn # off (default), warn, error

Enabled by the presets: css/stylelint-standard.

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