pasika 0.10.146 → 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 +170 -108
- 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(", ");
|
|
@@ -11534,27 +11624,16 @@ function scopeOf(symbol, sheet) {
|
|
|
11534
11624
|
}
|
|
11535
11625
|
return "top-level";
|
|
11536
11626
|
}
|
|
11537
|
-
function
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
}
|
|
11548
|
-
return ref.kind === "variable" && ref.name === symbol.name;
|
|
11549
|
-
});
|
|
11550
|
-
const indirect = graph.references.some(
|
|
11551
|
-
(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)
|
|
11552
|
-
);
|
|
11553
|
-
if (indirect) return "global";
|
|
11554
|
-
const owners = [
|
|
11555
|
-
...new Set(references.map((ref) => path77.relative(path77.dirname(root), ref.file).split(path77.sep).join("/")))
|
|
11556
|
-
].filter((name) => PATH_RE.test(name)).sort();
|
|
11557
|
-
return owners.length > 0 ? owners.join(", ") : "global";
|
|
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(", ");
|
|
11558
11637
|
}
|
|
11559
11638
|
var themeTokenOrderRule = {
|
|
11560
11639
|
meta: {
|
|
@@ -11562,22 +11641,21 @@ var themeTokenOrderRule = {
|
|
|
11562
11641
|
type: "problem",
|
|
11563
11642
|
fixable: "code",
|
|
11564
11643
|
docs: {
|
|
11565
|
-
description: "Group CSS definitions by
|
|
11644
|
+
description: "Group CSS definitions by the narrowest consumer paths and alphabetical order."
|
|
11566
11645
|
}
|
|
11567
11646
|
},
|
|
11568
11647
|
create(context) {
|
|
11569
11648
|
const root = sourceRootOf(context);
|
|
11570
|
-
const current =
|
|
11649
|
+
const current = path78.normalize(path78.resolve(context.filename));
|
|
11571
11650
|
const textOf = cachedTextReader();
|
|
11572
|
-
const cssFiles = /* @__PURE__ */ new Set([...findFiles(root, CSS_EXTENSIONS).map((file) =>
|
|
11573
|
-
const
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
});
|
|
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 });
|
|
11581
11659
|
const lines = context.sourceCode.text.split(/\r?\n/u);
|
|
11582
11660
|
const groups = [];
|
|
11583
11661
|
for (const [index, line] of lines.entries()) {
|
|
@@ -11588,7 +11666,7 @@ var themeTokenOrderRule = {
|
|
|
11588
11666
|
(symbol) => ["theme-token", "utility", "keyframes", "root-variable", "selector", "font-face"].includes(symbol.kind)
|
|
11589
11667
|
).map((symbol) => ({
|
|
11590
11668
|
symbol,
|
|
11591
|
-
owner:
|
|
11669
|
+
owner: groupForConsumers(consumers.get(symbolId(symbol)) ?? []),
|
|
11592
11670
|
section: sectionOf(symbol),
|
|
11593
11671
|
scope: scopeOf(symbol, context.sourceCode.ast)
|
|
11594
11672
|
})).sort((a, b) => a.symbol.line - b.symbol.line);
|
|
@@ -11605,33 +11683,17 @@ var themeTokenOrderRule = {
|
|
|
11605
11683
|
}
|
|
11606
11684
|
return {
|
|
11607
11685
|
"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
|
-
}
|
|
11624
11686
|
let previous;
|
|
11625
11687
|
for (const item of items) {
|
|
11626
11688
|
const currentGroup = item.group;
|
|
11627
11689
|
const actual = currentGroup?.label;
|
|
11628
11690
|
const reportedGroup = actual ?? "none";
|
|
11629
11691
|
let message;
|
|
11630
|
-
if (item.owner
|
|
11631
|
-
message = "
|
|
11632
|
-
} else if (
|
|
11633
|
-
message = `CSS definition "${item.symbol.name}" requires a
|
|
11634
|
-
} 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) {
|
|
11635
11697
|
message = `CSS definition "${item.symbol.name}" belongs to group "${item.owner}", not "${reportedGroup}".`;
|
|
11636
11698
|
} else if (previous?.section === item.section && previous.scope === item.scope) {
|
|
11637
11699
|
if (previous.owner !== item.owner && previous.owner.localeCompare(item.owner) > 0) {
|
|
@@ -11646,7 +11708,7 @@ var themeTokenOrderRule = {
|
|
|
11646
11708
|
node,
|
|
11647
11709
|
loc: { start: { line, column: 1 }, end: { line, column: 2 } },
|
|
11648
11710
|
message,
|
|
11649
|
-
...item.owner
|
|
11711
|
+
...item.owner && currentGroup && actual !== item.owner && items.filter((candidate) => candidate.group === currentGroup).length === 1 ? {
|
|
11650
11712
|
fix(fixer) {
|
|
11651
11713
|
const start = context.sourceCode.getIndexFromLoc({ line: currentGroup.line, column: 1 });
|
|
11652
11714
|
const end = start + (lines[currentGroup.line - 1] ?? "").length;
|
|
@@ -11663,7 +11725,7 @@ var themeTokenOrderRule = {
|
|
|
11663
11725
|
};
|
|
11664
11726
|
|
|
11665
11727
|
// eslint/rules/tailwind/unique-css-definition.ts
|
|
11666
|
-
import
|
|
11728
|
+
import path79 from "path";
|
|
11667
11729
|
function ownershipKey(symbol) {
|
|
11668
11730
|
if (symbol.kind === "selector") return void 0;
|
|
11669
11731
|
if (symbol.kind === "root-variable" && symbol.scope !== "default") return void 0;
|
|
@@ -11695,7 +11757,7 @@ var uniqueCssDefinitionRule = {
|
|
|
11695
11757
|
},
|
|
11696
11758
|
create(context) {
|
|
11697
11759
|
const sourceRoot = sourceRootOf(context);
|
|
11698
|
-
const current =
|
|
11760
|
+
const current = path79.normalize(path79.resolve(context.filename));
|
|
11699
11761
|
const cssFiles = findFiles(sourceRoot, CSS_EXTENSIONS);
|
|
11700
11762
|
if (cssFiles.length === 0) return {};
|
|
11701
11763
|
const textOf = cachedTextReader();
|
|
@@ -11703,7 +11765,7 @@ var uniqueCssDefinitionRule = {
|
|
|
11703
11765
|
sourceRoot,
|
|
11704
11766
|
css: cssFiles.map((file) => ({
|
|
11705
11767
|
path: file,
|
|
11706
|
-
content:
|
|
11768
|
+
content: path79.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
11707
11769
|
})),
|
|
11708
11770
|
modules: [],
|
|
11709
11771
|
includeReferences: false
|
|
@@ -11725,7 +11787,7 @@ var uniqueCssDefinitionRule = {
|
|
|
11725
11787
|
if (!canonical) continue;
|
|
11726
11788
|
for (const symbol of definitions.slice(1)) {
|
|
11727
11789
|
if (symbol.file !== current) continue;
|
|
11728
|
-
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.`;
|
|
11729
11791
|
context.report({
|
|
11730
11792
|
node,
|
|
11731
11793
|
loc: {
|
|
@@ -11742,7 +11804,7 @@ var uniqueCssDefinitionRule = {
|
|
|
11742
11804
|
};
|
|
11743
11805
|
|
|
11744
11806
|
// eslint/rules/tailwind/unique-css-token-value.ts
|
|
11745
|
-
import
|
|
11807
|
+
import path80 from "path";
|
|
11746
11808
|
|
|
11747
11809
|
// eslint/rules/tailwind/css-named-colors.ts
|
|
11748
11810
|
var CSS_NAMED_COLORS = {
|
|
@@ -11983,14 +12045,14 @@ var uniqueCssTokenValueRule = {
|
|
|
11983
12045
|
},
|
|
11984
12046
|
create(context) {
|
|
11985
12047
|
const sourceRoot = sourceRootOf(context);
|
|
11986
|
-
const current =
|
|
12048
|
+
const current = path80.normalize(path80.resolve(context.filename));
|
|
11987
12049
|
const textOf = cachedTextReader();
|
|
11988
12050
|
const cssFiles = findFiles(sourceRoot, CSS_EXTENSIONS);
|
|
11989
12051
|
const graph = buildCssDependencyGraph({
|
|
11990
12052
|
sourceRoot,
|
|
11991
12053
|
css: cssFiles.map((file) => ({
|
|
11992
12054
|
path: file,
|
|
11993
|
-
content:
|
|
12055
|
+
content: path80.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
11994
12056
|
})),
|
|
11995
12057
|
modules: [],
|
|
11996
12058
|
includeReferences: false
|
|
@@ -12044,7 +12106,7 @@ var uniqueCssTokenValueRule = {
|
|
|
12044
12106
|
start: { line: definition.line, column: 1 },
|
|
12045
12107
|
end: { line: definition.line, column: 2 }
|
|
12046
12108
|
},
|
|
12047
|
-
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(
|
|
12048
12110
|
sourceRoot,
|
|
12049
12111
|
original.file
|
|
12050
12112
|
)}:${String(original.line)}; reuse one design token.`
|
|
@@ -12057,7 +12119,7 @@ var uniqueCssTokenValueRule = {
|
|
|
12057
12119
|
|
|
12058
12120
|
// eslint/rules/tailwind/unused-css-definition.ts
|
|
12059
12121
|
import { statSync as statSync5 } from "fs";
|
|
12060
|
-
import
|
|
12122
|
+
import path81 from "path";
|
|
12061
12123
|
function isImplicitThemeToken(name) {
|
|
12062
12124
|
return name === "--spacing" || name === "--radius" || name === "--font-sans" || name === "--font-mono" || name.startsWith("--breakpoint-") || name.startsWith("--default-");
|
|
12063
12125
|
}
|
|
@@ -12109,7 +12171,7 @@ var unusedCssDefinitionRule = {
|
|
|
12109
12171
|
} catch {
|
|
12110
12172
|
return {};
|
|
12111
12173
|
}
|
|
12112
|
-
const current =
|
|
12174
|
+
const current = path81.normalize(path81.resolve(context.filename));
|
|
12113
12175
|
const textOf = cachedTextReader();
|
|
12114
12176
|
const cssFiles = findFiles(sourceRoot, CSS_EXTENSIONS);
|
|
12115
12177
|
const moduleContents = findFiles(sourceRoot, MODULE_EXTENSIONS4).map((file) => ({
|
|
@@ -12120,7 +12182,7 @@ var unusedCssDefinitionRule = {
|
|
|
12120
12182
|
sourceRoot,
|
|
12121
12183
|
css: cssFiles.map((file) => ({
|
|
12122
12184
|
path: file,
|
|
12123
|
-
content:
|
|
12185
|
+
content: path81.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
12124
12186
|
})),
|
|
12125
12187
|
modules: moduleContents
|
|
12126
12188
|
});
|
|
@@ -12148,7 +12210,7 @@ var unusedCssDefinitionRule = {
|
|
|
12148
12210
|
// eslint/rules/tailwind/utility-mapping.ts
|
|
12149
12211
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
12150
12212
|
import { existsSync as existsSync12 } from "fs";
|
|
12151
|
-
import
|
|
12213
|
+
import path82 from "path";
|
|
12152
12214
|
function applyOperationCount(utility, textOf) {
|
|
12153
12215
|
let count = 0;
|
|
12154
12216
|
for (const apply of atrulesNamed(utility, "apply")) {
|
|
@@ -12503,13 +12565,13 @@ var utilityMappingRule = {
|
|
|
12503
12565
|
},
|
|
12504
12566
|
create(context) {
|
|
12505
12567
|
const sourceRoot = sourceRootOf(context);
|
|
12506
|
-
const current =
|
|
12568
|
+
const current = path82.normalize(path82.resolve(context.filename));
|
|
12507
12569
|
const textOf = cachedTextReader();
|
|
12508
12570
|
const graph = buildCssDependencyGraph({
|
|
12509
12571
|
sourceRoot,
|
|
12510
12572
|
css: findFiles(sourceRoot, CSS_EXTENSIONS).map((file) => ({
|
|
12511
12573
|
path: file,
|
|
12512
|
-
content:
|
|
12574
|
+
content: path82.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
12513
12575
|
})),
|
|
12514
12576
|
modules: [],
|
|
12515
12577
|
includeReferences: false
|
|
@@ -12662,8 +12724,8 @@ var utilityMappingRule = {
|
|
|
12662
12724
|
const generatorCandidates = utilities.map(
|
|
12663
12725
|
(utility) => themeCandidate(preludeIdentifiers(utility)[0] ?? "unknown", context.sourceCode.getText(utility))
|
|
12664
12726
|
).filter((candidate) => Boolean(candidate && requiresGeneratorProbe(candidate)));
|
|
12665
|
-
const physicalDir =
|
|
12666
|
-
const tailwindCwd =
|
|
12727
|
+
const physicalDir = path82.dirname(context.physicalFilename);
|
|
12728
|
+
const tailwindCwd = path82.isAbsolute(physicalDir) && existsSync12(physicalDir) ? physicalDir : context.cwd;
|
|
12667
12729
|
const themeGenerators = themeSupportedGenerators(generatorCandidates, tailwindCwd);
|
|
12668
12730
|
for (const utility of utilities) {
|
|
12669
12731
|
const name = preludeIdentifiers(utility)[0] ?? "unknown";
|
|
@@ -12773,8 +12835,8 @@ var utilityMappingRule = {
|
|
|
12773
12835
|
// eslint/rules/tailwind/utility-name-parity.ts
|
|
12774
12836
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
12775
12837
|
import { existsSync as existsSync13 } from "fs";
|
|
12776
|
-
import
|
|
12777
|
-
import { generate as
|
|
12838
|
+
import path83 from "path";
|
|
12839
|
+
import { generate as generate7, parse as parse8, toPlainObject as toPlainObject2 } from "@eslint/css-tree";
|
|
12778
12840
|
function numericPart(value) {
|
|
12779
12841
|
const match = /^(?<negative>-?)(?<number>(?:\d+(?:\.\d+)?|\.\d+))(?<unit>%|px|rem|em|vw|vh|dvw|dvh|ch|fr|s|ms|deg|turn)?$/u.exec(
|
|
12780
12842
|
value
|
|
@@ -12866,7 +12928,7 @@ function compileApplies(applies, cwd) {
|
|
|
12866
12928
|
}
|
|
12867
12929
|
function compiledOperation(compiled, index) {
|
|
12868
12930
|
if (!compiled.css) return void 0;
|
|
12869
|
-
const sheet = toPlainObject2(
|
|
12931
|
+
const sheet = toPlainObject2(parse8(compiled.css, { parseValue: false }));
|
|
12870
12932
|
const probe = rules(sheet).find((candidate) => selectorNames(candidate).includes(`pasika-probe-${String(index)}`));
|
|
12871
12933
|
if (!probe) return void 0;
|
|
12872
12934
|
const declarations = blockChildren2(probe).filter(
|
|
@@ -12880,10 +12942,10 @@ function compiledOperation(compiled, index) {
|
|
|
12880
12942
|
(child) => child.type === "Declaration" && child.property === "--tw-shadow"
|
|
12881
12943
|
);
|
|
12882
12944
|
if (shadow?.type === "Declaration") {
|
|
12883
|
-
return { property: "box-shadow", value:
|
|
12945
|
+
return { property: "box-shadow", value: generate7(shadow.value).trim() };
|
|
12884
12946
|
}
|
|
12885
12947
|
}
|
|
12886
|
-
return { property: declaration.property, value:
|
|
12948
|
+
return { property: declaration.property, value: generate7(declaration.value).trim() };
|
|
12887
12949
|
}
|
|
12888
12950
|
function propertyPrefix(property) {
|
|
12889
12951
|
return property.replace(/^-+/u, "").replace(/^background-/u, "bg-");
|
|
@@ -12917,8 +12979,8 @@ var utilityNameParityRule = {
|
|
|
12917
12979
|
return apply ? [{ utility, name, apply }] : [];
|
|
12918
12980
|
});
|
|
12919
12981
|
if (candidates.length === 0) return;
|
|
12920
|
-
const physicalDir =
|
|
12921
|
-
const cwd =
|
|
12982
|
+
const physicalDir = path83.dirname(context.physicalFilename);
|
|
12983
|
+
const cwd = path83.isAbsolute(physicalDir) && existsSync13(physicalDir) ? physicalDir : context.cwd;
|
|
12922
12984
|
const compiled = compileApplies(
|
|
12923
12985
|
candidates.map((candidate) => candidate.apply),
|
|
12924
12986
|
cwd
|
|
@@ -12987,7 +13049,7 @@ var tailwindRules = {
|
|
|
12987
13049
|
};
|
|
12988
13050
|
|
|
12989
13051
|
// eslint/rules/type-extraction.ts
|
|
12990
|
-
import
|
|
13052
|
+
import path84 from "path";
|
|
12991
13053
|
var typeExtractionRule = {
|
|
12992
13054
|
meta: {
|
|
12993
13055
|
schema: [],
|
|
@@ -12998,7 +13060,7 @@ var typeExtractionRule = {
|
|
|
12998
13060
|
},
|
|
12999
13061
|
create(context) {
|
|
13000
13062
|
const sourceRoot = sourceRootOf(context);
|
|
13001
|
-
const file =
|
|
13063
|
+
const file = path84.resolve(context.filename);
|
|
13002
13064
|
const segments = segmentsOf(file, sourceRoot);
|
|
13003
13065
|
if (segments.length === 0) return {};
|
|
13004
13066
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -13139,7 +13201,7 @@ var uiStateRule = {
|
|
|
13139
13201
|
// eslint/rules/unknown-utility.ts
|
|
13140
13202
|
import { existsSync as existsSync14, readdirSync as readdirSync6, readFileSync as readFileSync16, statSync as statSync6 } from "fs";
|
|
13141
13203
|
import { createRequire } from "module";
|
|
13142
|
-
import
|
|
13204
|
+
import path85 from "path";
|
|
13143
13205
|
var PREFIX_NAMESPACES = {
|
|
13144
13206
|
bg: ["color", "background-image"],
|
|
13145
13207
|
text: ["color", "text"],
|
|
@@ -13427,7 +13489,7 @@ function stylesheetFiles(dir) {
|
|
|
13427
13489
|
}
|
|
13428
13490
|
return entries.flatMap((entry) => {
|
|
13429
13491
|
if (entry.startsWith(".") || entry === "node_modules") return [];
|
|
13430
|
-
const entryPath =
|
|
13492
|
+
const entryPath = path85.join(dir, entry);
|
|
13431
13493
|
let stats;
|
|
13432
13494
|
try {
|
|
13433
13495
|
stats = statSync6(entryPath);
|
|
@@ -13435,7 +13497,7 @@ function stylesheetFiles(dir) {
|
|
|
13435
13497
|
return [];
|
|
13436
13498
|
}
|
|
13437
13499
|
if (stats.isDirectory()) return stylesheetFiles(entryPath);
|
|
13438
|
-
return
|
|
13500
|
+
return path85.extname(entry) === ".css" ? [entryPath] : [];
|
|
13439
13501
|
});
|
|
13440
13502
|
}
|
|
13441
13503
|
function packageNameOf(specifier) {
|
|
@@ -13446,10 +13508,10 @@ function packageNameOf(specifier) {
|
|
|
13446
13508
|
function resolvePackageStylesheet(fromFile, specifier) {
|
|
13447
13509
|
const packageName = packageNameOf(specifier);
|
|
13448
13510
|
if (!packageName || packageName === "tailwindcss") return void 0;
|
|
13449
|
-
let directory =
|
|
13450
|
-
while (directory !==
|
|
13451
|
-
const packageRoot =
|
|
13452
|
-
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");
|
|
13453
13515
|
if (existsSync14(manifestPath)) {
|
|
13454
13516
|
try {
|
|
13455
13517
|
const manifest = readFileSync16(manifestPath, "utf8");
|
|
@@ -13457,13 +13519,13 @@ function resolvePackageStylesheet(fromFile, specifier) {
|
|
|
13457
13519
|
const main = /"main"\s*:\s*"(?<file>[^"]+\.css)"/.exec(manifest)?.groups?.file;
|
|
13458
13520
|
const target = stylesheet ?? main;
|
|
13459
13521
|
if (!target) return void 0;
|
|
13460
|
-
const resolved =
|
|
13522
|
+
const resolved = path85.resolve(packageRoot, target);
|
|
13461
13523
|
return existsSync14(resolved) ? resolved : void 0;
|
|
13462
13524
|
} catch {
|
|
13463
13525
|
return void 0;
|
|
13464
13526
|
}
|
|
13465
13527
|
}
|
|
13466
|
-
directory =
|
|
13528
|
+
directory = path85.dirname(directory);
|
|
13467
13529
|
}
|
|
13468
13530
|
return void 0;
|
|
13469
13531
|
}
|
|
@@ -13745,7 +13807,7 @@ var unknownUtilityRule = {
|
|
|
13745
13807
|
};
|
|
13746
13808
|
|
|
13747
13809
|
// eslint/rules/util-file-name.ts
|
|
13748
|
-
import
|
|
13810
|
+
import path86 from "path";
|
|
13749
13811
|
function toKebabCase2(value) {
|
|
13750
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();
|
|
13751
13813
|
}
|
|
@@ -13758,7 +13820,7 @@ var utilFileNameRule = {
|
|
|
13758
13820
|
}
|
|
13759
13821
|
},
|
|
13760
13822
|
create(context) {
|
|
13761
|
-
const filename =
|
|
13823
|
+
const filename = path86.resolve(context.filename);
|
|
13762
13824
|
const segments = filename.replace(/\\/g, "/").split("/");
|
|
13763
13825
|
if (!segments.includes("utils")) return {};
|
|
13764
13826
|
let module;
|
|
@@ -13772,13 +13834,13 @@ var utilFileNameRule = {
|
|
|
13772
13834
|
const functionName = functions[0]?.name;
|
|
13773
13835
|
if (!functionName) return {};
|
|
13774
13836
|
const expected = toKebabCase2(functionName);
|
|
13775
|
-
const actual =
|
|
13837
|
+
const actual = path86.basename(filename, path86.extname(filename));
|
|
13776
13838
|
if (!expected || actual === expected) return {};
|
|
13777
13839
|
return {
|
|
13778
13840
|
Program(node) {
|
|
13779
13841
|
context.report({
|
|
13780
13842
|
node,
|
|
13781
|
-
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)}.`
|
|
13782
13844
|
});
|
|
13783
13845
|
}
|
|
13784
13846
|
};
|
|
@@ -13786,7 +13848,7 @@ var utilFileNameRule = {
|
|
|
13786
13848
|
};
|
|
13787
13849
|
|
|
13788
13850
|
// eslint/rules/value-extraction.ts
|
|
13789
|
-
import
|
|
13851
|
+
import path87 from "path";
|
|
13790
13852
|
var valueExtractionRule = {
|
|
13791
13853
|
meta: {
|
|
13792
13854
|
schema: [],
|
|
@@ -13797,7 +13859,7 @@ var valueExtractionRule = {
|
|
|
13797
13859
|
},
|
|
13798
13860
|
create(context) {
|
|
13799
13861
|
const sourceRoot = sourceRootOf(context);
|
|
13800
|
-
const file =
|
|
13862
|
+
const file = path87.resolve(context.filename);
|
|
13801
13863
|
const segments = segmentsOf(file, sourceRoot);
|
|
13802
13864
|
if (segments.length === 0 || segments[0] !== "app") return {};
|
|
13803
13865
|
const index = getProjectIndex(sourceRoot);
|
|
@@ -13819,7 +13881,7 @@ var valueExtractionRule = {
|
|
|
13819
13881
|
|
|
13820
13882
|
// eslint/rules/vulyk/tracked-docs.ts
|
|
13821
13883
|
import { existsSync as existsSync15, readFileSync as readFileSync17 } from "fs";
|
|
13822
|
-
import
|
|
13884
|
+
import path88 from "path";
|
|
13823
13885
|
var PASIKA_REPO = "Bredansky/pasika";
|
|
13824
13886
|
var BASE_REQUIRED_TRACKED_DOCS = [
|
|
13825
13887
|
{ name: "documentation-guide", path: "docs/documentation-guide" },
|
|
@@ -13852,8 +13914,8 @@ var trackedDocsRule = {
|
|
|
13852
13914
|
if (!context.filename.endsWith("package.json")) return;
|
|
13853
13915
|
const root = node.body;
|
|
13854
13916
|
if (root.type !== "Object") return;
|
|
13855
|
-
const projectRoot =
|
|
13856
|
-
const configPath =
|
|
13917
|
+
const projectRoot = path88.dirname(path88.resolve(context.filename));
|
|
13918
|
+
const configPath = path88.join(projectRoot, "vulyk.config.ts");
|
|
13857
13919
|
if (!existsSync15(configPath)) {
|
|
13858
13920
|
context.report({
|
|
13859
13921
|
node,
|
|
@@ -13878,7 +13940,7 @@ var trackedDocsRule = {
|
|
|
13878
13940
|
});
|
|
13879
13941
|
}
|
|
13880
13942
|
}
|
|
13881
|
-
const agentsPath =
|
|
13943
|
+
const agentsPath = path88.join(projectRoot, "AGENTS.md");
|
|
13882
13944
|
if (!existsSync15(agentsPath)) {
|
|
13883
13945
|
context.report({
|
|
13884
13946
|
node,
|
|
@@ -13978,7 +14040,7 @@ var withResponseHelperRule = {
|
|
|
13978
14040
|
|
|
13979
14041
|
// eslint/rules/zirka-baseline.ts
|
|
13980
14042
|
import fs7 from "fs";
|
|
13981
|
-
import
|
|
14043
|
+
import path89 from "path";
|
|
13982
14044
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
13983
14045
|
var PRETTIER_CONFIGS = [
|
|
13984
14046
|
"prettier.config.mjs",
|
|
@@ -13997,10 +14059,10 @@ var zirkaBaselineRule = {
|
|
|
13997
14059
|
}
|
|
13998
14060
|
},
|
|
13999
14061
|
create(context) {
|
|
14000
|
-
const filename =
|
|
14001
|
-
const basename =
|
|
14062
|
+
const filename = path89.resolve(context.filename);
|
|
14063
|
+
const basename = path89.basename(filename);
|
|
14002
14064
|
if (!ESLINT_CONFIG.test(basename)) return {};
|
|
14003
|
-
const projectRoot =
|
|
14065
|
+
const projectRoot = path89.dirname(filename);
|
|
14004
14066
|
const report3 = (message) => {
|
|
14005
14067
|
context.report({
|
|
14006
14068
|
node: context.sourceCode.ast,
|
|
@@ -14015,7 +14077,7 @@ var zirkaBaselineRule = {
|
|
|
14015
14077
|
'ESLint config must take its configuration from zirka (import { styleguide } from "zirka") instead of restating rules locally.'
|
|
14016
14078
|
);
|
|
14017
14079
|
}
|
|
14018
|
-
const tsconfigPath =
|
|
14080
|
+
const tsconfigPath = path89.join(projectRoot, "tsconfig.json");
|
|
14019
14081
|
if (!fs7.existsSync(tsconfigPath)) {
|
|
14020
14082
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
14021
14083
|
} else {
|
|
@@ -14033,13 +14095,13 @@ var zirkaBaselineRule = {
|
|
|
14033
14095
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
14034
14096
|
}
|
|
14035
14097
|
}
|
|
14036
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(
|
|
14098
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs7.existsSync(path89.join(projectRoot, name)));
|
|
14037
14099
|
if (!prettierConfigFile) {
|
|
14038
14100
|
report3(
|
|
14039
14101
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
14040
14102
|
);
|
|
14041
14103
|
} else {
|
|
14042
|
-
const content = fs7.readFileSync(
|
|
14104
|
+
const content = fs7.readFileSync(path89.join(projectRoot, prettierConfigFile), "utf8");
|
|
14043
14105
|
if (!content.includes("zirka")) {
|
|
14044
14106
|
report3(
|
|
14045
14107
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|