pasika 0.10.144 → 0.10.145
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/eslint/pasika/index.js +38 -10
- package/package.json +1 -1
|
@@ -11578,26 +11578,54 @@ var themeTokenOrderRule = {
|
|
|
11578
11578
|
(symbol) => ["theme-token", "utility", "keyframes", "root-variable", "selector", "font-face"].includes(symbol.kind)
|
|
11579
11579
|
).map((symbol) => ({
|
|
11580
11580
|
symbol,
|
|
11581
|
-
group: groups.filter((group) => group.line < symbol.line).at(-1),
|
|
11582
11581
|
owner: ownerOf(symbol, graph, root),
|
|
11583
11582
|
section: sectionOf(symbol)
|
|
11584
11583
|
})).sort((a, b) => a.symbol.line - b.symbol.line);
|
|
11584
|
+
let activeGroup;
|
|
11585
|
+
let previousItem;
|
|
11586
|
+
for (const item of items) {
|
|
11587
|
+
const previousLine = previousItem?.symbol.line ?? 0;
|
|
11588
|
+
const intervening = groups.filter((group) => group.line > previousLine && group.line < item.symbol.line).at(-1);
|
|
11589
|
+
if (item.section !== previousItem?.section) activeGroup = intervening;
|
|
11590
|
+
else if (intervening) activeGroup = intervening;
|
|
11591
|
+
item.group = activeGroup;
|
|
11592
|
+
previousItem = item;
|
|
11593
|
+
}
|
|
11585
11594
|
return {
|
|
11586
11595
|
"StyleSheet:exit"(node) {
|
|
11596
|
+
for (const group of groups.filter((entry) => entry.label === "global")) {
|
|
11597
|
+
context.report({
|
|
11598
|
+
node,
|
|
11599
|
+
loc: { start: { line: group.line, column: 1 }, end: { line: group.line, column: 2 } },
|
|
11600
|
+
message: "Global CSS definitions must not have a group comment.",
|
|
11601
|
+
fix(fixer) {
|
|
11602
|
+
const start = context.sourceCode.getIndexFromLoc({ line: group.line, column: 1 });
|
|
11603
|
+
const end = start + (lines[group.line - 1] ?? "").length;
|
|
11604
|
+
const remaining = context.sourceCode.text.slice(end);
|
|
11605
|
+
let newline = 0;
|
|
11606
|
+
if (remaining.startsWith("\r\n")) newline = 2;
|
|
11607
|
+
else if (remaining.startsWith("\n")) newline = 1;
|
|
11608
|
+
return fixer.removeRange([start, end + newline]);
|
|
11609
|
+
}
|
|
11610
|
+
});
|
|
11611
|
+
}
|
|
11587
11612
|
let previous;
|
|
11588
11613
|
for (const item of items) {
|
|
11589
11614
|
const currentGroup = item.group;
|
|
11590
11615
|
const actual = currentGroup?.label;
|
|
11616
|
+
const reportedGroup = actual ?? "none";
|
|
11591
11617
|
let message;
|
|
11592
|
-
if (
|
|
11593
|
-
message =
|
|
11594
|
-
} else if (
|
|
11595
|
-
message = `CSS definition "${item.symbol.name}"
|
|
11596
|
-
} else if (
|
|
11597
|
-
|
|
11618
|
+
if (item.owner === "global" && currentGroup && currentGroup.label !== "global") {
|
|
11619
|
+
message = "Global definitions must be ungrouped.";
|
|
11620
|
+
} else if (item.owner !== "global" && !currentGroup) {
|
|
11621
|
+
message = `CSS definition "${item.symbol.name}" requires a component-path group comment.`;
|
|
11622
|
+
} else if (item.owner !== "global" && actual !== item.owner) {
|
|
11623
|
+
message = `CSS definition "${item.symbol.name}" belongs to group "${item.owner}", not "${reportedGroup}".`;
|
|
11624
|
+
} else if (previous?.section === item.section) {
|
|
11625
|
+
if (previous.owner !== item.owner && previous.owner.localeCompare(item.owner) > 0) {
|
|
11598
11626
|
message = `CSS consumer groups in ${item.section} must be ordered alphabetically by path.`;
|
|
11599
|
-
} else if (previous.
|
|
11600
|
-
message = `CSS definitions in group "${
|
|
11627
|
+
} else if (previous.owner === item.owner && previous.symbol.name.localeCompare(item.symbol.name) > 0) {
|
|
11628
|
+
message = `CSS definitions in group "${item.owner}" must be alphabetical: "${item.symbol.name}" comes before "${previous.symbol.name}".`;
|
|
11601
11629
|
}
|
|
11602
11630
|
}
|
|
11603
11631
|
if (message) {
|
|
@@ -11606,7 +11634,7 @@ var themeTokenOrderRule = {
|
|
|
11606
11634
|
node,
|
|
11607
11635
|
loc: { start: { line, column: 1 }, end: { line, column: 2 } },
|
|
11608
11636
|
message,
|
|
11609
|
-
...currentGroup && actual !== item.owner && items.filter((candidate) => candidate.group === currentGroup).length === 1 ? {
|
|
11637
|
+
...item.owner !== "global" && currentGroup && actual !== item.owner && items.filter((candidate) => candidate.group === currentGroup).length === 1 ? {
|
|
11610
11638
|
fix(fixer) {
|
|
11611
11639
|
const start = context.sourceCode.getIndexFromLoc({ line: currentGroup.line, column: 1 });
|
|
11612
11640
|
const end = start + (lines[currentGroup.line - 1] ?? "").length;
|