pasika 0.10.144 → 0.10.146
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 +51 -11
- package/package.json +1 -1
|
@@ -11524,6 +11524,16 @@ function sectionOf(symbol) {
|
|
|
11524
11524
|
if (symbol.kind === "keyframes") return "keyframes";
|
|
11525
11525
|
return symbol.kind;
|
|
11526
11526
|
}
|
|
11527
|
+
function scopeOf(symbol, sheet) {
|
|
11528
|
+
const enclosing = [...sheet.children].find(
|
|
11529
|
+
(node) => node.loc && node.loc.start.line <= symbol.line && node.loc.end.line >= symbol.line
|
|
11530
|
+
);
|
|
11531
|
+
if (!enclosing?.loc) return "top-level";
|
|
11532
|
+
if (symbol.kind === "theme-token" || symbol.kind === "root-variable" || enclosing.type === "Atrule" && enclosing.name === "layer") {
|
|
11533
|
+
return `block:${enclosing.loc.start.offset.toString()}`;
|
|
11534
|
+
}
|
|
11535
|
+
return "top-level";
|
|
11536
|
+
}
|
|
11527
11537
|
function ownerOf(symbol, graph, root) {
|
|
11528
11538
|
const references = graph.references.filter((ref) => {
|
|
11529
11539
|
if (ref.source !== "module" || !/\.(?:tsx|jsx)$/u.test(ref.file) || /\.(?:test|spec|stories)\.(?:tsx|jsx)$/u.test(ref.file)) {
|
|
@@ -11578,26 +11588,56 @@ var themeTokenOrderRule = {
|
|
|
11578
11588
|
(symbol) => ["theme-token", "utility", "keyframes", "root-variable", "selector", "font-face"].includes(symbol.kind)
|
|
11579
11589
|
).map((symbol) => ({
|
|
11580
11590
|
symbol,
|
|
11581
|
-
group: groups.filter((group) => group.line < symbol.line).at(-1),
|
|
11582
11591
|
owner: ownerOf(symbol, graph, root),
|
|
11583
|
-
section: sectionOf(symbol)
|
|
11592
|
+
section: sectionOf(symbol),
|
|
11593
|
+
scope: scopeOf(symbol, context.sourceCode.ast)
|
|
11584
11594
|
})).sort((a, b) => a.symbol.line - b.symbol.line);
|
|
11595
|
+
let activeGroup;
|
|
11596
|
+
let previousItem;
|
|
11597
|
+
for (const item of items) {
|
|
11598
|
+
const previousLine = previousItem?.symbol.line ?? 0;
|
|
11599
|
+
const intervening = groups.filter((group) => group.line > previousLine && group.line < item.symbol.line).at(-1);
|
|
11600
|
+
const previousScope = previousItem?.scope;
|
|
11601
|
+
if (item.section !== previousItem?.section || item.scope !== previousScope) activeGroup = intervening;
|
|
11602
|
+
else if (intervening) activeGroup = intervening;
|
|
11603
|
+
item.group = activeGroup;
|
|
11604
|
+
previousItem = item;
|
|
11605
|
+
}
|
|
11585
11606
|
return {
|
|
11586
11607
|
"StyleSheet:exit"(node) {
|
|
11608
|
+
for (const group of groups.filter((entry) => entry.label === "global")) {
|
|
11609
|
+
context.report({
|
|
11610
|
+
node,
|
|
11611
|
+
loc: { start: { line: group.line, column: 1 }, end: { line: group.line, column: 2 } },
|
|
11612
|
+
message: "Global CSS definitions must not have a group comment.",
|
|
11613
|
+
fix(fixer) {
|
|
11614
|
+
const start = context.sourceCode.getIndexFromLoc({ line: group.line, column: 1 });
|
|
11615
|
+
const end = start + (lines[group.line - 1] ?? "").length;
|
|
11616
|
+
const remaining = context.sourceCode.text.slice(end);
|
|
11617
|
+
let newline = 0;
|
|
11618
|
+
if (remaining.startsWith("\r\n")) newline = 2;
|
|
11619
|
+
else if (remaining.startsWith("\n")) newline = 1;
|
|
11620
|
+
return fixer.removeRange([start, end + newline]);
|
|
11621
|
+
}
|
|
11622
|
+
});
|
|
11623
|
+
}
|
|
11587
11624
|
let previous;
|
|
11588
11625
|
for (const item of items) {
|
|
11589
11626
|
const currentGroup = item.group;
|
|
11590
11627
|
const actual = currentGroup?.label;
|
|
11628
|
+
const reportedGroup = actual ?? "none";
|
|
11591
11629
|
let message;
|
|
11592
|
-
if (
|
|
11593
|
-
message =
|
|
11594
|
-
} else if (
|
|
11595
|
-
message = `CSS definition "${item.symbol.name}"
|
|
11596
|
-
} else if (
|
|
11597
|
-
|
|
11630
|
+
if (item.owner === "global" && currentGroup && currentGroup.label !== "global") {
|
|
11631
|
+
message = "Global definitions must be ungrouped.";
|
|
11632
|
+
} else if (item.owner !== "global" && !currentGroup) {
|
|
11633
|
+
message = `CSS definition "${item.symbol.name}" requires a component-path group comment.`;
|
|
11634
|
+
} else if (item.owner !== "global" && actual !== item.owner) {
|
|
11635
|
+
message = `CSS definition "${item.symbol.name}" belongs to group "${item.owner}", not "${reportedGroup}".`;
|
|
11636
|
+
} else if (previous?.section === item.section && previous.scope === item.scope) {
|
|
11637
|
+
if (previous.owner !== item.owner && previous.owner.localeCompare(item.owner) > 0) {
|
|
11598
11638
|
message = `CSS consumer groups in ${item.section} must be ordered alphabetically by path.`;
|
|
11599
|
-
} else if (previous.
|
|
11600
|
-
message = `CSS definitions in group "${
|
|
11639
|
+
} else if (previous.owner === item.owner && previous.symbol.name.localeCompare(item.symbol.name) > 0) {
|
|
11640
|
+
message = `CSS definitions in group "${item.owner}" must be alphabetical: "${item.symbol.name}" comes before "${previous.symbol.name}".`;
|
|
11601
11641
|
}
|
|
11602
11642
|
}
|
|
11603
11643
|
if (message) {
|
|
@@ -11606,7 +11646,7 @@ var themeTokenOrderRule = {
|
|
|
11606
11646
|
node,
|
|
11607
11647
|
loc: { start: { line, column: 1 }, end: { line, column: 2 } },
|
|
11608
11648
|
message,
|
|
11609
|
-
...currentGroup && actual !== item.owner && items.filter((candidate) => candidate.group === currentGroup).length === 1 ? {
|
|
11649
|
+
...item.owner !== "global" && currentGroup && actual !== item.owner && items.filter((candidate) => candidate.group === currentGroup).length === 1 ? {
|
|
11610
11650
|
fix(fixer) {
|
|
11611
11651
|
const start = context.sourceCode.getIndexFromLoc({ line: currentGroup.line, column: 1 });
|
|
11612
11652
|
const end = start + (lines[currentGroup.line - 1] ?? "").length;
|