1.0.4 • Published 5 years ago

stylelint-color-whitelist v1.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

stylelint-color-whitelist

Build Status GitHub license npm version GitHub version GitHub release

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.

Installation

Via NPM:

npm i stylelint-color-whitelist

or Yarn:

yarn add stylelint-color-whitelist

Usage

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.

Supported formats

FormatExampleSupport
HEX#fff #ffffff #FFF #ffffff88YES
RGBrgb(255, 255, 255)YES
RGBArgba(255, 255, 255, 0.5)YES
HSLhsl(0, 0%, 100%)YES
HSLAhsl(0, 0%, 100%, 1)YES
Namedred green blueNO

License

stylelint-color-whitelist is MIT licensed.