stylelint-gamut 1.0.1 → 1.1.1

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.
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # stylelint-gamut
2
2
  Stylelint plugin for working with different color spaces.
3
+ Right now it's working with node version >= 16.0.0.
3
4
 
4
5
  # Installation
5
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylelint-gamut",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
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,8 +19,10 @@ 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
- module.exports = stylelint.createPlugin(ruleName, (primary) => {
25
+ const ruleFunction = (primary) => {
24
26
  return (root, result) => {
25
27
  const validOptions = stylelint.utils.validateOptions(result, ruleName, {
26
28
  actual: primary
@@ -40,12 +42,7 @@ module.exports = stylelint.createPlugin(ruleName, (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
 
@@ -71,7 +68,7 @@ module.exports = stylelint.createPlugin(ruleName, (primary) => {
71
68
  })
72
69
  })
73
70
  }
74
- })
71
+ }
75
72
 
76
73
  /**
77
74
  * @param {import('postcss').Declaration} decl
@@ -87,6 +84,8 @@ function isInColorGamutP3MediaQuery (decl) {
87
84
  return false
88
85
  }
89
86
 
90
- module.exports.ruleName = ruleName
91
- module.exports.messages = messages
92
- module.exports.meta = meta
87
+ ruleFunction.ruleName = ruleName
88
+ ruleFunction.messages = messages
89
+ ruleFunction.meta = meta
90
+
91
+ module.exports = stylelint.createPlugin(ruleName, ruleFunction)
package/src/index.test.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { messages, ruleName } = require('./index.js')
3
+ const { rule: { messages, ruleName } } = require('./index.js')
4
4
 
5
5
  testRule({
6
6
  ruleName,