@primer/stylelint-config 12.0.0-rc.9e96998 → 12.0.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/CHANGELOG.md CHANGED
@@ -1,11 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 12.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#132](https://github.com/primer/stylelint-config/pull/132) [`b672367`](https://github.com/primer/stylelint-config/commit/b6723679606bb8d39e75025ae17ace9f1c3e2631) Thanks [@jonrohan](https://github.com/jonrohan)! - Updating no-deprecated-colors plugin for edge cases
8
+
3
9
  ## 12.0.0
4
10
 
5
11
  ### Major Changes
6
12
 
7
13
  - [#129](https://github.com/primer/stylelint-config/pull/129) [`653d596`](https://github.com/primer/stylelint-config/commit/653d596072b897b265b093aac4cd5c143e61410e) Thanks [@jonrohan](https://github.com/jonrohan)! - Renaming the package to use org scope. This is a breaking change, you'll need to uninstall `stylelint-config-primer` and reinstall `@primer/stylelint-config`.
8
14
 
15
+ ### Patch Changes
16
+
17
+ - [#130](https://github.com/primer/stylelint-config/pull/130) [`f495a56`](https://github.com/primer/stylelint-config/commit/f495a563a9e809252630466088eb94177e6c0be4) Thanks [@jonrohan](https://github.com/jonrohan)! - Updating @primer/primitives to 5.0 release candidate
18
+
9
19
  ## 11.1.1
10
20
 
11
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/stylelint-config",
3
- "version": "12.0.0-rc.9e96998",
3
+ "version": "12.0.1",
4
4
  "description": "Sharable stylelint config used by GitHub's CSS",
5
5
  "homepage": "http://primer.style/css/tools/linting",
6
6
  "author": "GitHub, Inc.",
@@ -37,14 +37,14 @@
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@primer/css": "*",
40
- "@primer/primitives": ">= 4.6.2"
40
+ "@primer/primitives": "^5.0.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@changesets/changelog-github": "0.4.1",
44
44
  "@changesets/cli": "2.17.0",
45
45
  "@github/prettier-config": "0.0.4",
46
46
  "@primer/css": "^13.2.0",
47
- "@primer/primitives": "^4.6.7",
47
+ "@primer/primitives": "^5.0.0",
48
48
  "dedent": "0.7.0",
49
49
  "eslint": "7.32.0",
50
50
  "eslint-plugin-github": "4.3.0",
@@ -52,7 +52,7 @@
52
52
  "eslint-plugin-prettier": "4.0.0",
53
53
  "jest": "27.2.2",
54
54
  "jest-preset-stylelint": "4.1.1",
55
- "prettier": "2.4.0",
55
+ "prettier": "2.4.1",
56
56
  "stylelint": "13.13.1"
57
57
  },
58
58
  "eslintConfig": {
@@ -39,9 +39,13 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
39
39
  const seen = new WeakMap()
40
40
 
41
41
  // eslint-disable-next-line import/no-dynamic-require
42
- const deprecatedColors = require(options.deprecatedFile || '@primer/primitives/dist/deprecations/colors.json')
42
+ const deprecatedColors = require(options.deprecatedFile || '@primer/primitives/dist/deprecated/colors.json')
43
+ // eslint-disable-next-line import/no-dynamic-require
44
+ const removedColors = require(options.removedFile || '@primer/primitives/dist/removed/colors.json')
45
+
46
+ const variableChecks = Object.assign(deprecatedColors, removedColors)
43
47
 
44
- const convertedCSSVars = Object.entries(deprecatedColors)
48
+ const convertedCSSVars = Object.entries(variableChecks)
45
49
  .map(([k, v]) => {
46
50
  return [`--color-${kebabCase(k)}`, v]
47
51
  })
@@ -51,35 +55,45 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
51
55
  }, {})
52
56
 
53
57
  const lintResult = (root, result) => {
54
- root.walkRules(rule => {
55
- rule.walkDecls(decl => {
56
- if (seen.has(decl)) {
57
- return
58
- } else {
59
- seen.set(decl, true)
60
- }
61
-
62
- for (const [, variableName] of matchAll(decl.value, variableReferenceRegex)) {
63
- if (variableName in convertedCSSVars) {
64
- let replacement = convertedCSSVars[variableName]
65
-
66
- if (context.fix && replacement !== null && !Array.isArray(replacement)) {
67
- replacement = `--color-${kebabCase(replacement)}`
68
- replacedVars[variableName] = true
69
- newVars[replacement] = true
70
- decl.value = decl.value.replace(variableName, replacement)
71
- return
58
+ // Walk all declarartions
59
+ root.walk(node => {
60
+ if (seen.has(node)) {
61
+ return
62
+ } else {
63
+ seen.set(node, true)
64
+ }
65
+ // walk these nodes
66
+ if (!(node.type === 'decl' || node.type === 'atrule')) {
67
+ return
68
+ }
69
+
70
+ for (const [, variableName] of matchAll(
71
+ node.type === 'atrule' ? node.params : node.value,
72
+ variableReferenceRegex
73
+ )) {
74
+ if (variableName in convertedCSSVars) {
75
+ let replacement = convertedCSSVars[variableName]
76
+
77
+ if (context.fix && replacement !== null && !Array.isArray(replacement)) {
78
+ replacement = `--color-${kebabCase(replacement)}`
79
+ replacedVars[variableName] = true
80
+ newVars[replacement] = true
81
+ if (node.type === 'atrule') {
82
+ node.params = node.params.replace(variableName, replacement)
83
+ } else {
84
+ node.value = node.value.replace(variableName, replacement)
72
85
  }
73
-
74
- stylelint.utils.report({
75
- message: messages.rejected(variableName, replacement),
76
- node: decl,
77
- ruleName,
78
- result
79
- })
86
+ continue
80
87
  }
88
+
89
+ stylelint.utils.report({
90
+ message: messages.rejected(variableName, replacement),
91
+ node,
92
+ ruleName,
93
+ result
94
+ })
81
95
  }
82
- })
96
+ }
83
97
  })
84
98
  }
85
99