alpha-value-notation
What it does
Section titled “What it does”Reports the alpha value of rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() or color() written as a number (/ 0.5), also the fourth argument of the comma form of rgba() and hsla(), on the function name. A percentage is not reported.
Why it matters
Section titled “Why it matters”An alpha value can be a number or a percentage, and a file that mixes both makes the reader convert in the head: 0.5 and 50% are the same. The rule keeps one notation, the percentage, which reads as a share of opacity and matches how the channels of hsl() are written.
To fix, write / 50% instead of / 0.5.
Example
Section titled “Example”a { color: rgba(0, 0, 0, 0.5); }...d { color: rgb(0 0 0 / 0.5); }e { color: hsl(120deg 50% 50%); }...h { color: rgb(0 0 0 / 50%); }i { color: hsl(120 50% 50% / 0.5); }j { color: rgb(var(--x), 0.5); }k { 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); }Configuration
Section titled “Configuration”css: lint: rules: alpha-value-notation: warn # off (default), warn, errorless: lint: rules: alpha-value-notation: warn # off (default), warn, errorscss: lint: rules: alpha-value-notation: warn # off (default), warn, errorEnabled by the presets: css/stylelint-standard.
Suppress one line with sudsy-disable-next-line alpha-value-notation in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| stylelint | alpha-value-notation |
full |