stylelint-gamut 1.2.7 → 1.3.0

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/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "stylelint-gamut",
3
- "version": "1.2.7",
3
+ "version": "1.3.0",
4
4
  "description": "Stylelint plugin for working with different color spaces",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
- "test": "jest"
7
+ "test": "jest",
8
+ "prepare": "husky install"
9
+ },
10
+ "lint-staged": {
11
+ "*.js": "eslint --fix"
8
12
  },
9
13
  "engines": {
10
14
  "node": ">=16.0.0"
@@ -41,9 +45,11 @@
41
45
  "eslint-plugin-import": "^2.26.0",
42
46
  "eslint-plugin-n": "^15.2.4",
43
47
  "eslint-plugin-promise": "^6.0.0",
48
+ "husky": "^8.0.1",
44
49
  "jest": "^28.1.3",
45
50
  "jest-cli": "^28.1.3",
46
51
  "jest-preset-stylelint": "^5.0.4",
52
+ "lint-staged": "^13.0.3",
47
53
  "stylelint": "^14.10.0"
48
54
  },
49
55
  "dependencies": {
package/src/index.js CHANGED
@@ -11,7 +11,7 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
11
11
  })
12
12
 
13
13
  const meta = {
14
- url: 'https://stylelint.io/user-guide/rules/list/color-no-out-gamut-range'
14
+ url: 'https://github.com/ab34b266/stylelint-gamut/blob/master/src/README.md'
15
15
  }
16
16
 
17
17
  /** @type {import('stylelint').Rule} */
@@ -38,6 +38,8 @@ const ruleFunction = (primary) => {
38
38
  }
39
39
 
40
40
  function check (value) {
41
+ if (!value.startsWith('var(--') && value.includes('var(--')) return
42
+
41
43
  let customPropValue
42
44
  if (value.startsWith('var(--')) {
43
45
  const varName = value.slice(4, -1)
package/src/utils.js CHANGED
@@ -28,14 +28,6 @@ function declarationValueIndex (decl) {
28
28
  }, 0)
29
29
  }
30
30
 
31
- /**
32
- * @param {Node} node
33
- * @returns {node is import('postcss').AtRule}
34
- */
35
- function isAtRule (node) {
36
- return node.type === 'atrule'
37
- }
38
-
39
31
  /**
40
32
  * Check whether a property is standard
41
33
  *
@@ -94,13 +86,21 @@ function isInColorGamutRec2020MediaQuery (decl) {
94
86
  * @returns {boolean | decl}
95
87
  */
96
88
  function getMediaQueryParent (decl) {
97
- if (decl.parent && decl.parent.parent && isAtRule(decl.parent.parent)) {
98
- const parent = decl.parent.parent
89
+ let parent = decl.parent
99
90
 
100
- return parent.name === 'media' && parent
101
- }
91
+ if (parent && isMediaQuery(parent)) return parent
102
92
 
103
- return false
93
+ parent = parent.parent
94
+
95
+ return isMediaQuery(parent) && parent
96
+ }
97
+
98
+ /**
99
+ * @param {import('postcss').Declaration} decl
100
+ * @returns {boolean}
101
+ */
102
+ function isMediaQuery (decl) {
103
+ return decl.type === 'atrule' && decl.name === 'media'
104
104
  }
105
105
 
106
106
  module.exports = {