pasika 0.10.141 → 0.10.143
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 -2
- package/package.json +1 -1
|
@@ -10093,6 +10093,16 @@ var baseLayerPairRule = {
|
|
|
10093
10093
|
return {
|
|
10094
10094
|
"StyleSheet:exit"(node) {
|
|
10095
10095
|
const applied = collectBodyUtilities(node);
|
|
10096
|
+
const themeColors = /* @__PURE__ */ new Set();
|
|
10097
|
+
const collectThemeColors = (source) => {
|
|
10098
|
+
const uncommented = source.replace(/\/\*[\s\S]*?\*\//gu, " ");
|
|
10099
|
+
for (const theme of uncommented.matchAll(/@theme(?:\s+[\w-]+)*\s*\{(?<body>[^}]*)\}/gu)) {
|
|
10100
|
+
for (const token of (theme.groups?.body ?? "").matchAll(/(?:^|[;\r\n])\s*--color-(?<name>[\w-]+)\s*:/gu)) {
|
|
10101
|
+
if (token.groups?.name) themeColors.add(token.groups.name);
|
|
10102
|
+
}
|
|
10103
|
+
}
|
|
10104
|
+
};
|
|
10105
|
+
collectThemeColors(context.sourceCode.text);
|
|
10096
10106
|
const seen = /* @__PURE__ */ new Set([current]);
|
|
10097
10107
|
const queue = [{ file: current, source: context.sourceCode.text }];
|
|
10098
10108
|
const textOf = cachedTextReader();
|
|
@@ -10106,6 +10116,7 @@ var baseLayerPairRule = {
|
|
|
10106
10116
|
if (seen.has(filename) || !existsSync8(filename)) continue;
|
|
10107
10117
|
seen.add(filename);
|
|
10108
10118
|
const source = textOf(filename);
|
|
10119
|
+
collectThemeColors(source);
|
|
10109
10120
|
const parsed = toPlainObject(parse3(source, { parseAtrulePrelude: true }));
|
|
10110
10121
|
if (parsed.type !== "StyleSheet") continue;
|
|
10111
10122
|
const fragment = collectBodyUtilities(parsed);
|
|
@@ -10115,8 +10126,12 @@ var baseLayerPairRule = {
|
|
|
10115
10126
|
}
|
|
10116
10127
|
}
|
|
10117
10128
|
if (!applied.hasBaseLayer) return;
|
|
10118
|
-
const hasCanvas = applied.names.some(
|
|
10119
|
-
|
|
10129
|
+
const hasCanvas = applied.names.some(
|
|
10130
|
+
(name) => name.includes("canvas") || name.startsWith("bg-") && themeColors.has(name.slice(3))
|
|
10131
|
+
);
|
|
10132
|
+
const hasInk = applied.names.some(
|
|
10133
|
+
(name) => name.includes("ink") || name.startsWith("text-") && themeColors.has(name.slice(5))
|
|
10134
|
+
);
|
|
10120
10135
|
if (!hasCanvas || !hasInk) {
|
|
10121
10136
|
context.report({
|
|
10122
10137
|
node,
|
|
@@ -11966,6 +11981,16 @@ var uniqueCssTokenValueRule = {
|
|
|
11966
11981
|
group.push(definition);
|
|
11967
11982
|
byValue.set(value, group);
|
|
11968
11983
|
}
|
|
11984
|
+
const fixedHslPrimitives = new Map(
|
|
11985
|
+
graph.definitions.filter((symbol) => symbol.kind === "theme-token" && symbol.value !== void 0).filter((symbol) => /^\s*\d+(?:\.\d+)?\s+\d+(?:\.\d+)?%\s+\d+(?:\.\d+)?%\s*$/u.test(symbol.value ?? "")).map((symbol) => [symbol.name, symbol])
|
|
11986
|
+
);
|
|
11987
|
+
const wrappedPrimitives = /* @__PURE__ */ new Map();
|
|
11988
|
+
for (const symbol of graph.definitions) {
|
|
11989
|
+
if (symbol.kind !== "theme-token" || !symbol.name.startsWith("--color-")) continue;
|
|
11990
|
+
const primitive = /^hsl\(\s*var\(\s*(?<name>--[\w-]+)\s*\)\s*\)$/u.exec(symbol.value ?? "")?.groups?.name;
|
|
11991
|
+
const original = primitive ? fixedHslPrimitives.get(primitive) : void 0;
|
|
11992
|
+
if (original && original.name !== symbol.name) wrappedPrimitives.set(symbol, original);
|
|
11993
|
+
}
|
|
11969
11994
|
const redundant = /* @__PURE__ */ new Map();
|
|
11970
11995
|
for (const group of byValue.values()) {
|
|
11971
11996
|
group.sort(compareLocations);
|
|
@@ -11978,6 +12003,17 @@ var uniqueCssTokenValueRule = {
|
|
|
11978
12003
|
}
|
|
11979
12004
|
return {
|
|
11980
12005
|
"StyleSheet:exit"(node) {
|
|
12006
|
+
for (const [definition, primitive] of wrappedPrimitives) {
|
|
12007
|
+
if (definition.file !== current) continue;
|
|
12008
|
+
context.report({
|
|
12009
|
+
node,
|
|
12010
|
+
loc: {
|
|
12011
|
+
start: { line: definition.line, column: 1 },
|
|
12012
|
+
end: { line: definition.line, column: 2 }
|
|
12013
|
+
},
|
|
12014
|
+
message: `Color token "${definition.name}" unnecessarily wraps fixed HSL primitive "${primitive.name}"; define a single --color-* token with hsl(...) directly and reuse it across utility roles.`
|
|
12015
|
+
});
|
|
12016
|
+
}
|
|
11981
12017
|
for (const [definition, original] of redundant) {
|
|
11982
12018
|
if (definition.file !== current) continue;
|
|
11983
12019
|
context.report({
|