pasika 0.10.109 → 0.10.111
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 +53 -6
- package/package.json +1 -1
|
@@ -4268,7 +4268,6 @@ var NEXT_ROUTING_FILES3 = /* @__PURE__ */ new Set([
|
|
|
4268
4268
|
"loading",
|
|
4269
4269
|
"middleware",
|
|
4270
4270
|
"not-found",
|
|
4271
|
-
"page",
|
|
4272
4271
|
"route",
|
|
4273
4272
|
"template",
|
|
4274
4273
|
// File conventions Next.js requires to keep their exact names in src/app/
|
|
@@ -10376,24 +10375,72 @@ function applyOperationCount(utility) {
|
|
|
10376
10375
|
}
|
|
10377
10376
|
return count;
|
|
10378
10377
|
}
|
|
10378
|
+
function themeCandidate(name, utilityText) {
|
|
10379
|
+
const match = /^@utility\s+[\w-]+\s*\{\s*@apply\s+\[(?<property>font-size|letter-spacing):(?<value>[^\]\r\n;{}]+)\];?\s*\}$/u.exec(
|
|
10380
|
+
utilityText.trim()
|
|
10381
|
+
);
|
|
10382
|
+
if (!match) return void 0;
|
|
10383
|
+
const property = match.groups?.property;
|
|
10384
|
+
const value = match.groups?.value?.trim();
|
|
10385
|
+
if (!property || !value) return void 0;
|
|
10386
|
+
const prefix = property === "font-size" ? "text-" : "tracking-";
|
|
10387
|
+
if (!name.startsWith(prefix) || name.length === prefix.length) return void 0;
|
|
10388
|
+
const length = /^-?(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem|em|%)$/u.test(value);
|
|
10389
|
+
const variable = /^var\(--[a-z][a-z0-9-]*\)$/u.test(value);
|
|
10390
|
+
if (!length && !variable) return void 0;
|
|
10391
|
+
if (property === "font-size" && value.startsWith("-")) return void 0;
|
|
10392
|
+
return { token: `--${name}`, property, value };
|
|
10393
|
+
}
|
|
10379
10394
|
var utilityMappingRule = {
|
|
10380
10395
|
meta: {
|
|
10381
|
-
schema: [
|
|
10396
|
+
schema: [
|
|
10397
|
+
{
|
|
10398
|
+
type: "object",
|
|
10399
|
+
properties: { preferThemeTokens: { type: "boolean" } },
|
|
10400
|
+
additionalProperties: false
|
|
10401
|
+
}
|
|
10402
|
+
],
|
|
10382
10403
|
type: "problem",
|
|
10383
10404
|
docs: {
|
|
10384
|
-
description: "Require
|
|
10405
|
+
description: "Require one styling operation per custom utility; optionally suggest theme-generated utilities."
|
|
10385
10406
|
}
|
|
10386
10407
|
},
|
|
10387
10408
|
create(context) {
|
|
10409
|
+
const option = context.options[0];
|
|
10410
|
+
const preferThemeTokens = typeof option === "object" && option !== null && "preferThemeTokens" in option && option.preferThemeTokens === true;
|
|
10388
10411
|
return {
|
|
10389
10412
|
"StyleSheet:exit"(node) {
|
|
10390
|
-
|
|
10413
|
+
const utilities = atrulesNamed(node, "utility");
|
|
10414
|
+
const themeTokens = /* @__PURE__ */ new Set();
|
|
10415
|
+
const nameCounts = /* @__PURE__ */ new Map();
|
|
10416
|
+
if (preferThemeTokens) {
|
|
10417
|
+
for (const theme of atrulesNamed(node, "theme")) {
|
|
10418
|
+
for (const child of blockChildren2(theme)) {
|
|
10419
|
+
if (child.type === "Declaration") themeTokens.add(child.property);
|
|
10420
|
+
}
|
|
10421
|
+
}
|
|
10422
|
+
for (const utility of utilities) {
|
|
10423
|
+
const name = preludeIdentifiers(utility)[0] ?? "";
|
|
10424
|
+
nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1);
|
|
10425
|
+
}
|
|
10426
|
+
}
|
|
10427
|
+
for (const utility of utilities) {
|
|
10391
10428
|
const name = preludeIdentifiers(utility)[0] ?? "unknown";
|
|
10392
10429
|
const operationCount = applyOperationCount(utility);
|
|
10393
|
-
if (operationCount
|
|
10430
|
+
if (operationCount !== 1) {
|
|
10431
|
+
context.report({
|
|
10432
|
+
node: utility,
|
|
10433
|
+
message: `Custom utility "${name}" maps ${String(operationCount)} Tailwind operations; custom utilities must map exactly one operation. Reusable presentation belongs in a component.`
|
|
10434
|
+
});
|
|
10435
|
+
continue;
|
|
10436
|
+
}
|
|
10437
|
+
if (!preferThemeTokens || nameCounts.get(name) !== 1) continue;
|
|
10438
|
+
const candidate = themeCandidate(name, context.sourceCode.getText(utility));
|
|
10439
|
+
if (!candidate || themeTokens.has(candidate.token)) continue;
|
|
10440
|
+
if (candidate.property === "font-size" && themeTokens.has(`--color-${name.slice(5)}`)) continue;
|
|
10394
10441
|
context.report({
|
|
10395
10442
|
node: utility,
|
|
10396
|
-
message: `Custom utility "${name}" maps ${
|
|
10443
|
+
message: `Custom utility "${name}" only maps ${candidate.property} (${candidate.value}); prefer @theme inline token "${candidate.token}" backed by a :root variable. Preserve the class name and compare compiled CSS before removing the utility.`
|
|
10397
10444
|
});
|
|
10398
10445
|
}
|
|
10399
10446
|
}
|