@primer/stylelint-config 12.7.0-rc.f3bb1ab → 12.7.1-rc.59e46db
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 +6 -0
- package/package.json +8 -9
- package/plugins/no-deprecated-colors.js +18 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 12.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`726d7d1`](https://github.com/primer/stylelint-config/commit/726d7d1bf4eac82a032c448cb0be32d5bf66b29a) Thanks [@jonrohan](https://github.com/jonrohan)! - Updating no-deprecated-colors for primitives v8
|
|
8
|
+
|
|
3
9
|
## 12.7.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/stylelint-config",
|
|
3
|
-
"version": "12.7.
|
|
3
|
+
"version": "12.7.1-rc.59e46db",
|
|
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.",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"anymatch": "^3.1.1",
|
|
29
29
|
"globby": "^11.0.1",
|
|
30
|
-
"lodash.kebabcase": "^4.1.1",
|
|
31
30
|
"postcss-scss": "^4.0.2",
|
|
32
31
|
"postcss-value-parser": "^4.0.2",
|
|
33
32
|
"string.prototype.matchall": "^4.0.2",
|
|
@@ -39,19 +38,19 @@
|
|
|
39
38
|
"tap-map": "^1.0.0"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
|
-
"@changesets/changelog-github": "0.4.
|
|
43
|
-
"@changesets/cli": "2.
|
|
41
|
+
"@changesets/changelog-github": "0.4.7",
|
|
42
|
+
"@changesets/cli": "2.26.1",
|
|
44
43
|
"@github/prettier-config": "0.0.4",
|
|
45
44
|
"@primer/css": "^20.0.0",
|
|
46
45
|
"@primer/primitives": "^7.8.3",
|
|
47
46
|
"dedent": "0.7.0",
|
|
48
|
-
"eslint": "8.
|
|
47
|
+
"eslint": "8.22.0",
|
|
49
48
|
"eslint-plugin-github": "4.3.5",
|
|
50
|
-
"eslint-plugin-jest": "
|
|
49
|
+
"eslint-plugin-jest": "27.0.1",
|
|
51
50
|
"eslint-plugin-prettier": "4.2.1",
|
|
52
|
-
"jest": "
|
|
53
|
-
"jest-preset-stylelint": "
|
|
54
|
-
"prettier": "2.
|
|
51
|
+
"jest": "29.4.3",
|
|
52
|
+
"jest-preset-stylelint": "6.1.0",
|
|
53
|
+
"prettier": "2.8.1"
|
|
55
54
|
},
|
|
56
55
|
"jest": {
|
|
57
56
|
"preset": "jest-preset-stylelint",
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
const stylelint = require('stylelint')
|
|
2
|
-
const kebabCase = require('lodash.kebabcase')
|
|
3
2
|
const matchAll = require('string.prototype.matchall')
|
|
4
3
|
|
|
5
4
|
const ruleName = 'primer/no-deprecated-colors'
|
|
6
5
|
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
7
6
|
rejected: (varName, replacement) => {
|
|
8
7
|
if (replacement === null) {
|
|
9
|
-
return `${varName} is a deprecated color variable. Please consult the primer color docs for a replacement. https://primer.style/primitives`
|
|
8
|
+
return `${varName} is a deprecated color variable. Please consult the primer color docs for a replacement. https://primer.style/primitives/storybook/?path=/story/migration-tables`
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
if (Array.isArray(replacement)) {
|
|
13
|
-
replacement = replacement.map(r => `--color-${kebabCase(r)}`)
|
|
14
|
-
return `${varName} is a deprecated color variable. Please use one of (${replacement.join(', ')}).`
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
replacement = `--color-${kebabCase(replacement)}`
|
|
18
11
|
return `${varName} is a deprecated color variable. Please use the replacement ${replacement}.`
|
|
19
12
|
}
|
|
20
13
|
})
|
|
@@ -39,20 +32,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
39
32
|
const seen = new WeakMap()
|
|
40
33
|
|
|
41
34
|
// eslint-disable-next-line import/no-dynamic-require
|
|
42
|
-
const
|
|
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)
|
|
47
|
-
|
|
48
|
-
const convertedCSSVars = Object.entries(variableChecks)
|
|
49
|
-
.map(([k, v]) => {
|
|
50
|
-
return [`--color-${kebabCase(k)}`, v]
|
|
51
|
-
})
|
|
52
|
-
.reduce((acc, [key, value]) => {
|
|
53
|
-
acc[key] = value
|
|
54
|
-
return acc
|
|
55
|
-
}, {})
|
|
35
|
+
const variableChecks = require(options.deprecatedFile || '../__tests__/__fixtures__/primitives-v8.json')
|
|
56
36
|
|
|
57
37
|
const lintResult = (root, result) => {
|
|
58
38
|
// Walk all declarations
|
|
@@ -62,6 +42,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
62
42
|
} else {
|
|
63
43
|
seen.set(node, true)
|
|
64
44
|
}
|
|
45
|
+
|
|
65
46
|
// walk these nodes
|
|
66
47
|
if (!(node.type === 'decl' || node.type === 'atrule')) {
|
|
67
48
|
return
|
|
@@ -71,11 +52,22 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
71
52
|
node.type === 'atrule' ? node.params : node.value,
|
|
72
53
|
variableReferenceRegex
|
|
73
54
|
)) {
|
|
74
|
-
if (variableName in
|
|
75
|
-
let replacement =
|
|
55
|
+
if (variableName in variableChecks) {
|
|
56
|
+
let replacement = variableChecks[variableName]
|
|
57
|
+
if (typeof replacement === 'object') {
|
|
58
|
+
for (const property of Object.keys(replacement)) {
|
|
59
|
+
if (node.prop.includes(property)) {
|
|
60
|
+
replacement = replacement[property]
|
|
61
|
+
break
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (typeof replacement === 'object') {
|
|
65
|
+
replacement = null
|
|
66
|
+
}
|
|
67
|
+
}
|
|
76
68
|
|
|
77
|
-
if (context.fix && replacement !== null
|
|
78
|
-
replacement =
|
|
69
|
+
if (context.fix && replacement !== null) {
|
|
70
|
+
replacement = `${replacement}, var(${variableName})`
|
|
79
71
|
replacedVars[variableName] = true
|
|
80
72
|
newVars[replacement] = true
|
|
81
73
|
if (node.type === 'atrule') {
|