pasika 0.10.122 → 0.10.123
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 +37 -4
- package/package.json +1 -1
|
@@ -10627,7 +10627,7 @@ import path72 from "path";
|
|
|
10627
10627
|
import { generate as generate3, parse as parse6, walk as walk3 } from "@eslint/css-tree";
|
|
10628
10628
|
var INLINE_MESSAGE = "Define design tokens with direct values in @theme, not @theme inline.";
|
|
10629
10629
|
var INDIRECT_MESSAGE = "Define design tokens that reference CSS variables via var() in @theme inline.";
|
|
10630
|
-
var MIXED_THEME_MESSAGE = "Use either @theme or @theme inline across the project
|
|
10630
|
+
var MIXED_THEME_MESSAGE = "Use either @theme or @theme inline across the project; external font-loader mappings with valid fallbacks are the only exception.";
|
|
10631
10631
|
var REDUNDANT_INLINE_MESSAGE = (name) => `Tailwind token "${name}" has no runtime overrides; define its value directly in @theme instead of using :root and @theme inline.`;
|
|
10632
10632
|
var EXTERNAL_FONT_FALLBACK_MESSAGE = (name, variable) => `Tailwind font token "${name}" references external font "${variable}" without a fallback inside var(); use var(${variable}, Arial) or another font-family fallback.`;
|
|
10633
10633
|
function hasVarFallback(source, variable) {
|
|
@@ -10644,7 +10644,7 @@ var rootVariablesRule = {
|
|
|
10644
10644
|
schema: [],
|
|
10645
10645
|
type: "problem",
|
|
10646
10646
|
docs: {
|
|
10647
|
-
description: "Require @theme for fixed tokens, matching :root variables for @theme inline tokens, and no other token redeclarations."
|
|
10647
|
+
description: "Require @theme for fixed tokens and fixed-token aliases, matching :root variables for @theme inline tokens, and no other token redeclarations."
|
|
10648
10648
|
}
|
|
10649
10649
|
},
|
|
10650
10650
|
create(context) {
|
|
@@ -10661,12 +10661,26 @@ var rootVariablesRule = {
|
|
|
10661
10661
|
modules: [],
|
|
10662
10662
|
includeReferences: false
|
|
10663
10663
|
});
|
|
10664
|
+
const themeValues = new Map(
|
|
10665
|
+
graph.definitions.filter((symbol) => symbol.kind === "theme-token" && symbol.value !== void 0).map((symbol) => [symbol.name, symbol.value ?? ""])
|
|
10666
|
+
);
|
|
10664
10667
|
const names = new Set(
|
|
10665
10668
|
graph.definitions.filter((symbol) => symbol.kind === "theme-token").map((symbol) => symbol.name)
|
|
10666
10669
|
);
|
|
10670
|
+
function isFixedThemeAlias(name, value, visited = /* @__PURE__ */ new Set()) {
|
|
10671
|
+
const match = /^var\(\s*(?<target>--[a-z][\w-]*)\s*\)$/u.exec(value.trim());
|
|
10672
|
+
const target = match?.groups?.target;
|
|
10673
|
+
if (!target || target === name || visited.has(target)) return false;
|
|
10674
|
+
const next = themeValues.get(target);
|
|
10675
|
+
if (!next) return false;
|
|
10676
|
+
if (!/\bvar\s*\(/u.test(next)) return true;
|
|
10677
|
+
visited.add(target);
|
|
10678
|
+
return isFixedThemeAlias(name, next, visited);
|
|
10679
|
+
}
|
|
10667
10680
|
const mirroredTokens = /* @__PURE__ */ new Set();
|
|
10668
10681
|
let hasPlainThemeBlocks = false;
|
|
10669
10682
|
let hasInlineThemeBlocks = false;
|
|
10683
|
+
let inlineBlocksAreExternalFonts = true;
|
|
10670
10684
|
for (const file of [...stylesheets.filter((candidate) => path72.normalize(candidate) !== current), current]) {
|
|
10671
10685
|
const source = (path72.normalize(file) === current ? context.sourceCode.text : textOf(file)).replace(
|
|
10672
10686
|
/\/\*[\s\S]*?\*\//gu,
|
|
@@ -10676,6 +10690,25 @@ var rootVariablesRule = {
|
|
|
10676
10690
|
if (/\binline\b/u.test(header.groups?.options ?? "")) hasInlineThemeBlocks = true;
|
|
10677
10691
|
else hasPlainThemeBlocks = true;
|
|
10678
10692
|
}
|
|
10693
|
+
const inlineHeaders = [...source.matchAll(/@theme\s+inline\s*\{/gu)];
|
|
10694
|
+
const inlineBlocks = [...source.matchAll(/@theme\s+inline\s*\{(?<body>[^{}]*)\}/gu)];
|
|
10695
|
+
if (inlineHeaders.length !== inlineBlocks.length) inlineBlocksAreExternalFonts = false;
|
|
10696
|
+
for (const block of inlineBlocks) {
|
|
10697
|
+
const declarations = (block.groups?.body ?? "").split(";").map((part) => part.trim()).filter(Boolean);
|
|
10698
|
+
if (declarations.length === 0) inlineBlocksAreExternalFonts = false;
|
|
10699
|
+
for (const declaration of declarations) {
|
|
10700
|
+
const match = /^(?<token>--font-[a-z][\w-]*)\s*:\s*(?<value>.+)$/u.exec(declaration);
|
|
10701
|
+
const name = match?.groups?.token;
|
|
10702
|
+
const value = match?.groups?.value ?? "";
|
|
10703
|
+
const references = [...value.matchAll(/\bvar\s*\(\s*(?<name>--[\w-]+)/gu)].map(
|
|
10704
|
+
(reference) => reference.groups?.name
|
|
10705
|
+
);
|
|
10706
|
+
const runtime = references[0];
|
|
10707
|
+
if (!name || references.length !== 1 || !runtime?.startsWith("--font-") || runtime === name || names.has(runtime) || !hasVarFallback(value, runtime)) {
|
|
10708
|
+
inlineBlocksAreExternalFonts = false;
|
|
10709
|
+
}
|
|
10710
|
+
}
|
|
10711
|
+
}
|
|
10679
10712
|
for (const theme of source.matchAll(/@theme(?<options>(?:\s+[\w-]+)*)\s*\{(?<body>[^{}]*)\}/gu)) {
|
|
10680
10713
|
const inline = /\binline\b/u.test(theme.groups?.options ?? "");
|
|
10681
10714
|
for (const declaration of (theme.groups?.body ?? "").matchAll(
|
|
@@ -10715,7 +10748,7 @@ var rootVariablesRule = {
|
|
|
10715
10748
|
return {
|
|
10716
10749
|
"StyleSheet:exit"(node) {
|
|
10717
10750
|
const localThemes = atrulesNamed(node, "theme");
|
|
10718
|
-
if (hasPlainThemeBlocks && hasInlineThemeBlocks && localThemes[0]) {
|
|
10751
|
+
if (hasPlainThemeBlocks && hasInlineThemeBlocks && !inlineBlocksAreExternalFonts && localThemes[0]) {
|
|
10719
10752
|
context.report({ node: localThemes[0], message: MIXED_THEME_MESSAGE });
|
|
10720
10753
|
}
|
|
10721
10754
|
for (const theme of localThemes) {
|
|
@@ -10757,7 +10790,7 @@ var rootVariablesRule = {
|
|
|
10757
10790
|
context.report({ node: theme, message: REDUNDANT_INLINE_MESSAGE(name) });
|
|
10758
10791
|
}
|
|
10759
10792
|
}
|
|
10760
|
-
if (inline === referencesVariable) continue;
|
|
10793
|
+
if (inline === referencesVariable || !inline && isFixedThemeAlias(name, unquoted)) continue;
|
|
10761
10794
|
const offset = (theme.loc?.start.offset ?? 0) + match.index + match[0].indexOf(name);
|
|
10762
10795
|
const preceding = context.sourceCode.text.slice(0, offset);
|
|
10763
10796
|
const line = preceding.split("\n").length;
|