stylelint-gamut 1.0.2 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +13 -10
  2. package/package.json +1 -1
  3. package/src/index.js +3 -6
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # stylelint-gamut
2
- Stylelint plugin for working with different color spaces.
2
+
3
+ **stylelint-gamut** is a [Stylelint] plugin that helps you to work with different color spaces.
4
+
5
+ Right now it's working with **node version ≥ 16.0.0**.
3
6
 
4
7
  # Installation
5
8
 
@@ -17,21 +20,21 @@ npm install stylelint-gamut --save-dev
17
20
 
18
21
  ## Usage
19
22
 
20
- Add `stylelint-gamut` to your Stylelint config `plugins` array, then add rules you need to the rules list. All rules from stylelint-gamut need to be namespaced with `gamut`.
23
+ Add `stylelint-gamut` to your Stylelint config `plugins` array, then add rules you need to the rules list. All rules from `stylelint-gamut` need to be namespaced with `gamut`.
21
24
 
22
25
  ```json
23
26
  {
24
- "plugins": [
25
- "stylelint-gamut"
26
- ],
27
- "rules": {
28
- "gamut/color-no-out-gamut-range": true,
29
- }
27
+ "plugins": [
28
+ "stylelint-gamut"
29
+ ],
30
+ "rules": {
31
+ "gamut/color-no-out-gamut-range": true,
32
+ }
30
33
  }
31
34
  ```
32
35
 
33
36
  ## Rules
34
37
 
35
- * [`color-no-out-gamut-range`](./src/README.md): Throw warning if color goes out of sRGB color space and is not wrapped in @media (color-gamut: p3) {}.
38
+ * [`color-no-out-gamut-range`](./src/README.md): Throw warning if color goes out of sRGB color space and is not wrapped in `@media (color-gamut: p3) {}`.
36
39
 
37
- [Stylelint]: https://stylelint.io/
40
+ [Stylelint]: https://stylelint.io/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylelint-gamut",
3
- "version": "1.0.2",
3
+ "version": "1.1.2",
4
4
  "description": "Stylelint plugin for working with different color spaces",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -19,6 +19,8 @@ const meta = {
19
19
  url: 'https://stylelint.io/user-guide/rules/list/color-no-out-gamut-range'
20
20
  }
21
21
 
22
+ const COLOR_FUNCTIONS = new Set(['lch', 'lab', 'oklch', 'oklab'])
23
+
22
24
  /** @type {import('stylelint').Rule} */
23
25
  const ruleFunction = (primary) => {
24
26
  return (root, result) => {
@@ -40,12 +42,7 @@ const ruleFunction = (primary) => {
40
42
  parsedValue.walk((node, _index, nodes) => {
41
43
  if (node.type !== 'function') return
42
44
 
43
- if (
44
- node.value !== 'lch' &&
45
- node.value !== 'lab' &&
46
- node.value !== 'oklch' &&
47
- node.value !== 'oklab'
48
- ) {
45
+ if (!COLOR_FUNCTIONS.has(node.value)) {
49
46
  return
50
47
  }
51
48