stylelint-config-crisp 1.0.8 → 1.0.9
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/index.js +8 -2
- package/package.json +1 -1
- package/rules/at-rule-conditional-parentheses.js +34 -0
package/index.js
CHANGED
|
@@ -12,6 +12,8 @@ module.exports = {
|
|
|
12
12
|
],
|
|
13
13
|
|
|
14
14
|
plugins: [
|
|
15
|
+
"./rules/at-rule-conditional-parentheses",
|
|
16
|
+
|
|
15
17
|
"stylelint-order"
|
|
16
18
|
],
|
|
17
19
|
|
|
@@ -36,7 +38,8 @@ module.exports = {
|
|
|
36
38
|
{
|
|
37
39
|
"ignoreShorthands": [
|
|
38
40
|
"inset",
|
|
39
|
-
"overflow"
|
|
41
|
+
"overflow",
|
|
42
|
+
"place-self"
|
|
40
43
|
]
|
|
41
44
|
}
|
|
42
45
|
],
|
|
@@ -99,6 +102,9 @@ module.exports = {
|
|
|
99
102
|
"dollar-variables",
|
|
100
103
|
"declarations",
|
|
101
104
|
"rules"
|
|
102
|
-
]
|
|
105
|
+
],
|
|
106
|
+
|
|
107
|
+
// Crisp rules
|
|
108
|
+
"crisp/at-rule-conditional-parentheses": true
|
|
103
109
|
}
|
|
104
110
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const stylelint = require("stylelint");
|
|
2
|
+
|
|
3
|
+
const ruleName = "crisp/at-rule-conditional-parentheses";
|
|
4
|
+
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
5
|
+
expected: "Expected parentheses in \"@if\" and \"@else-if\" statements",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const ruleFunction = (primaryOption, secondaryOptions, context) => {
|
|
9
|
+
return (root, result) => {
|
|
10
|
+
const validOptions = stylelint.utils.validateOptions(result, ruleName, {
|
|
11
|
+
actual: primaryOption,
|
|
12
|
+
possible: [true, false],
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!validOptions) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
root.walkAtRules((rule) => {
|
|
20
|
+
if (rule.name === "if" || rule.name === "else-if") {
|
|
21
|
+
if (!rule.params.startsWith("(") || !rule.params.endsWith(")")) {
|
|
22
|
+
stylelint.utils.report({
|
|
23
|
+
ruleName,
|
|
24
|
+
result,
|
|
25
|
+
node: rule,
|
|
26
|
+
message: messages.expected,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports = stylelint.createPlugin(ruleName, ruleFunction);
|