stylelint-plugin-logical-css 0.1.0 → 0.1.1
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
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
# Stylelint Plugin Logical CSS
|
|
1
|
+
# 🚀 Stylelint Plugin Logical CSS
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|

|
|
5
|
+

|
|
5
6
|
|
|
6
7
|
Stylelint Plugin Logical CSS aims to enforce the use of logical CSS properties,
|
|
7
8
|
values and units. The plugin provides two rules. But first, let's get set up.
|
package/package.json
CHANGED
|
@@ -8,9 +8,15 @@ const { isPhysicalValue } = require('../../utils/isPhysicalValue');
|
|
|
8
8
|
const { physicalPropertiesMap } = require('../../utils/physicalPropertiesMap');
|
|
9
9
|
const { physicalValuesMap } = require('../../utils/physicalValuesMap');
|
|
10
10
|
|
|
11
|
-
const ruleFunction = () => {
|
|
11
|
+
const ruleFunction = (_, options, context) => {
|
|
12
12
|
return (root, result) => {
|
|
13
|
-
const validOptions = stylelint.utils.validateOptions(result, ruleName
|
|
13
|
+
const validOptions = stylelint.utils.validateOptions(result, ruleName, [
|
|
14
|
+
{
|
|
15
|
+
action: 'enableAutoFix',
|
|
16
|
+
possible: [true, false],
|
|
17
|
+
optional: true,
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
14
20
|
|
|
15
21
|
if (!validOptions) {
|
|
16
22
|
return;
|
|
@@ -33,6 +39,18 @@ const ruleFunction = () => {
|
|
|
33
39
|
physicalValuesMap[decl.prop][decl.value],
|
|
34
40
|
);
|
|
35
41
|
|
|
42
|
+
if (context.fix && options.enableAutoFix) {
|
|
43
|
+
if (propIsPhysical) {
|
|
44
|
+
decl.prop = physicalPropertiesMap[decl.prop];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (valueIsPhysical) {
|
|
48
|
+
decl.value = physicalValuesMap[decl.value];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
36
54
|
stylelint.utils.report({
|
|
37
55
|
message,
|
|
38
56
|
node: decl,
|