@primer/stylelint-config 12.3.1 → 12.3.3-rc.7590f39
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 +15 -3
- package/package.json +2 -2
- package/plugins/no-deprecated-colors.js +1 -1
- package/plugins/no-unused-vars.js +5 -5
- package/plugins/spacing.js +39 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 12.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#217](https://github.com/primer/stylelint-config/pull/217) [`5bb2834`](https://github.com/primer/stylelint-config/commit/5bb28342a6194dfdd4fbf5197682367ea54792b7) Thanks [@jsoref](https://github.com/jsoref)! - Spelling fixes
|
|
8
|
+
|
|
9
|
+
## 12.3.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#215](https://github.com/primer/stylelint-config/pull/215) [`66b16ae`](https://github.com/primer/stylelint-config/commit/66b16ae2edd81f8c8949f83c96d7011e5d395cc0) Thanks [@jonrohan](https://github.com/jonrohan)! - Making linter pick up separate function groups
|
|
14
|
+
|
|
3
15
|
## 12.3.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -24,7 +36,7 @@
|
|
|
24
36
|
|
|
25
37
|
### Patch Changes
|
|
26
38
|
|
|
27
|
-
- [#181](https://github.com/primer/stylelint-config/pull/181) [`23e438a`](https://github.com/primer/stylelint-config/commit/23e438a7a9062550baa696cafbb186dc78b723f5) Thanks [@jonrohan](https://github.com/jonrohan)! -
|
|
39
|
+
- [#181](https://github.com/primer/stylelint-config/pull/181) [`23e438a`](https://github.com/primer/stylelint-config/commit/23e438a7a9062550baa696cafbb186dc78b723f5) Thanks [@jonrohan](https://github.com/jonrohan)! - Turning off scss/dollar-variable-default
|
|
28
40
|
|
|
29
41
|
## 12.1.1
|
|
30
42
|
|
|
@@ -86,7 +98,7 @@
|
|
|
86
98
|
|
|
87
99
|
### Major Changes
|
|
88
100
|
|
|
89
|
-
- [`23a1f15`](https://github.com/primer/stylelint-config/commit/23a1f1599673f2a4f9f28c39da61f42871c05697) [#85](https://github.com/primer/stylelint-config/pull/85) Thanks [@koddsson](https://github.com/koddsson)! - Replace deprecated "blacklist" rules for "
|
|
101
|
+
- [`23a1f15`](https://github.com/primer/stylelint-config/commit/23a1f1599673f2a4f9f28c39da61f42871c05697) [#85](https://github.com/primer/stylelint-config/pull/85) Thanks [@koddsson](https://github.com/koddsson)! - Replace deprecated "blacklist" rules for "disallow list" rules.
|
|
90
102
|
|
|
91
103
|
See https://stylelint.io/user-guide/rules/at-rule-blacklist and http://stylelint.io/user-guide/rules/declaration-property-value-disallowed-list/
|
|
92
104
|
|
|
@@ -104,7 +116,7 @@
|
|
|
104
116
|
|
|
105
117
|
### Patch Changes
|
|
106
118
|
|
|
107
|
-
- [`d18cfbf`](https://github.com/primer/stylelint-config/commit/d18cfbfefc25be6ae38f73132552d2f3c62c4d02) [#79](https://github.com/primer/stylelint-config/pull/79) Thanks [@BinaryMuse](https://github.com/BinaryMuse)! - Add
|
|
119
|
+
- [`d18cfbf`](https://github.com/primer/stylelint-config/commit/d18cfbfefc25be6ae38f73132552d2f3c62c4d02) [#79](https://github.com/primer/stylelint-config/pull/79) Thanks [@BinaryMuse](https://github.com/BinaryMuse)! - Add additional verbose logging to `no-undefined-vars`
|
|
108
120
|
|
|
109
121
|
* [`d18cfbf`](https://github.com/primer/stylelint-config/commit/d18cfbfefc25be6ae38f73132552d2f3c62c4d02) [#79](https://github.com/primer/stylelint-config/pull/79) Thanks [@BinaryMuse](https://github.com/BinaryMuse)! - Fix handling of edge-cases in `no-undefined-vars`
|
|
110
122
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/stylelint-config",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.3-rc.7590f39",
|
|
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.",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"plugins/"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
|
-
"test": "jest",
|
|
23
|
+
"test": "jest --coverage false",
|
|
24
24
|
"lint": "eslint .",
|
|
25
25
|
"release": "changeset publish"
|
|
26
26
|
},
|
|
@@ -50,7 +50,7 @@ function getCachedVariables(options, log) {
|
|
|
50
50
|
const key = JSON.stringify(options)
|
|
51
51
|
return cache.tap(key, () => {
|
|
52
52
|
const {files, variablePattern} = options
|
|
53
|
-
const
|
|
53
|
+
const decls = new TapMap()
|
|
54
54
|
const refs = new TapMap()
|
|
55
55
|
|
|
56
56
|
log(`Looking for variables in ${files} ...`)
|
|
@@ -60,15 +60,15 @@ function getCachedVariables(options, log) {
|
|
|
60
60
|
const after = css.substr(match.index + match[0].length)
|
|
61
61
|
const name = match[0]
|
|
62
62
|
if (after.startsWith(COLON)) {
|
|
63
|
-
|
|
63
|
+
decls.tap(name, set).add(file)
|
|
64
64
|
} else {
|
|
65
65
|
refs.tap(name, set).add(file)
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
log(`Found ${
|
|
69
|
+
log(`Found ${decls.size} declarations, ${pluralize(refs.size, 'reference')}.`)
|
|
70
70
|
|
|
71
|
-
for (const [name, filesList] of
|
|
71
|
+
for (const [name, filesList] of decls.entries()) {
|
|
72
72
|
const fileRefs = refs.get(name)
|
|
73
73
|
if (fileRefs) {
|
|
74
74
|
log(`variable "${name}" declared in ${pluralize(filesList.size, 'file')}, ref'd in ${fileRefs.size}`)
|
|
@@ -77,7 +77,7 @@ function getCachedVariables(options, log) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
return {
|
|
80
|
+
return {decls, refs}
|
|
81
81
|
})
|
|
82
82
|
}
|
|
83
83
|
|
package/plugins/spacing.js
CHANGED
|
@@ -2,6 +2,7 @@ const stylelint = require('stylelint')
|
|
|
2
2
|
const declarationValueIndex = require('stylelint/lib/utils/declarationValueIndex')
|
|
3
3
|
const valueParser = require('postcss-value-parser')
|
|
4
4
|
|
|
5
|
+
// TODO: Pull this in from primer/primitives
|
|
5
6
|
const spacerValues = {
|
|
6
7
|
'$spacer-1': '4px',
|
|
7
8
|
'$spacer-2': '8px',
|
|
@@ -34,6 +35,17 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
|
34
35
|
}
|
|
35
36
|
})
|
|
36
37
|
|
|
38
|
+
const walkGroups = (root, validate) => {
|
|
39
|
+
for (const node of root.nodes) {
|
|
40
|
+
if (node.type === 'function') {
|
|
41
|
+
walkGroups(node, validate)
|
|
42
|
+
} else {
|
|
43
|
+
validate(node)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return root
|
|
47
|
+
}
|
|
48
|
+
|
|
37
49
|
// eslint-disable-next-line no-unused-vars
|
|
38
50
|
module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, context) => {
|
|
39
51
|
if (!enabled) {
|
|
@@ -47,63 +59,55 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
47
59
|
}
|
|
48
60
|
|
|
49
61
|
const problems = []
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
|
|
63
|
+
const parsedValue = walkGroups(valueParser(decl.value), node => {
|
|
64
|
+
// Remove leading negative sign, if any.
|
|
65
|
+
const cleanValue = node.value.replace(/^-/g, '')
|
|
66
|
+
|
|
53
67
|
// Only check word types. https://github.com/TrySound/postcss-value-parser#word
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
68
|
+
if (node.type !== 'word') {
|
|
69
|
+
return
|
|
56
70
|
}
|
|
57
71
|
|
|
58
|
-
//
|
|
59
|
-
if (['0', 'auto', 'inherit', 'initial'].includes(
|
|
60
|
-
return
|
|
72
|
+
// Exact values to ignore.
|
|
73
|
+
if (['*', '+', '-', '/', '0', 'auto', 'inherit', 'initial'].includes(node.value)) {
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const valueUnit = valueParser.unit(cleanValue)
|
|
78
|
+
|
|
79
|
+
if (valueUnit && (valueUnit.unit === '' || !/^[0-9]+$/.test(valueUnit.number))) {
|
|
80
|
+
return
|
|
61
81
|
}
|
|
62
|
-
// Remove leading negative sign, if any.
|
|
63
|
-
const cleanDeclValue = declValue.value.replace(/^-/g, '')
|
|
64
82
|
|
|
65
83
|
// If the a variable is found in the value, skip it.
|
|
66
84
|
if (
|
|
67
85
|
Object.keys(spacerValues).some(variable =>
|
|
68
|
-
new RegExp(`${variable.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(
|
|
86
|
+
new RegExp(`${variable.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(cleanValue)
|
|
69
87
|
)
|
|
70
88
|
) {
|
|
71
|
-
|
|
72
|
-
return noop
|
|
89
|
+
return
|
|
73
90
|
}
|
|
74
91
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
containsMath = true
|
|
78
|
-
return noop
|
|
79
|
-
}
|
|
92
|
+
const replacement = Object.keys(spacerValues).find(spacer => spacerValues[spacer] === cleanValue) || null
|
|
93
|
+
const valueMatch = replacement ? spacerValues[replacement] : node.value
|
|
80
94
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
declValue.value = declValue.value.replace(spacerValues[valueMatch], valueMatch)
|
|
85
|
-
} else {
|
|
86
|
-
problems.push({
|
|
87
|
-
index: declarationValueIndex(decl) + declValue.sourceIndex,
|
|
88
|
-
message: messages.rejected(spacerValues[valueMatch], valueMatch)
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
} else if (declValue.value !== '' && declValue.type !== 'function' && !containsMath) {
|
|
95
|
+
if (replacement && context.fix) {
|
|
96
|
+
node.value = node.value.replace(valueMatch, replacement)
|
|
97
|
+
} else {
|
|
92
98
|
problems.push({
|
|
93
|
-
index: declarationValueIndex(decl) +
|
|
94
|
-
message: messages.rejected(
|
|
99
|
+
index: declarationValueIndex(decl) + node.sourceIndex,
|
|
100
|
+
message: messages.rejected(valueMatch, replacement)
|
|
95
101
|
})
|
|
96
102
|
}
|
|
103
|
+
|
|
104
|
+
return
|
|
97
105
|
})
|
|
98
106
|
|
|
99
107
|
if (context.fix) {
|
|
100
108
|
decl.value = parsedValue.toString()
|
|
101
109
|
}
|
|
102
110
|
|
|
103
|
-
if (containsMath && conatinsVariable) {
|
|
104
|
-
return noop
|
|
105
|
-
}
|
|
106
|
-
|
|
107
111
|
if (problems.length) {
|
|
108
112
|
for (const err of problems) {
|
|
109
113
|
stylelint.utils.report({
|