@primer/stylelint-config 12.7.2 → 12.7.3-rc.99e67f7
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 +310 -0
- package/browsers.js +1 -1
- package/index.js +7 -7
- package/package.json +5 -5
- package/plugins/borders.js +11 -11
- package/plugins/box-shadow.js +4 -4
- package/plugins/colors.js +7 -7
- package/plugins/lib/decl-validator.js +8 -8
- package/plugins/lib/primer-utilities.js +144 -144
- package/plugins/lib/primer.js +1 -1
- package/plugins/lib/primitives-v8.json +1 -1
- package/plugins/lib/variable-rules.js +3 -3
- package/plugins/no-deprecated-colors.js +3 -3
- package/plugins/no-experimental-vars.js +2 -2
- package/plugins/no-override.js +5 -5
- package/plugins/no-scale-colors.js +2 -2
- package/plugins/no-undefined-vars.js +3 -3
- package/plugins/no-unused-vars.js +2 -2
- package/plugins/responsive-widths.js +4 -4
- package/plugins/spacing.js +5 -5
- package/plugins/typography.js +6 -6
- package/plugins/utilities.js +2 -2
- package/property-order.js +1 -1
|
@@ -10,7 +10,7 @@ module.exports = {
|
|
|
10
10
|
createVariableRule,
|
|
11
11
|
CSS_DIRECTIONS,
|
|
12
12
|
CSS_CORNERS,
|
|
13
|
-
CSS_IMPORTANT
|
|
13
|
+
CSS_IMPORTANT,
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function createVariableRule(ruleName, rules, url) {
|
|
@@ -79,7 +79,7 @@ function createVariableRule(ruleName, rules, url) {
|
|
|
79
79
|
return `${m}. See ${url}.`
|
|
80
80
|
}
|
|
81
81
|
return `${m}.`
|
|
82
|
-
}
|
|
82
|
+
},
|
|
83
83
|
})
|
|
84
84
|
.rejected(error)
|
|
85
85
|
|
|
@@ -87,7 +87,7 @@ function createVariableRule(ruleName, rules, url) {
|
|
|
87
87
|
message,
|
|
88
88
|
node: decl,
|
|
89
89
|
result,
|
|
90
|
-
ruleName
|
|
90
|
+
ruleName,
|
|
91
91
|
})
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -9,7 +9,7 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return `Variable ${varName} is deprecated for property ${property}. Please use the replacement ${replacement}.`
|
|
12
|
-
}
|
|
12
|
+
},
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
// Match CSS variable references (e.g var(--color-text-primary))
|
|
@@ -84,7 +84,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
84
84
|
message: messages.rejected(variableName, replacement, node.prop),
|
|
85
85
|
node,
|
|
86
86
|
ruleName,
|
|
87
|
-
result
|
|
87
|
+
result,
|
|
88
88
|
})
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -92,7 +92,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
log(
|
|
95
|
-
`${Object.keys(replacedVars).length} deprecated variables replaced with ${Object.keys(newVars).length} variables
|
|
95
|
+
`${Object.keys(replacedVars).length} deprecated variables replaced with ${Object.keys(newVars).length} variables.`,
|
|
96
96
|
)
|
|
97
97
|
return lintResult
|
|
98
98
|
})
|
|
@@ -5,7 +5,7 @@ const ruleName = 'primer/no-experimental-vars'
|
|
|
5
5
|
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
6
6
|
rejected: value => {
|
|
7
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
|
-
}
|
|
8
|
+
},
|
|
9
9
|
})
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -31,7 +31,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
31
31
|
message: messages.rejected(expVar),
|
|
32
32
|
node: decl,
|
|
33
33
|
result,
|
|
34
|
-
ruleName
|
|
34
|
+
ruleName,
|
|
35
35
|
})
|
|
36
36
|
}
|
|
37
37
|
}
|
package/plugins/no-override.js
CHANGED
|
@@ -52,7 +52,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
|
|
52
52
|
const ruleSelector = collapseWhitespace(rule.selector)
|
|
53
53
|
const context = selector === rule.selector ? '' : ` in "${ruleSelector}"`
|
|
54
54
|
return `"${collapseWhitespace(selector)}" should not be overridden${context}${definedIn}.`
|
|
55
|
-
}
|
|
55
|
+
},
|
|
56
56
|
})
|
|
57
57
|
|
|
58
58
|
return (root, result) => {
|
|
@@ -62,7 +62,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
|
|
62
62
|
: '(not an array)'
|
|
63
63
|
result.warn(`The "bundles" option must be an array of valid bundles; got: ${invalidBundles}`, {
|
|
64
64
|
stylelintType: 'invalidOption',
|
|
65
|
-
stylelintReference: 'https://github.com/primer/stylelint-config#options'
|
|
65
|
+
stylelintReference: 'https://github.com/primer/stylelint-config#options',
|
|
66
66
|
})
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -71,7 +71,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
|
|
71
71
|
message: messages.rejected(subject),
|
|
72
72
|
node: subject.rule,
|
|
73
73
|
result,
|
|
74
|
-
ruleName
|
|
74
|
+
ruleName,
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
root.walkRules(rule => {
|
|
@@ -82,7 +82,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
|
|
82
82
|
return report({
|
|
83
83
|
rule,
|
|
84
84
|
bundle: immutableSelectors.get(selector),
|
|
85
|
-
selector
|
|
85
|
+
selector,
|
|
86
86
|
})
|
|
87
87
|
}
|
|
88
88
|
} else {
|
|
@@ -95,7 +95,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
|
|
95
95
|
return report({
|
|
96
96
|
rule,
|
|
97
97
|
bundle: immutableClassSelectors.get(classSelector),
|
|
98
|
-
selector: classSelector
|
|
98
|
+
selector: classSelector,
|
|
99
99
|
})
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -4,7 +4,7 @@ const matchAll = require('string.prototype.matchall')
|
|
|
4
4
|
const ruleName = 'primer/no-scale-colors'
|
|
5
5
|
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
6
6
|
rejected: varName =>
|
|
7
|
-
`${varName} is a non-functional scale color and cannot be used without being wrapped in the color-variables mixin
|
|
7
|
+
`${varName} is a non-functional scale color and cannot be used without being wrapped in the color-variables mixin`,
|
|
8
8
|
})
|
|
9
9
|
|
|
10
10
|
// Match CSS variable references (e.g var(--color-text-primary))
|
|
@@ -39,7 +39,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
|
|
39
39
|
message: messages.rejected(variableName),
|
|
40
40
|
node: decl,
|
|
41
41
|
result,
|
|
42
|
-
ruleName
|
|
42
|
+
ruleName,
|
|
43
43
|
})
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -6,7 +6,7 @@ const TapMap = require('tap-map')
|
|
|
6
6
|
|
|
7
7
|
const ruleName = 'primer/no-undefined-vars'
|
|
8
8
|
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
9
|
-
rejected: varName => `${varName} is not defined
|
|
9
|
+
rejected: varName => `${varName} is not defined`,
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
// Match CSS variable definitions (e.g. --color-text-primary:)
|
|
@@ -40,7 +40,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
|
|
40
40
|
message: messages.rejected(variableName),
|
|
41
41
|
node,
|
|
42
42
|
result,
|
|
43
|
-
ruleName
|
|
43
|
+
ruleName,
|
|
44
44
|
})
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -80,7 +80,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
|
|
80
80
|
checkVariable(
|
|
81
81
|
variableName,
|
|
82
82
|
decl,
|
|
83
|
-
new Set([...globalDefinedVariables, ...fileDefinedVariables, ...scopeDefinedVaribles])
|
|
83
|
+
new Set([...globalDefinedVariables, ...fileDefinedVariables, ...scopeDefinedVaribles]),
|
|
84
84
|
)
|
|
85
85
|
}
|
|
86
86
|
})
|
|
@@ -11,7 +11,7 @@ const COLON = ':'
|
|
|
11
11
|
const SCSS_VARIABLE_PATTERN = /(\$[-\w]+)/g
|
|
12
12
|
|
|
13
13
|
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
14
|
-
rejected: name => `The variable "${name}" is not referenced
|
|
14
|
+
rejected: name => `The variable "${name}" is not referenced.`,
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
const cache = new TapMap()
|
|
@@ -35,7 +35,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
|
|
35
35
|
message: messages.rejected(name),
|
|
36
36
|
node: decl,
|
|
37
37
|
result,
|
|
38
|
-
ruleName
|
|
38
|
+
ruleName,
|
|
39
39
|
})
|
|
40
40
|
} else {
|
|
41
41
|
const path = stripCwd(decl.source.input.file)
|
|
@@ -7,7 +7,7 @@ const ruleName = 'primer/responsive-widths'
|
|
|
7
7
|
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
8
8
|
rejected: value => {
|
|
9
9
|
return `A value larger than the smallest viewport could break responsive pages. Use a width value smaller than ${value}. https://primer.style/css/support/breakpoints`
|
|
10
|
-
}
|
|
10
|
+
},
|
|
11
11
|
})
|
|
12
12
|
|
|
13
13
|
// 320px is the smallest viewport size that we support
|
|
@@ -60,7 +60,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
60
60
|
if (parseInt(valueUnit.number) > 320) {
|
|
61
61
|
problems.push({
|
|
62
62
|
index: declarationValueIndex(decl) + node.sourceIndex,
|
|
63
|
-
message: messages.rejected(node.value)
|
|
63
|
+
message: messages.rejected(node.value),
|
|
64
64
|
})
|
|
65
65
|
}
|
|
66
66
|
break
|
|
@@ -68,7 +68,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
68
68
|
if (parseInt(valueUnit.number) > 100) {
|
|
69
69
|
problems.push({
|
|
70
70
|
index: declarationValueIndex(decl) + node.sourceIndex,
|
|
71
|
-
message: messages.rejected(node.value)
|
|
71
|
+
message: messages.rejected(node.value),
|
|
72
72
|
})
|
|
73
73
|
}
|
|
74
74
|
break
|
|
@@ -82,7 +82,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
82
82
|
message: err.message,
|
|
83
83
|
node: decl,
|
|
84
84
|
result,
|
|
85
|
-
ruleName
|
|
85
|
+
ruleName,
|
|
86
86
|
})
|
|
87
87
|
}
|
|
88
88
|
}
|
package/plugins/spacing.js
CHANGED
|
@@ -21,7 +21,7 @@ const spacerValues = {
|
|
|
21
21
|
'$em-spacer-3': '0.25em',
|
|
22
22
|
'$em-spacer-4': '0.375em',
|
|
23
23
|
'$em-spacer-5': '0.5em',
|
|
24
|
-
'$em-spacer-6': '0.75em'
|
|
24
|
+
'$em-spacer-6': '0.75em',
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const ruleName = 'primer/spacing'
|
|
@@ -32,7 +32,7 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return `Please replace ${value} with spacing variable '${replacement}'.`
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
const walkGroups = (root, validate) => {
|
|
@@ -83,7 +83,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
83
83
|
// If the a variable is found in the value, skip it.
|
|
84
84
|
if (
|
|
85
85
|
Object.keys(spacerValues).some(variable =>
|
|
86
|
-
new RegExp(`${variable.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(cleanValue)
|
|
86
|
+
new RegExp(`${variable.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(cleanValue),
|
|
87
87
|
)
|
|
88
88
|
) {
|
|
89
89
|
return
|
|
@@ -97,7 +97,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
97
97
|
} else {
|
|
98
98
|
problems.push({
|
|
99
99
|
index: declarationValueIndex(decl) + node.sourceIndex,
|
|
100
|
-
message: messages.rejected(valueMatch, replacement)
|
|
100
|
+
message: messages.rejected(valueMatch, replacement),
|
|
101
101
|
})
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -115,7 +115,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
115
115
|
message: err.message,
|
|
116
116
|
node: decl,
|
|
117
117
|
result,
|
|
118
|
-
ruleName
|
|
118
|
+
ruleName,
|
|
119
119
|
})
|
|
120
120
|
}
|
|
121
121
|
}
|
package/plugins/typography.js
CHANGED
|
@@ -5,20 +5,20 @@ module.exports = createVariableRule(
|
|
|
5
5
|
{
|
|
6
6
|
'font-size': {
|
|
7
7
|
expects: 'a font-size variable',
|
|
8
|
-
values: ['$body-font-size', '$h{000,00,0,1,2,3,4,5,6}-size', '$font-size-*', '1', '1em', 'inherit']
|
|
8
|
+
values: ['$body-font-size', '$h{000,00,0,1,2,3,4,5,6}-size', '$font-size-*', '1', '1em', 'inherit'],
|
|
9
9
|
},
|
|
10
10
|
'font-weight': {
|
|
11
11
|
props: 'font-weight',
|
|
12
12
|
values: ['$font-weight-*', 'inherit'],
|
|
13
13
|
replacements: {
|
|
14
14
|
bold: '$font-weight-bold',
|
|
15
|
-
normal: '$font-weight-normal'
|
|
16
|
-
}
|
|
15
|
+
normal: '$font-weight-normal',
|
|
16
|
+
},
|
|
17
17
|
},
|
|
18
18
|
'line-height': {
|
|
19
19
|
props: 'line-height',
|
|
20
|
-
values: ['$body-line-height', '$lh-*', '0', '1', '1em', 'inherit']
|
|
21
|
-
}
|
|
20
|
+
values: ['$body-line-height', '$lh-*', '0', '1', '1em', 'inherit'],
|
|
21
|
+
},
|
|
22
22
|
},
|
|
23
|
-
'https://primer.style/css/utilities/typography'
|
|
23
|
+
'https://primer.style/css/utilities/typography',
|
|
24
24
|
)
|
package/plugins/utilities.js
CHANGED
|
@@ -6,7 +6,7 @@ const ruleName = 'primer/utilities'
|
|
|
6
6
|
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
7
7
|
rejected: (selector, utilityClass) => {
|
|
8
8
|
return `Consider using the Primer utility '.${utilityClass}' instead of the selector '${selector}' in your html. https://primer.style/css/utilities`
|
|
9
|
-
}
|
|
9
|
+
},
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -39,7 +39,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
|
|
|
39
39
|
message: messages.rejected(rule.selector, replacement.utilityClass),
|
|
40
40
|
node: rule,
|
|
41
41
|
result,
|
|
42
|
-
ruleName
|
|
42
|
+
ruleName,
|
|
43
43
|
})
|
|
44
44
|
}
|
|
45
45
|
}
|
package/property-order.js
CHANGED