pasika 0.10.145 → 0.10.147
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 +184 -110
- package/package.json +1 -1
|
@@ -11511,9 +11511,99 @@ var themeResetRule = {
|
|
|
11511
11511
|
};
|
|
11512
11512
|
|
|
11513
11513
|
// eslint/rules/tailwind/theme-token-order.ts
|
|
11514
|
+
import path78 from "path";
|
|
11515
|
+
|
|
11516
|
+
// eslint/rules/tailwind/css-consumers.ts
|
|
11514
11517
|
import path77 from "path";
|
|
11515
|
-
|
|
11516
|
-
|
|
11518
|
+
import { generate as generate6, parse as parse7 } from "@eslint/css-tree";
|
|
11519
|
+
function contains2(text, name) {
|
|
11520
|
+
return new RegExp(`(?<![\\w-])${escapeRegExp(name)}(?![\\w-])`, "u").test(text);
|
|
11521
|
+
}
|
|
11522
|
+
function inferCssConsumerPaths(options) {
|
|
11523
|
+
const { graph, css: css2, modules, sourceRoot } = options;
|
|
11524
|
+
const defs = graph.definitions;
|
|
11525
|
+
const components = modules.filter((mod) => {
|
|
11526
|
+
const relative = path77.relative(sourceRoot, mod.path).split(path77.sep).join("/");
|
|
11527
|
+
return /^(?:features\/[\w-]+\/|shared\/|compositions\/)[\w./-]+\.(?:tsx|jsx)$/u.test(relative) && !/\.(?:test|spec|stories)\.(?:tsx|jsx)$/u.test(relative);
|
|
11528
|
+
});
|
|
11529
|
+
const classesByToken = themeClassesForTokens(
|
|
11530
|
+
defs.filter((def) => def.kind === "theme-token").map((def) => def.name),
|
|
11531
|
+
sourceRoot
|
|
11532
|
+
);
|
|
11533
|
+
const consumers = new Map(defs.map((def) => [symbolId(def), /* @__PURE__ */ new Set()]));
|
|
11534
|
+
for (const def of defs) {
|
|
11535
|
+
const refs = graph.references.filter(
|
|
11536
|
+
(ref) => ref.source === "module" && (def.kind === "theme-token" && ref.kind === "theme-class" && ref.token === def.name || def.kind === "utility" && ref.kind === "utility" && ref.name === def.name || def.kind === "selector" && ref.kind === "selector" && ref.name === def.name || def.kind === "keyframes" && ref.kind === "keyframes" && ref.name === def.name)
|
|
11537
|
+
);
|
|
11538
|
+
for (const mod of components) {
|
|
11539
|
+
const explicit = ["theme-token", "root-variable"].includes(def.kind) && contains2(mod.content, def.name) || def.kind === "keyframes" && contains2(mod.content, def.name) || def.kind === "font-face" && new RegExp(`(?:fontFamily|font-family)\\s*[:=]\\s*["']${escapeRegExp(def.name)}`, "iu").test(mod.content);
|
|
11540
|
+
if (explicit || refs.some((ref) => ref.file === mod.path)) {
|
|
11541
|
+
consumers.get(symbolId(def))?.add(path77.relative(sourceRoot, mod.path).split(path77.sep).join("/"));
|
|
11542
|
+
}
|
|
11543
|
+
}
|
|
11544
|
+
}
|
|
11545
|
+
const links = /* @__PURE__ */ new Map();
|
|
11546
|
+
for (const [from, body] of bodiesOf(css2, defs)) {
|
|
11547
|
+
const targets = dependencies(body, defs, classesByToken);
|
|
11548
|
+
const def = defs.find((candidate) => symbolId(candidate) === from);
|
|
11549
|
+
if (def?.kind === "theme-token" && def.name.startsWith("--animate-")) {
|
|
11550
|
+
for (const frame of defs) {
|
|
11551
|
+
if (frame.kind === "keyframes" && contains2(body, frame.name)) {
|
|
11552
|
+
targets.add(symbolId(frame));
|
|
11553
|
+
}
|
|
11554
|
+
}
|
|
11555
|
+
}
|
|
11556
|
+
if (def?.kind === "theme-token" && /^--text-[\w-]+$/u.test(def.name)) {
|
|
11557
|
+
for (const metadata of defs) {
|
|
11558
|
+
if (metadata.kind === "theme-token" && ["--line-height", "--letter-spacing", "--font-weight"].some((suffix) => metadata.name === def.name + suffix)) {
|
|
11559
|
+
targets.add(symbolId(metadata));
|
|
11560
|
+
}
|
|
11561
|
+
}
|
|
11562
|
+
}
|
|
11563
|
+
targets.delete(from);
|
|
11564
|
+
links.set(from, targets);
|
|
11565
|
+
}
|
|
11566
|
+
for (const src of css2) {
|
|
11567
|
+
const ast = parse7(src.content, { positions: true, parseAtrulePrelude: false });
|
|
11568
|
+
if (ast.type !== "StyleSheet") continue;
|
|
11569
|
+
for (const node of ast.children) {
|
|
11570
|
+
if (node.type !== "Atrule" || node.name !== "layer" || !node.loc || !node.prelude || generate6(node.prelude).trim() !== "base") {
|
|
11571
|
+
continue;
|
|
11572
|
+
}
|
|
11573
|
+
const body = src.content.slice(node.loc.start.offset, node.loc.end.offset);
|
|
11574
|
+
for (const target of dependencies(body, defs, classesByToken)) consumers.get(target)?.add("app");
|
|
11575
|
+
}
|
|
11576
|
+
}
|
|
11577
|
+
for (const def of defs) {
|
|
11578
|
+
if (def.kind !== "theme-token") continue;
|
|
11579
|
+
if (["--spacing", "--radius", "--font-sans", "--font-mono"].includes(def.name) || def.name.startsWith("--breakpoint-") || def.name.startsWith("--default-")) {
|
|
11580
|
+
consumers.get(symbolId(def))?.add("app");
|
|
11581
|
+
}
|
|
11582
|
+
}
|
|
11583
|
+
let changed = true;
|
|
11584
|
+
while (changed) {
|
|
11585
|
+
changed = false;
|
|
11586
|
+
for (const [from, targets] of links) {
|
|
11587
|
+
for (const consumer of consumers.get(from) ?? []) {
|
|
11588
|
+
for (const target of targets) {
|
|
11589
|
+
const set = consumers.get(target);
|
|
11590
|
+
if (set && !set.has(consumer)) {
|
|
11591
|
+
set.add(consumer);
|
|
11592
|
+
changed = true;
|
|
11593
|
+
}
|
|
11594
|
+
}
|
|
11595
|
+
}
|
|
11596
|
+
}
|
|
11597
|
+
}
|
|
11598
|
+
return new Map([...consumers].map(([id, paths]) => [id, [...paths].sort()]));
|
|
11599
|
+
}
|
|
11600
|
+
|
|
11601
|
+
// eslint/rules/tailwind/theme-token-order.ts
|
|
11602
|
+
var GROUP_PATH = String.raw`(?:global|src/[\w./-]+\.(?:tsx?|jsx?)|(?:app|features|shared|compositions)(?:/[\w.-]+)*)`;
|
|
11603
|
+
var GROUP_RE = new RegExp(
|
|
11604
|
+
String.raw`^\s*/\*\s*(?:Group:\s*)?(?<paths>${GROUP_PATH}(?:\s*,\s*${GROUP_PATH})*)\s*\*/\s*$`,
|
|
11605
|
+
"u"
|
|
11606
|
+
);
|
|
11517
11607
|
function normalizeGroup(label) {
|
|
11518
11608
|
if (label === "global") return "global";
|
|
11519
11609
|
return [...new Set(label.split(",").map((name) => name.trim()))].sort().join(", ");
|
|
@@ -11524,27 +11614,26 @@ function sectionOf(symbol) {
|
|
|
11524
11614
|
if (symbol.kind === "keyframes") return "keyframes";
|
|
11525
11615
|
return symbol.kind;
|
|
11526
11616
|
}
|
|
11527
|
-
function
|
|
11528
|
-
const
|
|
11529
|
-
|
|
11530
|
-
return false;
|
|
11531
|
-
}
|
|
11532
|
-
if (symbol.kind === "theme-token") {
|
|
11533
|
-
return ref.kind === "theme-class" && ref.token === symbol.name || ref.kind === "variable" && ref.name === symbol.name;
|
|
11534
|
-
}
|
|
11535
|
-
if (symbol.kind === "utility" || symbol.kind === "keyframes" || symbol.kind === "selector") {
|
|
11536
|
-
return ref.name === symbol.name;
|
|
11537
|
-
}
|
|
11538
|
-
return ref.kind === "variable" && ref.name === symbol.name;
|
|
11539
|
-
});
|
|
11540
|
-
const indirect = graph.references.some(
|
|
11541
|
-
(ref) => ref.source === "css" && ref.file !== symbol.file && (symbol.kind === "theme-token" && ref.kind === "variable" && ref.name === symbol.name || symbol.kind === "utility" && ref.kind === "utility" && ref.name === symbol.name || symbol.kind === "keyframes" && ref.kind === "keyframes" && ref.name === symbol.name)
|
|
11617
|
+
function scopeOf(symbol, sheet) {
|
|
11618
|
+
const enclosing = [...sheet.children].find(
|
|
11619
|
+
(node) => node.loc && node.loc.start.line <= symbol.line && node.loc.end.line >= symbol.line
|
|
11542
11620
|
);
|
|
11543
|
-
if (
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
return
|
|
11621
|
+
if (!enclosing?.loc) return "top-level";
|
|
11622
|
+
if (symbol.kind === "theme-token" || symbol.kind === "root-variable" || enclosing.type === "Atrule" && enclosing.name === "layer") {
|
|
11623
|
+
return `block:${enclosing.loc.start.offset.toString()}`;
|
|
11624
|
+
}
|
|
11625
|
+
return "top-level";
|
|
11626
|
+
}
|
|
11627
|
+
function groupForConsumers(consumers) {
|
|
11628
|
+
if (consumers.length === 1) return consumers[0] ?? "";
|
|
11629
|
+
return [
|
|
11630
|
+
...new Set(
|
|
11631
|
+
consumers.map((consumer) => {
|
|
11632
|
+
const parts = consumer.split("/");
|
|
11633
|
+
return parts[0] === "features" ? parts.slice(0, 2).join("/") : parts[0] ?? "";
|
|
11634
|
+
})
|
|
11635
|
+
)
|
|
11636
|
+
].sort().join(", ");
|
|
11548
11637
|
}
|
|
11549
11638
|
var themeTokenOrderRule = {
|
|
11550
11639
|
meta: {
|
|
@@ -11552,22 +11641,21 @@ var themeTokenOrderRule = {
|
|
|
11552
11641
|
type: "problem",
|
|
11553
11642
|
fixable: "code",
|
|
11554
11643
|
docs: {
|
|
11555
|
-
description: "Group CSS definitions by
|
|
11644
|
+
description: "Group CSS definitions by the narrowest consumer paths and alphabetical order."
|
|
11556
11645
|
}
|
|
11557
11646
|
},
|
|
11558
11647
|
create(context) {
|
|
11559
11648
|
const root = sourceRootOf(context);
|
|
11560
|
-
const current =
|
|
11649
|
+
const current = path78.normalize(path78.resolve(context.filename));
|
|
11561
11650
|
const textOf = cachedTextReader();
|
|
11562
|
-
const cssFiles = /* @__PURE__ */ new Set([...findFiles(root, CSS_EXTENSIONS).map((file) =>
|
|
11563
|
-
const
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
});
|
|
11651
|
+
const cssFiles = /* @__PURE__ */ new Set([...findFiles(root, CSS_EXTENSIONS).map((file) => path78.normalize(file)), current]);
|
|
11652
|
+
const css2 = [...cssFiles].map((file) => ({
|
|
11653
|
+
path: file,
|
|
11654
|
+
content: path78.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
11655
|
+
}));
|
|
11656
|
+
const modules = findFiles(root, MODULE_EXTENSIONS4).map((file) => ({ path: file, content: textOf(file) }));
|
|
11657
|
+
const graph = buildCssDependencyGraph({ sourceRoot: root, css: css2, modules });
|
|
11658
|
+
const consumers = inferCssConsumerPaths({ graph, css: css2, modules, sourceRoot: root });
|
|
11571
11659
|
const lines = context.sourceCode.text.split(/\r?\n/u);
|
|
11572
11660
|
const groups = [];
|
|
11573
11661
|
for (const [index, line] of lines.entries()) {
|
|
@@ -11578,50 +11666,36 @@ var themeTokenOrderRule = {
|
|
|
11578
11666
|
(symbol) => ["theme-token", "utility", "keyframes", "root-variable", "selector", "font-face"].includes(symbol.kind)
|
|
11579
11667
|
).map((symbol) => ({
|
|
11580
11668
|
symbol,
|
|
11581
|
-
owner:
|
|
11582
|
-
section: sectionOf(symbol)
|
|
11669
|
+
owner: groupForConsumers(consumers.get(symbolId(symbol)) ?? []),
|
|
11670
|
+
section: sectionOf(symbol),
|
|
11671
|
+
scope: scopeOf(symbol, context.sourceCode.ast)
|
|
11583
11672
|
})).sort((a, b) => a.symbol.line - b.symbol.line);
|
|
11584
11673
|
let activeGroup;
|
|
11585
11674
|
let previousItem;
|
|
11586
11675
|
for (const item of items) {
|
|
11587
11676
|
const previousLine = previousItem?.symbol.line ?? 0;
|
|
11588
11677
|
const intervening = groups.filter((group) => group.line > previousLine && group.line < item.symbol.line).at(-1);
|
|
11589
|
-
|
|
11678
|
+
const previousScope = previousItem?.scope;
|
|
11679
|
+
if (item.section !== previousItem?.section || item.scope !== previousScope) activeGroup = intervening;
|
|
11590
11680
|
else if (intervening) activeGroup = intervening;
|
|
11591
11681
|
item.group = activeGroup;
|
|
11592
11682
|
previousItem = item;
|
|
11593
11683
|
}
|
|
11594
11684
|
return {
|
|
11595
11685
|
"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
|
-
}
|
|
11612
11686
|
let previous;
|
|
11613
11687
|
for (const item of items) {
|
|
11614
11688
|
const currentGroup = item.group;
|
|
11615
11689
|
const actual = currentGroup?.label;
|
|
11616
11690
|
const reportedGroup = actual ?? "none";
|
|
11617
11691
|
let message;
|
|
11618
|
-
if (item.owner
|
|
11619
|
-
message = "
|
|
11620
|
-
} else if (
|
|
11621
|
-
message = `CSS definition "${item.symbol.name}" requires a
|
|
11622
|
-
} else if (
|
|
11692
|
+
if (!item.owner) {
|
|
11693
|
+
message = `CSS definition "${item.symbol.name}" has no traceable consumer; reference it or remove it.`;
|
|
11694
|
+
} else if (!currentGroup) {
|
|
11695
|
+
message = `CSS definition "${item.symbol.name}" requires a consumer-path group comment.`;
|
|
11696
|
+
} else if (actual !== item.owner) {
|
|
11623
11697
|
message = `CSS definition "${item.symbol.name}" belongs to group "${item.owner}", not "${reportedGroup}".`;
|
|
11624
|
-
} else if (previous?.section === item.section) {
|
|
11698
|
+
} else if (previous?.section === item.section && previous.scope === item.scope) {
|
|
11625
11699
|
if (previous.owner !== item.owner && previous.owner.localeCompare(item.owner) > 0) {
|
|
11626
11700
|
message = `CSS consumer groups in ${item.section} must be ordered alphabetically by path.`;
|
|
11627
11701
|
} else if (previous.owner === item.owner && previous.symbol.name.localeCompare(item.symbol.name) > 0) {
|
|
@@ -11634,7 +11708,7 @@ var themeTokenOrderRule = {
|
|
|
11634
11708
|
node,
|
|
11635
11709
|
loc: { start: { line, column: 1 }, end: { line, column: 2 } },
|
|
11636
11710
|
message,
|
|
11637
|
-
...item.owner
|
|
11711
|
+
...item.owner && currentGroup && actual !== item.owner && items.filter((candidate) => candidate.group === currentGroup).length === 1 ? {
|
|
11638
11712
|
fix(fixer) {
|
|
11639
11713
|
const start = context.sourceCode.getIndexFromLoc({ line: currentGroup.line, column: 1 });
|
|
11640
11714
|
const end = start + (lines[currentGroup.line - 1] ?? "").length;
|
|
@@ -11651,7 +11725,7 @@ var themeTokenOrderRule = {
|
|
|
11651
11725
|
};
|
|
11652
11726
|
|
|
11653
11727
|
// eslint/rules/tailwind/unique-css-definition.ts
|
|
11654
|
-
import
|
|
11728
|
+
import path79 from "path";
|
|
11655
11729
|
function ownershipKey(symbol) {
|
|
11656
11730
|
if (symbol.kind === "selector") return void 0;
|
|
11657
11731
|
if (symbol.kind === "root-variable" && symbol.scope !== "default") return void 0;
|
|
@@ -11683,7 +11757,7 @@ var uniqueCssDefinitionRule = {
|
|
|
11683
11757
|
},
|
|
11684
11758
|
create(context) {
|
|
11685
11759
|
const sourceRoot = sourceRootOf(context);
|
|
11686
|
-
const current =
|
|
11760
|
+
const current = path79.normalize(path79.resolve(context.filename));
|
|
11687
11761
|
const cssFiles = findFiles(sourceRoot, CSS_EXTENSIONS);
|
|
11688
11762
|
if (cssFiles.length === 0) return {};
|
|
11689
11763
|
const textOf = cachedTextReader();
|
|
@@ -11691,7 +11765,7 @@ var uniqueCssDefinitionRule = {
|
|
|
11691
11765
|
sourceRoot,
|
|
11692
11766
|
css: cssFiles.map((file) => ({
|
|
11693
11767
|
path: file,
|
|
11694
|
-
content:
|
|
11768
|
+
content: path79.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
11695
11769
|
})),
|
|
11696
11770
|
modules: [],
|
|
11697
11771
|
includeReferences: false
|
|
@@ -11713,7 +11787,7 @@ var uniqueCssDefinitionRule = {
|
|
|
11713
11787
|
if (!canonical) continue;
|
|
11714
11788
|
for (const symbol of definitions.slice(1)) {
|
|
11715
11789
|
if (symbol.file !== current) continue;
|
|
11716
|
-
const message = symbol.file === canonical.file ? `${symbolLabel(symbol)} "${symbol.name}" is defined more than once in this CSS file; define it only once.` : `${symbolLabel(symbol)} "${symbol.name}" is also defined in ${
|
|
11790
|
+
const message = symbol.file === canonical.file ? `${symbolLabel(symbol)} "${symbol.name}" is defined more than once in this CSS file; define it only once.` : `${symbolLabel(symbol)} "${symbol.name}" is also defined in ${path79.relative(sourceRoot, canonical.file)}; define it in only one CSS file.`;
|
|
11717
11791
|
context.report({
|
|
11718
11792
|
node,
|
|
11719
11793
|
loc: {
|
|
@@ -11730,7 +11804,7 @@ var uniqueCssDefinitionRule = {
|
|
|
11730
11804
|
};
|
|
11731
11805
|
|
|
11732
11806
|
// eslint/rules/tailwind/unique-css-token-value.ts
|
|
11733
|
-
import
|
|
11807
|
+
import path80 from "path";
|
|
11734
11808
|
|
|
11735
11809
|
// eslint/rules/tailwind/css-named-colors.ts
|
|
11736
11810
|
var CSS_NAMED_COLORS = {
|
|
@@ -11971,14 +12045,14 @@ var uniqueCssTokenValueRule = {
|
|
|
11971
12045
|
},
|
|
11972
12046
|
create(context) {
|
|
11973
12047
|
const sourceRoot = sourceRootOf(context);
|
|
11974
|
-
const current =
|
|
12048
|
+
const current = path80.normalize(path80.resolve(context.filename));
|
|
11975
12049
|
const textOf = cachedTextReader();
|
|
11976
12050
|
const cssFiles = findFiles(sourceRoot, CSS_EXTENSIONS);
|
|
11977
12051
|
const graph = buildCssDependencyGraph({
|
|
11978
12052
|
sourceRoot,
|
|
11979
12053
|
css: cssFiles.map((file) => ({
|
|
11980
12054
|
path: file,
|
|
11981
|
-
content:
|
|
12055
|
+
content: path80.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
11982
12056
|
})),
|
|
11983
12057
|
modules: [],
|
|
11984
12058
|
includeReferences: false
|
|
@@ -12032,7 +12106,7 @@ var uniqueCssTokenValueRule = {
|
|
|
12032
12106
|
start: { line: definition.line, column: 1 },
|
|
12033
12107
|
end: { line: definition.line, column: 2 }
|
|
12034
12108
|
},
|
|
12035
|
-
message: `Token "${definition.name}" duplicates the value of "${original.name}" in ${
|
|
12109
|
+
message: `Token "${definition.name}" duplicates the value of "${original.name}" in ${path80.relative(
|
|
12036
12110
|
sourceRoot,
|
|
12037
12111
|
original.file
|
|
12038
12112
|
)}:${String(original.line)}; reuse one design token.`
|
|
@@ -12045,7 +12119,7 @@ var uniqueCssTokenValueRule = {
|
|
|
12045
12119
|
|
|
12046
12120
|
// eslint/rules/tailwind/unused-css-definition.ts
|
|
12047
12121
|
import { statSync as statSync5 } from "fs";
|
|
12048
|
-
import
|
|
12122
|
+
import path81 from "path";
|
|
12049
12123
|
function isImplicitThemeToken(name) {
|
|
12050
12124
|
return name === "--spacing" || name === "--radius" || name === "--font-sans" || name === "--font-mono" || name.startsWith("--breakpoint-") || name.startsWith("--default-");
|
|
12051
12125
|
}
|
|
@@ -12097,7 +12171,7 @@ var unusedCssDefinitionRule = {
|
|
|
12097
12171
|
} catch {
|
|
12098
12172
|
return {};
|
|
12099
12173
|
}
|
|
12100
|
-
const current =
|
|
12174
|
+
const current = path81.normalize(path81.resolve(context.filename));
|
|
12101
12175
|
const textOf = cachedTextReader();
|
|
12102
12176
|
const cssFiles = findFiles(sourceRoot, CSS_EXTENSIONS);
|
|
12103
12177
|
const moduleContents = findFiles(sourceRoot, MODULE_EXTENSIONS4).map((file) => ({
|
|
@@ -12108,7 +12182,7 @@ var unusedCssDefinitionRule = {
|
|
|
12108
12182
|
sourceRoot,
|
|
12109
12183
|
css: cssFiles.map((file) => ({
|
|
12110
12184
|
path: file,
|
|
12111
|
-
content:
|
|
12185
|
+
content: path81.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
12112
12186
|
})),
|
|
12113
12187
|
modules: moduleContents
|
|
12114
12188
|
});
|
|
@@ -12136,7 +12210,7 @@ var unusedCssDefinitionRule = {
|
|
|
12136
12210
|
// eslint/rules/tailwind/utility-mapping.ts
|
|
12137
12211
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
12138
12212
|
import { existsSync as existsSync12 } from "fs";
|
|
12139
|
-
import
|
|
12213
|
+
import path82 from "path";
|
|
12140
12214
|
function applyOperationCount(utility, textOf) {
|
|
12141
12215
|
let count = 0;
|
|
12142
12216
|
for (const apply of atrulesNamed(utility, "apply")) {
|
|
@@ -12491,13 +12565,13 @@ var utilityMappingRule = {
|
|
|
12491
12565
|
},
|
|
12492
12566
|
create(context) {
|
|
12493
12567
|
const sourceRoot = sourceRootOf(context);
|
|
12494
|
-
const current =
|
|
12568
|
+
const current = path82.normalize(path82.resolve(context.filename));
|
|
12495
12569
|
const textOf = cachedTextReader();
|
|
12496
12570
|
const graph = buildCssDependencyGraph({
|
|
12497
12571
|
sourceRoot,
|
|
12498
12572
|
css: findFiles(sourceRoot, CSS_EXTENSIONS).map((file) => ({
|
|
12499
12573
|
path: file,
|
|
12500
|
-
content:
|
|
12574
|
+
content: path82.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
12501
12575
|
})),
|
|
12502
12576
|
modules: [],
|
|
12503
12577
|
includeReferences: false
|
|
@@ -12650,8 +12724,8 @@ var utilityMappingRule = {
|
|
|
12650
12724
|
const generatorCandidates = utilities.map(
|
|
12651
12725
|
(utility) => themeCandidate(preludeIdentifiers(utility)[0] ?? "unknown", context.sourceCode.getText(utility))
|
|
12652
12726
|
).filter((candidate) => Boolean(candidate && requiresGeneratorProbe(candidate)));
|
|
12653
|
-
const physicalDir =
|
|
12654
|
-
const tailwindCwd =
|
|
12727
|
+
const physicalDir = path82.dirname(context.physicalFilename);
|
|
12728
|
+
const tailwindCwd = path82.isAbsolute(physicalDir) && existsSync12(physicalDir) ? physicalDir : context.cwd;
|
|
12655
12729
|
const themeGenerators = themeSupportedGenerators(generatorCandidates, tailwindCwd);
|
|
12656
12730
|
for (const utility of utilities) {
|
|
12657
12731
|
const name = preludeIdentifiers(utility)[0] ?? "unknown";
|
|
@@ -12761,8 +12835,8 @@ var utilityMappingRule = {
|
|
|
12761
12835
|
// eslint/rules/tailwind/utility-name-parity.ts
|
|
12762
12836
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
12763
12837
|
import { existsSync as existsSync13 } from "fs";
|
|
12764
|
-
import
|
|
12765
|
-
import { generate as
|
|
12838
|
+
import path83 from "path";
|
|
12839
|
+
import { generate as generate7, parse as parse8, toPlainObject as toPlainObject2 } from "@eslint/css-tree";
|
|
12766
12840
|
function numericPart(value) {
|
|
12767
12841
|
const match = /^(?<negative>-?)(?<number>(?:\d+(?:\.\d+)?|\.\d+))(?<unit>%|px|rem|em|vw|vh|dvw|dvh|ch|fr|s|ms|deg|turn)?$/u.exec(
|
|
12768
12842
|
value
|
|
@@ -12854,7 +12928,7 @@ function compileApplies(applies, cwd) {
|
|
|
12854
12928
|
}
|
|
12855
12929
|
function compiledOperation(compiled, index) {
|
|
12856
12930
|
if (!compiled.css) return void 0;
|
|
12857
|
-
const sheet = toPlainObject2(
|
|
12931
|
+
const sheet = toPlainObject2(parse8(compiled.css, { parseValue: false }));
|
|
12858
12932
|
const probe = rules(sheet).find((candidate) => selectorNames(candidate).includes(`pasika-probe-${String(index)}`));
|
|
12859
12933
|
if (!probe) return void 0;
|
|
12860
12934
|
const declarations = blockChildren2(probe).filter(
|
|
@@ -12868,10 +12942,10 @@ function compiledOperation(compiled, index) {
|
|
|
12868
12942
|
(child) => child.type === "Declaration" && child.property === "--tw-shadow"
|
|
12869
12943
|
);
|
|
12870
12944
|
if (shadow?.type === "Declaration") {
|
|
12871
|
-
return { property: "box-shadow", value:
|
|
12945
|
+
return { property: "box-shadow", value: generate7(shadow.value).trim() };
|
|
12872
12946
|
}
|
|
12873
12947
|
}
|
|
12874
|
-
return { property: declaration.property, value:
|
|
12948
|
+
return { property: declaration.property, value: generate7(declaration.value).trim() };
|
|
12875
12949
|
}
|
|
12876
12950
|
function propertyPrefix(property) {
|
|
12877
12951
|
return property.replace(/^-+/u, "").replace(/^background-/u, "bg-");
|
|
@@ -12905,8 +12979,8 @@ var utilityNameParityRule = {
|
|
|
12905
12979
|
return apply ? [{ utility, name, apply }] : [];
|
|
12906
12980
|
});
|
|
12907
12981
|
if (candidates.length === 0) return;
|
|
12908
|
-
const physicalDir =
|
|
12909
|
-
const cwd =
|
|
12982
|
+
const physicalDir = path83.dirname(context.physicalFilename);
|
|
12983
|
+
const cwd = path83.isAbsolute(physicalDir) && existsSync13(physicalDir) ? physicalDir : context.cwd;
|
|
12910
12984
|
const compiled = compileApplies(
|
|
12911
12985
|
candidates.map((candidate) => candidate.apply),
|
|
12912
12986
|
cwd
|
|
@@ -12975,7 +13049,7 @@ var tailwindRules = {
|
|
|
12975
13049
|
};
|
|
12976
13050
|
|
|
12977
13051
|
// eslint/rules/type-extraction.ts
|
|
12978
|
-
import
|
|
13052
|
+
import path84 from "path";
|
|
12979
13053
|
var typeExtractionRule = {
|
|
12980
13054
|
meta: {
|
|
12981
13055
|
schema: [],
|
|
@@ -12986,7 +13060,7 @@ var typeExtractionRule = {
|
|
|
12986
13060
|
},
|
|
12987
13061
|
create(context) {
|
|
12988
13062
|
const sourceRoot = sourceRootOf(context);
|
|
12989
|
-
const file =
|
|
13063
|
+
const file = path84.resolve(context.filename);
|
|
12990
13064
|
const segments = segmentsOf(file, sourceRoot);
|
|
12991
13065
|
if (segments.length === 0) return {};
|
|
12992
13066
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -13127,7 +13201,7 @@ var uiStateRule = {
|
|
|
13127
13201
|
// eslint/rules/unknown-utility.ts
|
|
13128
13202
|
import { existsSync as existsSync14, readdirSync as readdirSync6, readFileSync as readFileSync16, statSync as statSync6 } from "fs";
|
|
13129
13203
|
import { createRequire } from "module";
|
|
13130
|
-
import
|
|
13204
|
+
import path85 from "path";
|
|
13131
13205
|
var PREFIX_NAMESPACES = {
|
|
13132
13206
|
bg: ["color", "background-image"],
|
|
13133
13207
|
text: ["color", "text"],
|
|
@@ -13415,7 +13489,7 @@ function stylesheetFiles(dir) {
|
|
|
13415
13489
|
}
|
|
13416
13490
|
return entries.flatMap((entry) => {
|
|
13417
13491
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
13418
|
-
const entryPath =
|
|
13492
|
+
const entryPath = path85.join(dir, entry);
|
|
13419
13493
|
let stats;
|
|
13420
13494
|
try {
|
|
13421
13495
|
stats = statSync6(entryPath);
|
|
@@ -13423,7 +13497,7 @@ function stylesheetFiles(dir) {
|
|
|
13423
13497
|
return [];
|
|
13424
13498
|
}
|
|
13425
13499
|
if (stats.isDirectory()) return stylesheetFiles(entryPath);
|
|
13426
|
-
return
|
|
13500
|
+
return path85.extname(entry) === ".css" ? [entryPath] : [];
|
|
13427
13501
|
});
|
|
13428
13502
|
}
|
|
13429
13503
|
function packageNameOf(specifier) {
|
|
@@ -13434,10 +13508,10 @@ function packageNameOf(specifier) {
|
|
|
13434
13508
|
function resolvePackageStylesheet(fromFile, specifier) {
|
|
13435
13509
|
const packageName = packageNameOf(specifier);
|
|
13436
13510
|
if (!packageName || packageName === "tailwindcss") return void 0;
|
|
13437
|
-
let directory =
|
|
13438
|
-
while (directory !==
|
|
13439
|
-
const packageRoot =
|
|
13440
|
-
const manifestPath =
|
|
13511
|
+
let directory = path85.dirname(fromFile);
|
|
13512
|
+
while (directory !== path85.dirname(directory)) {
|
|
13513
|
+
const packageRoot = path85.join(directory, "node_modules", packageName);
|
|
13514
|
+
const manifestPath = path85.join(packageRoot, "package.json");
|
|
13441
13515
|
if (existsSync14(manifestPath)) {
|
|
13442
13516
|
try {
|
|
13443
13517
|
const manifest = readFileSync16(manifestPath, "utf8");
|
|
@@ -13445,13 +13519,13 @@ function resolvePackageStylesheet(fromFile, specifier) {
|
|
|
13445
13519
|
const main = /"main"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
13446
13520
|
const target = stylesheet ?? main;
|
|
13447
13521
|
if (!target) return void 0;
|
|
13448
|
-
const resolved =
|
|
13522
|
+
const resolved = path85.resolve(packageRoot, target);
|
|
13449
13523
|
return existsSync14(resolved) ? resolved : void 0;
|
|
13450
13524
|
} catch {
|
|
13451
13525
|
return void 0;
|
|
13452
13526
|
}
|
|
13453
13527
|
}
|
|
13454
|
-
directory =
|
|
13528
|
+
directory = path85.dirname(directory);
|
|
13455
13529
|
}
|
|
13456
13530
|
return void 0;
|
|
13457
13531
|
}
|
|
@@ -13733,7 +13807,7 @@ var unknownUtilityRule = {
|
|
|
13733
13807
|
};
|
|
13734
13808
|
|
|
13735
13809
|
// eslint/rules/util-file-name.ts
|
|
13736
|
-
import
|
|
13810
|
+
import path86 from "path";
|
|
13737
13811
|
function toKebabCase2(value) {
|
|
13738
13812
|
return value.replace(/(?<lower>[a-z0-9])(?<upper>[A-Z])/g, "$<lower>-$<upper>").replace(/(?<first>[A-Z])(?<rest>[A-Z][a-z])/g, "$<first>-$<rest>").toLowerCase();
|
|
13739
13813
|
}
|
|
@@ -13746,7 +13820,7 @@ var utilFileNameRule = {
|
|
|
13746
13820
|
}
|
|
13747
13821
|
},
|
|
13748
13822
|
create(context) {
|
|
13749
|
-
const filename =
|
|
13823
|
+
const filename = path86.resolve(context.filename);
|
|
13750
13824
|
const segments = filename.replace(/\\/g, "/").split("/");
|
|
13751
13825
|
if (!segments.includes("utils")) return {};
|
|
13752
13826
|
let module;
|
|
@@ -13760,13 +13834,13 @@ var utilFileNameRule = {
|
|
|
13760
13834
|
const functionName = functions[0]?.name;
|
|
13761
13835
|
if (!functionName) return {};
|
|
13762
13836
|
const expected = toKebabCase2(functionName);
|
|
13763
|
-
const actual =
|
|
13837
|
+
const actual = path86.basename(filename, path86.extname(filename));
|
|
13764
13838
|
if (!expected || actual === expected) return {};
|
|
13765
13839
|
return {
|
|
13766
13840
|
Program(node) {
|
|
13767
13841
|
context.report({
|
|
13768
13842
|
node,
|
|
13769
|
-
message: `A utility file exporting ${functionName} must be named ${expected}.${
|
|
13843
|
+
message: `A utility file exporting ${functionName} must be named ${expected}.${path86.extname(filename).slice(1)}.`
|
|
13770
13844
|
});
|
|
13771
13845
|
}
|
|
13772
13846
|
};
|
|
@@ -13774,7 +13848,7 @@ var utilFileNameRule = {
|
|
|
13774
13848
|
};
|
|
13775
13849
|
|
|
13776
13850
|
// eslint/rules/value-extraction.ts
|
|
13777
|
-
import
|
|
13851
|
+
import path87 from "path";
|
|
13778
13852
|
var valueExtractionRule = {
|
|
13779
13853
|
meta: {
|
|
13780
13854
|
schema: [],
|
|
@@ -13785,7 +13859,7 @@ var valueExtractionRule = {
|
|
|
13785
13859
|
},
|
|
13786
13860
|
create(context) {
|
|
13787
13861
|
const sourceRoot = sourceRootOf(context);
|
|
13788
|
-
const file =
|
|
13862
|
+
const file = path87.resolve(context.filename);
|
|
13789
13863
|
const segments = segmentsOf(file, sourceRoot);
|
|
13790
13864
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
13791
13865
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -13807,7 +13881,7 @@ var valueExtractionRule = {
|
|
|
13807
13881
|
|
|
13808
13882
|
// eslint/rules/vulyk/tracked-docs.ts
|
|
13809
13883
|
import { existsSync as existsSync15, readFileSync as readFileSync17 } from "fs";
|
|
13810
|
-
import
|
|
13884
|
+
import path88 from "path";
|
|
13811
13885
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
13812
13886
|
var BASE_REQUIRED_TRACKED_DOCS = [
|
|
13813
13887
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -13840,8 +13914,8 @@ var trackedDocsRule = {
|
|
|
13840
13914
|
if (!context.filename.endsWith("package.json")) return;
|
|
13841
13915
|
const root = node.body;
|
|
13842
13916
|
if (root.type !== "Object") return;
|
|
13843
|
-
const projectRoot =
|
|
13844
|
-
const configPath =
|
|
13917
|
+
const projectRoot = path88.dirname(path88.resolve(context.filename));
|
|
13918
|
+
const configPath = path88.join(projectRoot, "vulyk.config.ts");
|
|
13845
13919
|
if (!existsSync15(configPath)) {
|
|
13846
13920
|
context.report({
|
|
13847
13921
|
node,
|
|
@@ -13866,7 +13940,7 @@ var trackedDocsRule = {
|
|
|
13866
13940
|
});
|
|
13867
13941
|
}
|
|
13868
13942
|
}
|
|
13869
|
-
const agentsPath =
|
|
13943
|
+
const agentsPath = path88.join(projectRoot, "AGENTS.md");
|
|
13870
13944
|
if (!existsSync15(agentsPath)) {
|
|
13871
13945
|
context.report({
|
|
13872
13946
|
node,
|
|
@@ -13966,7 +14040,7 @@ var withResponseHelperRule = {
|
|
|
13966
14040
|
|
|
13967
14041
|
// eslint/rules/zirka-baseline.ts
|
|
13968
14042
|
import fs7 from "fs";
|
|
13969
|
-
import
|
|
14043
|
+
import path89 from "path";
|
|
13970
14044
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
13971
14045
|
var PRETTIER_CONFIGS = [
|
|
13972
14046
|
"prettier.config.mjs",
|
|
@@ -13985,10 +14059,10 @@ var zirkaBaselineRule = {
|
|
|
13985
14059
|
}
|
|
13986
14060
|
},
|
|
13987
14061
|
create(context) {
|
|
13988
|
-
const filename =
|
|
13989
|
-
const basename =
|
|
14062
|
+
const filename = path89.resolve(context.filename);
|
|
14063
|
+
const basename = path89.basename(filename);
|
|
13990
14064
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
13991
|
-
const projectRoot =
|
|
14065
|
+
const projectRoot = path89.dirname(filename);
|
|
13992
14066
|
const report3 = (message) => {
|
|
13993
14067
|
context.report({
|
|
13994
14068
|
node: context.sourceCode.ast,
|
|
@@ -14003,7 +14077,7 @@ var zirkaBaselineRule = {
|
|
|
14003
14077
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
14004
14078
|
);
|
|
14005
14079
|
}
|
|
14006
|
-
const tsconfigPath =
|
|
14080
|
+
const tsconfigPath = path89.join(projectRoot, "tsconfig.json");
|
|
14007
14081
|
if (!fs7.existsSync(tsconfigPath)) {
|
|
14008
14082
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
14009
14083
|
} else {
|
|
@@ -14021,13 +14095,13 @@ var zirkaBaselineRule = {
|
|
|
14021
14095
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
14022
14096
|
}
|
|
14023
14097
|
}
|
|
14024
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(
|
|
14098
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(path89.join(projectRoot, name)));
|
|
14025
14099
|
if (!prettierConfigFile) {
|
|
14026
14100
|
report3(
|
|
14027
14101
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
14028
14102
|
);
|
|
14029
14103
|
} else {
|
|
14030
|
-
const content = fs7.readFileSync(
|
|
14104
|
+
const content = fs7.readFileSync(path89.join(projectRoot, prettierConfigFile), "utf8");
|
|
14031
14105
|
if (!content.includes("zirka")) {
|
|
14032
14106
|
report3(
|
|
14033
14107
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|