@plumeria/eslint-plugin 10.5.1 → 10.5.3
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/dist/rules/sort-properties.js +23 -17
- package/package.json +1 -1
|
@@ -14,28 +14,34 @@ function getPropertyName(property) {
|
|
|
14
14
|
}
|
|
15
15
|
return '';
|
|
16
16
|
}
|
|
17
|
+
const propertyIndexMap = new Map();
|
|
18
|
+
let globalLastGroupIndex = 0;
|
|
19
|
+
let globalMaxPropIndex = 0;
|
|
20
|
+
for (let i = 0; i < propertyGroups_1.propertyGroups.length; i++) {
|
|
21
|
+
const group = propertyGroups_1.propertyGroups[i];
|
|
22
|
+
globalLastGroupIndex = i;
|
|
23
|
+
globalMaxPropIndex = Math.max(globalMaxPropIndex, group.properties.length);
|
|
24
|
+
for (let j = 0; j < group.properties.length; j++) {
|
|
25
|
+
propertyIndexMap.set(group.properties[j], i * 1000 + j);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const pseudoGroupOffset1 = (propertyGroups_1.propertyGroups.length + 1) * 1000;
|
|
29
|
+
const pseudoGroupOffset2 = (propertyGroups_1.propertyGroups.length + 2) * 1000;
|
|
30
|
+
const pseudoGroupOffset3 = (propertyGroups_1.propertyGroups.length + 3) * 1000;
|
|
31
|
+
const defaultOffset = globalLastGroupIndex * 1000 + globalMaxPropIndex + 1;
|
|
17
32
|
function getPropertyIndex(property) {
|
|
18
33
|
const name = getPropertyName(property);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const group = propertyGroups_1.propertyGroups[i];
|
|
23
|
-
const propIndex = group.properties.indexOf(name);
|
|
24
|
-
if (propIndex !== -1) {
|
|
25
|
-
return i * 1000 + propIndex;
|
|
26
|
-
}
|
|
27
|
-
lastGroupIndex = i;
|
|
28
|
-
maxPropIndex = Math.max(maxPropIndex, group.properties.length);
|
|
34
|
+
const cachedIndex = propertyIndexMap.get(name);
|
|
35
|
+
if (cachedIndex !== undefined) {
|
|
36
|
+
return cachedIndex;
|
|
29
37
|
}
|
|
30
38
|
if (name.startsWith(':'))
|
|
31
|
-
return
|
|
39
|
+
return pseudoGroupOffset1;
|
|
32
40
|
if (name.startsWith('&'))
|
|
33
|
-
return
|
|
34
|
-
if (name.startsWith('@media'))
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
return (propertyGroups_1.propertyGroups.length + 3) * 1000;
|
|
38
|
-
return lastGroupIndex * 1000 + maxPropIndex + 1;
|
|
41
|
+
return pseudoGroupOffset2;
|
|
42
|
+
if (name.startsWith('@media') || name.startsWith('@container'))
|
|
43
|
+
return pseudoGroupOffset3;
|
|
44
|
+
return defaultOffset;
|
|
39
45
|
}
|
|
40
46
|
function getLIS(arr) {
|
|
41
47
|
const n = arr.length;
|