@mrhenry/stylelint-mrhenry-prop-order 3.0.11 → 3.0.13
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/index.mjs +37 -29
- package/order.mjs +2 -7
- package/package.json +2 -2
package/index.mjs
CHANGED
|
@@ -49,8 +49,7 @@ const ruleFunction = (primaryOption, secondaryOption, context) => {
|
|
|
49
49
|
parent = parent.parent;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
// Comments after a node, not one a new line should be kept together with that node.
|
|
52
|
+
// Comments after a node, not on a new line should be kept together with that node.
|
|
54
53
|
// color: red; /* my color */
|
|
55
54
|
let matchedComments = new Map();
|
|
56
55
|
container.each((node) => {
|
|
@@ -60,13 +59,16 @@ const ruleFunction = (primaryOption, secondaryOption, context) => {
|
|
|
60
59
|
|
|
61
60
|
if (prev) {
|
|
62
61
|
matchedComments.set(comment, prev);
|
|
63
|
-
comment.remove();
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
});
|
|
67
65
|
|
|
68
66
|
let declarationsSections = [[]];
|
|
69
67
|
container.each((node) => {
|
|
68
|
+
if (matchedComments.has(node)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
70
72
|
if (
|
|
71
73
|
node.type === 'decl' &&
|
|
72
74
|
!node.variable &&
|
|
@@ -89,46 +91,52 @@ const ruleFunction = (primaryOption, secondaryOption, context) => {
|
|
|
89
91
|
});
|
|
90
92
|
|
|
91
93
|
declarationsSections.forEach((section) => {
|
|
92
|
-
|
|
94
|
+
const sortedSection = [...section];
|
|
95
|
+
sortedSection.sort((a, b) => {
|
|
93
96
|
return order.indexOf(a.prop.toLowerCase()) - order.indexOf(b.prop.toLowerCase());
|
|
94
97
|
});
|
|
95
98
|
|
|
96
99
|
const firstNodeIndex = Math.min.apply(Math, section.map((x) => container.index(x)));
|
|
97
100
|
const originalFirstNode = container.nodes[firstNodeIndex];
|
|
98
101
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
if (!context.fix) {
|
|
103
|
+
sortedSection.forEach((decl, index) => {
|
|
104
|
+
const oldIndex = section.indexOf(decl);
|
|
105
|
+
if (index === oldIndex) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (index < section.length - 1) {
|
|
110
|
+
stylelint.utils.report({
|
|
111
|
+
message: messages.expected(decl.prop),
|
|
112
|
+
node: decl,
|
|
113
|
+
index: 0,
|
|
114
|
+
endIndex: decl.prop.length,
|
|
115
|
+
result: postcssResult,
|
|
116
|
+
ruleName,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
104
121
|
|
|
105
|
-
|
|
106
|
-
|
|
122
|
+
if (context.fix) {
|
|
123
|
+
sortedSection.reverse().forEach((decl) => {
|
|
124
|
+
container.insertBefore(firstNodeIndex, decl);
|
|
107
125
|
return;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const finalFirstNode = container.nodes[firstNodeIndex];
|
|
129
|
+
if (originalFirstNode.raws.before && finalFirstNode.raws.before) {
|
|
130
|
+
const originalRawBefore = originalFirstNode.raws.before;
|
|
131
|
+
originalFirstNode.raws.before = finalFirstNode.raws.before;
|
|
132
|
+
finalFirstNode.raws.before = originalRawBefore;
|
|
108
133
|
}
|
|
109
|
-
|
|
110
|
-
if (index < section.length - 1) {
|
|
111
|
-
stylelint.utils.report({
|
|
112
|
-
message: messages.expected(decl.prop),
|
|
113
|
-
node: decl,
|
|
114
|
-
index: 0,
|
|
115
|
-
endIndex: decl.prop.length,
|
|
116
|
-
result: postcssResult,
|
|
117
|
-
ruleName,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const finalFirstNode = container.nodes[firstNodeIndex];
|
|
123
|
-
if (originalFirstNode.raws.before && finalFirstNode.raws.before) {
|
|
124
|
-
const originalRawBefore = originalFirstNode.raws.before;
|
|
125
|
-
originalFirstNode.raws.before = finalFirstNode.raws.before;
|
|
126
|
-
finalFirstNode.raws.before = originalRawBefore;
|
|
127
134
|
}
|
|
128
135
|
});
|
|
129
136
|
|
|
130
137
|
if (context.fix) {
|
|
131
138
|
for (const [comment, prev] of matchedComments) {
|
|
139
|
+
comment.remove();
|
|
132
140
|
container.insertAfter(prev, comment);
|
|
133
141
|
}
|
|
134
142
|
}
|
package/order.mjs
CHANGED
|
@@ -302,7 +302,7 @@ export const order = [
|
|
|
302
302
|
"inset-block",
|
|
303
303
|
"inset-block-start",
|
|
304
304
|
"inset-block-end",
|
|
305
|
-
"
|
|
305
|
+
"interpolate-size",
|
|
306
306
|
"isolation",
|
|
307
307
|
"justify-content",
|
|
308
308
|
"justify-items",
|
|
@@ -356,7 +356,6 @@ export const order = [
|
|
|
356
356
|
"mask-repeat",
|
|
357
357
|
"mask-size",
|
|
358
358
|
"mask-type",
|
|
359
|
-
"masonry-auto-flow",
|
|
360
359
|
"math-depth",
|
|
361
360
|
"math-shift",
|
|
362
361
|
"math-style",
|
|
@@ -435,6 +434,7 @@ export const order = [
|
|
|
435
434
|
"pointer-events",
|
|
436
435
|
"position",
|
|
437
436
|
"position-anchor",
|
|
437
|
+
"position-area",
|
|
438
438
|
"position-try",
|
|
439
439
|
"position-try-order",
|
|
440
440
|
"position-try-fallbacks",
|
|
@@ -483,11 +483,6 @@ export const order = [
|
|
|
483
483
|
"scroll-snap-align",
|
|
484
484
|
"scroll-snap-stop",
|
|
485
485
|
"scroll-snap-type",
|
|
486
|
-
"scroll-start",
|
|
487
|
-
"scroll-start-inline",
|
|
488
|
-
"scroll-start-block",
|
|
489
|
-
"scroll-start-x",
|
|
490
|
-
"scroll-start-y",
|
|
491
486
|
"scroll-start-target",
|
|
492
487
|
"scroll-timeline",
|
|
493
488
|
"scroll-timeline-axis",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrhenry/stylelint-mrhenry-prop-order",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.13",
|
|
4
4
|
"description": "Mr. Henry's preferred order for CSS properties",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.mjs",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"stylelint": "^16.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"stylelint": "^16.
|
|
33
|
+
"stylelint": "^16.7.0"
|
|
34
34
|
}
|
|
35
35
|
}
|