Plugin for stylelint to validate color usage defined in whitelist. Plugin transforms all colors to HEX format. So, for declared #fff
color, the rgb(255, 255, 255)
is also valid. Please note that it ignores the opacity, for example: rgba(255, 255, 255, 0.5)
, #ffffff80
, hsla(0, 0%, 100%, 0.5)
are also a valid colors.
Via NPM:
npm i stylelint-color-whitelist
or Yarn:
yarn add stylelint-color-whitelist
Add stylelint-color-whitelist
to the plugins array.
Add color/whitelist
rule config to the rules section.
Note: Configuration array can get only hex values.
{
"plugins": ["stylelint-color-whitelist"],
"rules": {
"color/whitelist": {
"color": ["#fff"] // Only hex values
}
}
}
Refer to stylelint docs for the detailed info.
Format | Example | Support |
---|---|---|
HEX | #fff #ffffff #FFF #ffffff88 |
YES |
RGB | rgb(255, 255, 255) |
YES |
RGBA | rgba(255, 255, 255, 0.5) |
YES |
HSL | hsl(0, 0%, 100%) |
YES |
HSLA | hsl(0, 0%, 100%, 1) |
YES |
Named | red green blue |
NO |
stylelint-color-whitelist is MIT licensed.