https://github.com/uxigene/stylelint-color-whitelist
Plugin for stylelint to validate color usage defined in whitelist.
https://github.com/uxigene/stylelint-color-whitelist
color color-scheme css hex hsl less linter plugin rgb sass scss stylelint stylelint-color-whitelist stylelint-plugin stylesheets stylus validation whitelist
Last synced: 8 months ago
JSON representation
Plugin for stylelint to validate color usage defined in whitelist.
- Host: GitHub
- URL: https://github.com/uxigene/stylelint-color-whitelist
- Owner: uxigene
- License: mit
- Created: 2019-05-31T11:52:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-03T10:03:00.000Z (over 6 years ago)
- Last Synced: 2025-02-14T08:49:05.932Z (8 months ago)
- Topics: color, color-scheme, css, hex, hsl, less, linter, plugin, rgb, sass, scss, stylelint, stylelint-color-whitelist, stylelint-plugin, stylesheets, stylus, validation, whitelist
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# stylelint-color-whitelist
[](https://travis-ci.org/MarinescuEvghenii/stylelint-color-whitelist) [](https://github.com/MarinescuEvghenii/stylelint-color-whitelist/blob/master/licence.md) [](https://www.npmjs.com/package/stylelint-color-whitelist) [](https://github.com/MarinescuEvghenii/stylelint-color-whitelist) [](https://github.com/MarinescuEvghenii/stylelint-color-whitelist/releases)Plugin for [stylelint](http://stylelint.io/) 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](https://stylelint.io/user-guide/) for the detailed info.## Supported formats
|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 |## License
stylelint-color-whitelist is [MIT licensed](https://github.com/MarinescuEvghenii/stylelint-color-whitelist/blob/master/licence.md).