@primer/stylelint-config 12.5.0-rc.95b13e5 → 12.6.0-rc.95fce9c
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/index.js +7 -0
- package/package.json +2 -2
- package/plugins/no-experimental-vars.js +47 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 12.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#272](https://github.com/primer/stylelint-config/pull/272) [`9104062`](https://github.com/primer/stylelint-config/commit/91040626d2195cbb63f1e302ae53acdd4ba5b361) Thanks [@langermank](https://github.com/langermank)! - Add no-experimental-vars plugin
|
|
8
|
+
|
|
3
9
|
## 12.5.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ module.exports = {
|
|
|
13
13
|
'./plugins/box-shadow',
|
|
14
14
|
'./plugins/colors',
|
|
15
15
|
'./plugins/no-deprecated-colors',
|
|
16
|
+
'./plugins/no-experimental-vars',
|
|
16
17
|
'./plugins/no-override',
|
|
17
18
|
'./plugins/no-scale-colors',
|
|
18
19
|
'./plugins/no-undefined-vars',
|
|
@@ -61,6 +62,12 @@ module.exports = {
|
|
|
61
62
|
'primer/box-shadow': true,
|
|
62
63
|
'primer/colors': true,
|
|
63
64
|
'primer/no-deprecated-colors': true,
|
|
65
|
+
'primer/no-experimental-vars': [
|
|
66
|
+
true,
|
|
67
|
+
{
|
|
68
|
+
designTokens: '@primer/primitives/tokens-v2-private/docs/docValues.json'
|
|
69
|
+
}
|
|
70
|
+
],
|
|
64
71
|
'primer/no-override': true,
|
|
65
72
|
'primer/no-undefined-vars': [
|
|
66
73
|
true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/stylelint-config",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.6.0-rc.95fce9c",
|
|
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.",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@changesets/cli": "2.22.0",
|
|
44
44
|
"@github/prettier-config": "0.0.4",
|
|
45
45
|
"@primer/css": "^20.0.0",
|
|
46
|
-
"@primer/primitives": "^7.
|
|
46
|
+
"@primer/primitives": "^7.8.3",
|
|
47
47
|
"dedent": "0.7.0",
|
|
48
48
|
"eslint": "8.14.0",
|
|
49
49
|
"eslint-plugin-github": "4.3.5",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const stylelint = require('stylelint')
|
|
2
|
+
const declarationValueIndex = require('stylelint/lib/utils/declarationValueIndex')
|
|
3
|
+
|
|
4
|
+
const ruleName = 'primer/no-experimental-vars'
|
|
5
|
+
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
6
|
+
rejected: value => {
|
|
7
|
+
return `Do not use experimental variable \`var(--${value})\`. Experimental variables are undergoing testing, see https://github.com/github/primer/issues/889 for more details.`
|
|
8
|
+
}
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line no-unused-vars
|
|
12
|
+
module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, context) => {
|
|
13
|
+
if (!enabled) {
|
|
14
|
+
return noop
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
18
|
+
const designTokens = require(options.designTokens)
|
|
19
|
+
|
|
20
|
+
let experimentalVars = null
|
|
21
|
+
for (const tokenType of Object.keys(designTokens)) {
|
|
22
|
+
experimentalVars = new Set(designTokens[tokenType].map(t => t['name']))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const lintResult = (root, result) => {
|
|
26
|
+
root.walkDecls(decl => {
|
|
27
|
+
for (const expVar of experimentalVars) {
|
|
28
|
+
if (decl.value.includes(`var(--${expVar})`)) {
|
|
29
|
+
stylelint.utils.report({
|
|
30
|
+
index: declarationValueIndex(decl),
|
|
31
|
+
message: messages.rejected(expVar),
|
|
32
|
+
node: decl,
|
|
33
|
+
result,
|
|
34
|
+
ruleName
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return lintResult
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
function noop() {}
|
|
45
|
+
|
|
46
|
+
module.exports.ruleName = ruleName
|
|
47
|
+
module.exports.messages = messages
|