stylelint-config-crisp 1.0.8 → 1.0.10
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/README.md +4 -0
- package/index.js +9 -2
- package/package.json +1 -1
- package/rules/at-rule-conditional-parentheses.js +34 -0
package/README.md
CHANGED
|
@@ -55,6 +55,7 @@ This is the list of configured syntaxes, plugins and rules used by Stylelint Con
|
|
|
55
55
|
#### SCSS rules
|
|
56
56
|
- [scss/at-rule-conditional-no-parentheses](https://github.com/stylelint-scss/stylelint-scss/tree/master/src/rules/at-rule-conditional-no-parentheses): Rule is **disabled** to allow parentheses in conditional at-rules (if, elsif, while)
|
|
57
57
|
- [scss/dollar-variable-empty-line-before](https://github.com/stylelint-scss/stylelint-scss/tree/master/src/rules/dollar-variable-empty-line-before): Rule is **disabled** to allow empty lines between logical variable blocks
|
|
58
|
+
- [scss/load-no-partial-leading-underscore](https://github.com/stylelint-scss/stylelint-scss/tree/master/src/rules/load-no-partial-leading-underscore): Rule is **disabled** to allow `@import`-ing files with underscore in their name
|
|
58
59
|
- [scss/no-global-function-names](https://github.com/stylelint-scss/stylelint-scss/tree/master/src/rules/no-global-function-names): Rule is **disabled** to keep using global function names, instead of the new built-in module system
|
|
59
60
|
- [scss/operator-no-newline-after](https://github.com/stylelint-scss/stylelint-scss/tree/master/src/rules/operator-no-newline-after): Rule is **disabled** to allow linebreaks after Sass operators
|
|
60
61
|
|
|
@@ -75,6 +76,9 @@ This is the list of configured syntaxes, plugins and rules used by Stylelint Con
|
|
|
75
76
|
#### Order rules
|
|
76
77
|
- [order/order](https://github.com/hudochenkov/stylelint-order/tree/master/rules/order): Enforces the order of content within declaration blocks: dollar variables, then declarations, then nested rules
|
|
77
78
|
|
|
79
|
+
#### Crisp rules
|
|
80
|
+
- [at-rule-conditional-parentheses](https://github.com/crisp-oss/stylelint-config-crisp/blob/master/rules/at-rule-conditional-parentheses.js): Enforces parentheses in conditions of at-rules (`@if`, `@elseif`, `@while`)
|
|
81
|
+
|
|
78
82
|
## License
|
|
79
83
|
|
|
80
84
|
stylelint-config-crisp is released under the MIT License. See the bundled LICENSE file for details.
|
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
|
],
|
|
@@ -66,6 +69,7 @@ module.exports = {
|
|
|
66
69
|
// SCSS rules
|
|
67
70
|
"scss/at-rule-conditional-no-parentheses": null,
|
|
68
71
|
"scss/dollar-variable-empty-line-before": null,
|
|
72
|
+
"scss/load-no-partial-leading-underscore": null,
|
|
69
73
|
"scss/no-global-function-names": null,
|
|
70
74
|
"scss/operator-no-newline-after": null,
|
|
71
75
|
|
|
@@ -99,6 +103,9 @@ module.exports = {
|
|
|
99
103
|
"dollar-variables",
|
|
100
104
|
"declarations",
|
|
101
105
|
"rules"
|
|
102
|
-
]
|
|
106
|
+
],
|
|
107
|
+
|
|
108
|
+
// Crisp rules
|
|
109
|
+
"crisp/at-rule-conditional-parentheses": true
|
|
103
110
|
}
|
|
104
111
|
}
|
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 (["if", "else-if", "while"].includes(rule.name)) {
|
|
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);
|