stylelint-plugin-logical-css 0.9.1 → 0.11.0
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
|
@@ -191,10 +191,10 @@ physical property or value is found, it will be flagged.
|
|
|
191
191
|
| ---------------------------------------------- | ----------------------------------- |
|
|
192
192
|
| `(-webkit-)box-orient: vertical` | `(-webkit-)box-orient: block-axis` |
|
|
193
193
|
| `(-webkit-)box-orient: horizontal` | `(-webkit-)box-orient: inline-axis` |
|
|
194
|
-
| `caption-
|
|
195
|
-
| `caption-
|
|
196
|
-
| `caption-
|
|
197
|
-
| `caption-
|
|
194
|
+
| `caption-side: top` | `caption-side: block-start` |
|
|
195
|
+
| `caption-side: bottom` | `caption-side: block-end` |
|
|
196
|
+
| `caption-side: right` | `caption-side: inline-end` |
|
|
197
|
+
| `caption-side: left` | `caption-side: inline-start` |
|
|
198
198
|
| `overflow-y` | `overflow-block` |
|
|
199
199
|
| `overflow-x` | `overflow-inline` |
|
|
200
200
|
| `overscroll-behavior-x` | `overscroll-behavior-inline` |
|
package/package.json
CHANGED
|
@@ -11,6 +11,9 @@ const ruleMessages = stylelint.utils.ruleMessages(ruleName, {
|
|
|
11
11
|
unexpectedValue(property, physicalValue, logicalValue) {
|
|
12
12
|
return `Unexpected "${physicalValue}" value in "${property}" property. Use "${logicalValue}".`;
|
|
13
13
|
},
|
|
14
|
+
unexpectedTransitionValue(physicalValue, logicalValue) {
|
|
15
|
+
return `Unexpected "${physicalValue}" value in "transition" property. Use "${logicalValue}".`;
|
|
16
|
+
},
|
|
14
17
|
});
|
|
15
18
|
|
|
16
19
|
const ruleMeta = {
|
|
@@ -31,24 +31,55 @@ const ruleFunction = (_, options, context) => {
|
|
|
31
31
|
(prefix) => (rootProp = rootProp.replace(prefix, '')),
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
const isValidProp =
|
|
34
|
+
const isValidProp = [
|
|
35
|
+
...Object.values(physicalProperties),
|
|
36
|
+
'transition',
|
|
37
|
+
].includes(rootProp);
|
|
35
38
|
if (!isValidProp) return;
|
|
36
39
|
|
|
40
|
+
const isTransitionProperty = rootProp === 'transition';
|
|
41
|
+
const physicalTransitionProperties =
|
|
42
|
+
isTransitionProperty &&
|
|
43
|
+
Object.values(physicalProperties)
|
|
44
|
+
.flatMap((property) => {
|
|
45
|
+
const exp = new RegExp(`(^|[^\\w-])${property}([^\\w-]|$)`);
|
|
46
|
+
return decl.value.match(exp);
|
|
47
|
+
})
|
|
48
|
+
.filter((p) => p && p.trim());
|
|
49
|
+
|
|
37
50
|
const propIsPhysical = isPhysicalProperty(decl.prop);
|
|
38
51
|
const valueIsPhysical = isPhysicalValue(decl.value);
|
|
39
52
|
|
|
40
|
-
if (
|
|
53
|
+
if (
|
|
54
|
+
!propIsPhysical &&
|
|
55
|
+
!valueIsPhysical &&
|
|
56
|
+
!physicalTransitionProperties.length
|
|
57
|
+
) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let message;
|
|
41
62
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
if (propIsPhysical) {
|
|
64
|
+
message = ruleMessages.unexpectedProp(
|
|
65
|
+
decl.prop,
|
|
66
|
+
physicalPropertiesMap[rootProp],
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (valueIsPhysical) {
|
|
70
|
+
message = ruleMessages.unexpectedValue(
|
|
71
|
+
decl.prop,
|
|
72
|
+
decl.value,
|
|
73
|
+
physicalValuesMap[rootProp][decl.value],
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (physicalTransitionProperties.length) {
|
|
77
|
+
const propertyToFlag = physicalTransitionProperties[0].trim();
|
|
78
|
+
message = ruleMessages.unexpectedTransitionValue(
|
|
79
|
+
propertyToFlag,
|
|
80
|
+
physicalPropertiesMap[propertyToFlag],
|
|
81
|
+
);
|
|
82
|
+
}
|
|
52
83
|
|
|
53
84
|
if (context.fix && !options?.['disable-auto-fix']) {
|
|
54
85
|
if (propIsPhysical) {
|
|
@@ -59,6 +90,18 @@ const ruleFunction = (_, options, context) => {
|
|
|
59
90
|
decl.value = physicalValuesMap[rootProp][decl.value];
|
|
60
91
|
}
|
|
61
92
|
|
|
93
|
+
if (physicalTransitionProperties.length) {
|
|
94
|
+
let newValue = decl.value;
|
|
95
|
+
physicalTransitionProperties.forEach((property) => {
|
|
96
|
+
newValue = newValue.replace(
|
|
97
|
+
property.trim(),
|
|
98
|
+
physicalPropertiesMap[property.trim()],
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
decl.value = newValue;
|
|
103
|
+
}
|
|
104
|
+
|
|
62
105
|
return;
|
|
63
106
|
}
|
|
64
107
|
|