@mrhenry/stylelint-mrhenry-prop-order 2.0.12 → 2.0.14
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/order.cjs +1 -2
- package/package.json +2 -2
- package/stylelint-mrhenry-prop-order.cjs +15 -11
package/order.cjs
CHANGED
|
@@ -3,7 +3,6 @@ module.exports = [
|
|
|
3
3
|
"align-content",
|
|
4
4
|
"align-items",
|
|
5
5
|
"align-self",
|
|
6
|
-
"align-tracks",
|
|
7
6
|
"alignment-baseline",
|
|
8
7
|
"all",
|
|
9
8
|
"anchor-default",
|
|
@@ -202,6 +201,7 @@ module.exports = [
|
|
|
202
201
|
"display",
|
|
203
202
|
"dominant-baseline",
|
|
204
203
|
"empty-cells",
|
|
204
|
+
"field-sizing",
|
|
205
205
|
"fill",
|
|
206
206
|
"fill-break",
|
|
207
207
|
"fill-color",
|
|
@@ -303,7 +303,6 @@ module.exports = [
|
|
|
303
303
|
"justify-content",
|
|
304
304
|
"justify-items",
|
|
305
305
|
"justify-self",
|
|
306
|
-
"justify-tracks",
|
|
307
306
|
"letter-spacing",
|
|
308
307
|
"lighting-color",
|
|
309
308
|
"line-break",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrhenry/stylelint-mrhenry-prop-order",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14",
|
|
4
4
|
"description": "Mr. Henry's preferred order for CSS properties",
|
|
5
5
|
"main": "stylelint-mrhenry-prop-order.cjs",
|
|
6
6
|
"scripts": {
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"stylelint": "^14.16.1 || ^15.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"stylelint": "^15.
|
|
36
|
+
"stylelint": "^15.11.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -25,8 +25,12 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
|
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
postcssRoot.
|
|
29
|
-
|
|
28
|
+
postcssRoot.walk((container) => {
|
|
29
|
+
if (container.type !== 'atrule' && container.type !== 'rule') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let parent = container;
|
|
30
34
|
while (parent) {
|
|
31
35
|
if (parent.type === 'atrule' && ignoredAtRules.includes(parent.name.toLowerCase())) {
|
|
32
36
|
return;
|
|
@@ -36,14 +40,14 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
|
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
/* c8 ignore next */
|
|
39
|
-
if (!
|
|
43
|
+
if (!container.nodes.length) {
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
// Comments after a node, not one a new line should be kept together with that node.
|
|
44
48
|
// color: red; /* my color */
|
|
45
49
|
let matchedComments = new Map();
|
|
46
|
-
|
|
50
|
+
container.each((node) => {
|
|
47
51
|
if (node.type === 'comment' && !node.raws?.before?.match(/\n/g)) {
|
|
48
52
|
const comment = node;
|
|
49
53
|
const prev = comment.prev();
|
|
@@ -56,7 +60,7 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
|
|
|
56
60
|
});
|
|
57
61
|
|
|
58
62
|
let declarationsSections = [[]];
|
|
59
|
-
|
|
63
|
+
container.each((node) => {
|
|
60
64
|
if (
|
|
61
65
|
node.type === 'decl' &&
|
|
62
66
|
!node.variable &&
|
|
@@ -83,17 +87,17 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
|
|
|
83
87
|
return order.indexOf(a.prop.toLowerCase()) - order.indexOf(b.prop.toLowerCase());
|
|
84
88
|
});
|
|
85
89
|
|
|
86
|
-
const firstNodeIndex = Math.min.apply(Math, section.map((x) =>
|
|
87
|
-
const originalFirstNode =
|
|
90
|
+
const firstNodeIndex = Math.min.apply(Math, section.map((x) => container.index(x)));
|
|
91
|
+
const originalFirstNode = container.nodes[firstNodeIndex];
|
|
88
92
|
|
|
89
93
|
section.forEach((decl, index) => {
|
|
90
94
|
const desiredIndex = firstNodeIndex + index;
|
|
91
|
-
if (
|
|
95
|
+
if (container.index(decl) === desiredIndex) {
|
|
92
96
|
return;
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
if (context.fix) {
|
|
96
|
-
|
|
100
|
+
container.insertBefore(desiredIndex, decl);
|
|
97
101
|
return;
|
|
98
102
|
}
|
|
99
103
|
|
|
@@ -109,7 +113,7 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
|
|
|
109
113
|
}
|
|
110
114
|
});
|
|
111
115
|
|
|
112
|
-
const finalFirstNode =
|
|
116
|
+
const finalFirstNode = container.nodes[firstNodeIndex];
|
|
113
117
|
if (originalFirstNode.raws.before && finalFirstNode.raws.before) {
|
|
114
118
|
const originalRawBefore = originalFirstNode.raws.before;
|
|
115
119
|
originalFirstNode.raws.before = finalFirstNode.raws.before;
|
|
@@ -119,7 +123,7 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
|
|
|
119
123
|
|
|
120
124
|
if (context.fix) {
|
|
121
125
|
for (const [comment, prev] of matchedComments) {
|
|
122
|
-
|
|
126
|
+
container.insertAfter(prev, comment);
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
129
|
});
|