oxlint-tailwindcss 1.16.0 → 1.17.0
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/config.cjs +2 -4
- package/dist/config.d.cts +9 -4
- package/dist/config.d.mts +9 -4
- package/dist/config.mjs +2 -4
- package/dist/index.cjs +146 -133
- package/dist/index.d.cts +0 -3
- package/dist/index.d.mts +0 -4
- package/dist/index.mjs +147 -135
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ let node_crypto = require("node:crypto");
|
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
let node_os = require("node:os");
|
|
7
|
-
|
|
7
|
+
// ../../node_modules/.pnpm/@oxlint+plugins@1.89.0/node_modules/@oxlint/plugins/index.js
|
|
8
8
|
/**
|
|
9
9
|
* Define a plugin.
|
|
10
10
|
*
|
|
@@ -68,8 +68,7 @@ Object.freeze({
|
|
|
68
68
|
throw Error("Cannot access `context.parserPath` in `createOnce`");
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
-
|
|
72
|
-
//#region src/utils/rule-docs.ts
|
|
71
|
+
// src/utils/rule-docs.ts
|
|
73
72
|
const DOCS_URL = "https://oxlint-tailwindcss.pages.dev";
|
|
74
73
|
function ruleDocs(name, docs) {
|
|
75
74
|
return {
|
|
@@ -77,8 +76,7 @@ function ruleDocs(name, docs) {
|
|
|
77
76
|
url: `${DOCS_URL}/rules/${name}`
|
|
78
77
|
};
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
//#region src/utils/allowlist.ts
|
|
79
|
+
// src/utils/allowlist.ts
|
|
82
80
|
/**
|
|
83
81
|
* Shared regex-allowlist helpers for options and settings that take regex
|
|
84
82
|
* source strings: the directional rules' `allowlist`, `no-conflicting-classes`'
|
|
@@ -98,8 +96,7 @@ function compileRegexList(patterns) {
|
|
|
98
96
|
function matchesAny(value, list) {
|
|
99
97
|
return list.some((re) => re.test(value));
|
|
100
98
|
}
|
|
101
|
-
|
|
102
|
-
//#region src/utils/context.ts
|
|
99
|
+
// src/utils/context.ts
|
|
103
100
|
/**
|
|
104
101
|
* Safely read `context.options[0]`. Returns `undefined` if the getter throws
|
|
105
102
|
* (oxlint < 1.31.0) or if options aren't populated yet.
|
|
@@ -247,8 +244,7 @@ function createLazySettings(context, compile) {
|
|
|
247
244
|
function settingsKey(settings) {
|
|
248
245
|
return JSON.stringify(settings?.tailwindcss) ?? "";
|
|
249
246
|
}
|
|
250
|
-
|
|
251
|
-
//#region src/utils/css-properties.ts
|
|
247
|
+
// src/utils/css-properties.ts
|
|
252
248
|
/**
|
|
253
249
|
* CSS property names (standard, SVG and `-ms-`), from csstype's `*PropertiesHyphen`
|
|
254
250
|
* interfaces, minus the 15 that are also Tailwind classes (`flex`, `grid`, `border`,
|
|
@@ -365,8 +361,7 @@ const CSS_PROPERTY_NAMES = new Set(`
|
|
|
365
361
|
view-transition-name visibility white-space white-space-collapse widows width will-change
|
|
366
362
|
word-break word-spacing word-wrap writing-mode x y z-index zoom
|
|
367
363
|
`.trim().split(/\s+/));
|
|
368
|
-
|
|
369
|
-
//#region src/utils/levenshtein.ts
|
|
364
|
+
// src/utils/levenshtein.ts
|
|
370
365
|
let bufA = /* @__PURE__ */ new Int32Array(64);
|
|
371
366
|
let bufB = /* @__PURE__ */ new Int32Array(64);
|
|
372
367
|
let bufC = /* @__PURE__ */ new Int32Array(64);
|
|
@@ -445,8 +440,7 @@ function findBestSuggestion(input, candidates, maxDistance = 3) {
|
|
|
445
440
|
}
|
|
446
441
|
return best;
|
|
447
442
|
}
|
|
448
|
-
|
|
449
|
-
//#region src/utils/settings-check.ts
|
|
443
|
+
// src/utils/settings-check.ts
|
|
450
444
|
const SETTINGS_MESSAGE_ID = "invalidSetting";
|
|
451
445
|
/** Pre-shaped entry for `meta.messages`: `messages: { ..., ...SETTINGS_MESSAGE }`. */
|
|
452
446
|
const SETTINGS_MESSAGE = { [SETTINGS_MESSAGE_ID]: "{{message}}" };
|
|
@@ -462,6 +456,7 @@ const CHECKS = {
|
|
|
462
456
|
calleeExtractors: "extractors",
|
|
463
457
|
tags: "strings",
|
|
464
458
|
variablePatterns: "regexes",
|
|
459
|
+
lookupTablePatterns: "regexes",
|
|
465
460
|
exclude: "exclude"
|
|
466
461
|
};
|
|
467
462
|
const EXCLUDE_KEYS = {
|
|
@@ -559,8 +554,7 @@ function reportSettingsProblems(context, program) {
|
|
|
559
554
|
}
|
|
560
555
|
});
|
|
561
556
|
}
|
|
562
|
-
|
|
563
|
-
//#region src/utils/extractors.ts
|
|
557
|
+
// src/utils/extractors.ts
|
|
564
558
|
/**
|
|
565
559
|
* Whether this string is the element's FINAL, self-contained class list — the
|
|
566
560
|
* only position where a RELATIONAL rule (one whose verdict for a class depends
|
|
@@ -617,6 +611,7 @@ const DEFAULT_EXTRACTOR_CONFIG = {
|
|
|
617
611
|
/^classes$/,
|
|
618
612
|
/^styles?$/
|
|
619
613
|
],
|
|
614
|
+
lookupTablePatterns: [],
|
|
620
615
|
calleeExtractors: /* @__PURE__ */ new Map()
|
|
621
616
|
};
|
|
622
617
|
/**
|
|
@@ -708,6 +703,7 @@ function compileExtractorConfig(tw) {
|
|
|
708
703
|
callees: mergeUnique(DEFAULT_EXTRACTOR_CONFIG.callees, [...tw.callees ?? [], ...calleeExtractors.keys()], exclude?.callees),
|
|
709
704
|
tags: mergeUnique(DEFAULT_EXTRACTOR_CONFIG.tags, tw.tags, exclude?.tags),
|
|
710
705
|
variablePatterns: [...filteredPatterns, ...compileRegexList(tw.variablePatterns)],
|
|
706
|
+
lookupTablePatterns: compileRegexList(tw.lookupTablePatterns),
|
|
711
707
|
calleeExtractors
|
|
712
708
|
};
|
|
713
709
|
}
|
|
@@ -984,13 +980,41 @@ function getPropertyName(key) {
|
|
|
984
980
|
/**
|
|
985
981
|
* Extracts class locations from a VariableDeclarator whose name matches variablePatterns.
|
|
986
982
|
* e.g. const className = "flex items-center"
|
|
983
|
+
*
|
|
984
|
+
* A name matching lookupTablePatterns whose initializer is an object literal is
|
|
985
|
+
* a lookup table instead: its values are read, not its keys.
|
|
986
|
+
* e.g. const TONE_CLASSES = { warning: "text-amber-700" }
|
|
987
987
|
*/
|
|
988
988
|
function extractFromVariableDeclarator(node, config = DEFAULT_EXTRACTOR_CONFIG) {
|
|
989
989
|
if (node.id.type !== "Identifier") return [];
|
|
990
|
-
|
|
990
|
+
const name = node.id.name;
|
|
991
|
+
if (node.init && config.lookupTablePatterns.some((p) => p.test(name))) {
|
|
992
|
+
const table = withoutTypeAssertion(node.init);
|
|
993
|
+
if (table.type === "ObjectExpression") return withOrigin(extractLookupTable(table), "variable");
|
|
994
|
+
}
|
|
995
|
+
if (!config.variablePatterns.some((p) => p.test(name))) return [];
|
|
991
996
|
if (!node.init) return [];
|
|
992
997
|
return withOrigin(extractFromExpression(node.init), "variable");
|
|
993
998
|
}
|
|
999
|
+
/** `{…} as const` and `{…} satisfies T` are the same object literal. */
|
|
1000
|
+
function withoutTypeAssertion(node) {
|
|
1001
|
+
let inner = node;
|
|
1002
|
+
while (inner.type === "TSAsExpression" || inner.type === "TSSatisfiesExpression") inner = inner.expression;
|
|
1003
|
+
return inner;
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* A lookup table's values, recursing into nested tables
|
|
1007
|
+
* (`{ sm: { root: "…", label: "…" } }`): there, too, the keys are names.
|
|
1008
|
+
*/
|
|
1009
|
+
function extractLookupTable(node, out = []) {
|
|
1010
|
+
for (const prop of node.properties) {
|
|
1011
|
+
if (prop.type !== "Property") continue;
|
|
1012
|
+
const value = withoutTypeAssertion(prop.value);
|
|
1013
|
+
if (value.type === "ObjectExpression") extractLookupTable(value, out);
|
|
1014
|
+
else extractFromExpression(value, out);
|
|
1015
|
+
}
|
|
1016
|
+
return out;
|
|
1017
|
+
}
|
|
994
1018
|
/**
|
|
995
1019
|
* Walk an expression and append every class-bearing location to `out`.
|
|
996
1020
|
*
|
|
@@ -1014,7 +1038,18 @@ function extractFromExpression(node, out = []) {
|
|
|
1014
1038
|
extractFromExpression(node.alternate, out);
|
|
1015
1039
|
return out;
|
|
1016
1040
|
}
|
|
1017
|
-
if (node.type === "LogicalExpression")
|
|
1041
|
+
if (node.type === "LogicalExpression") {
|
|
1042
|
+
const { operator, left, right } = node;
|
|
1043
|
+
if (operator !== "&&") extractFromExpression(left, out);
|
|
1044
|
+
return extractFromExpression(right, out);
|
|
1045
|
+
}
|
|
1046
|
+
if (node.type === "MemberExpression" && node.computed) {
|
|
1047
|
+
const object = withoutTypeAssertion(node.object);
|
|
1048
|
+
if (object.type === "ObjectExpression") {
|
|
1049
|
+
for (const prop of object.properties) if (prop.type === "Property") extractFromExpression(prop.value, out);
|
|
1050
|
+
} else if (object.type === "ArrayExpression") extractFromExpression(object, out);
|
|
1051
|
+
return out;
|
|
1052
|
+
}
|
|
1018
1053
|
if (node.type === "BinaryExpression" && node.operator === "+") return appendFromConcatenation(node, out);
|
|
1019
1054
|
if (node.type === "ArrayExpression") {
|
|
1020
1055
|
for (const element of node.elements) if (element && element.type !== "SpreadElement") extractFromExpression(element, out);
|
|
@@ -1157,8 +1192,7 @@ function getCalleeName(node) {
|
|
|
1157
1192
|
if (prop.type === "Identifier") return prop.name;
|
|
1158
1193
|
}
|
|
1159
1194
|
}
|
|
1160
|
-
|
|
1161
|
-
//#region src/utils/class-splitter.ts
|
|
1195
|
+
// src/utils/class-splitter.ts
|
|
1162
1196
|
function isWhitespace(char) {
|
|
1163
1197
|
return char === " " || char === " " || char === "\n" || char === "\r" || char === "\f" || char === "\v";
|
|
1164
1198
|
}
|
|
@@ -1292,8 +1326,7 @@ function rebuildClassString(split, newClasses, sourceIndices) {
|
|
|
1292
1326
|
const join = separators.slice(1, -1).find((s) => s.includes("\n")) ?? " ";
|
|
1293
1327
|
return separators[0] + newClasses.join(join) + separators[separators.length - 1];
|
|
1294
1328
|
}
|
|
1295
|
-
|
|
1296
|
-
//#region src/rules/no-duplicate-classes.ts
|
|
1329
|
+
// src/rules/no-duplicate-classes.ts
|
|
1297
1330
|
const noDuplicateClasses = defineRule({
|
|
1298
1331
|
meta: {
|
|
1299
1332
|
type: "problem",
|
|
@@ -1341,8 +1374,7 @@ const noDuplicateClasses = defineRule({
|
|
|
1341
1374
|
return createExtractorVisitors(context, check);
|
|
1342
1375
|
}
|
|
1343
1376
|
});
|
|
1344
|
-
|
|
1345
|
-
//#region src/rules/no-unnecessary-whitespace.ts
|
|
1377
|
+
// src/rules/no-unnecessary-whitespace.ts
|
|
1346
1378
|
const noUnnecessaryWhitespace = defineRule({
|
|
1347
1379
|
meta: {
|
|
1348
1380
|
type: "suggestion",
|
|
@@ -1385,8 +1417,7 @@ const noUnnecessaryWhitespace = defineRule({
|
|
|
1385
1417
|
return createExtractorVisitors(context, check, { raw: true });
|
|
1386
1418
|
}
|
|
1387
1419
|
});
|
|
1388
|
-
|
|
1389
|
-
//#region src/utils/report.ts
|
|
1420
|
+
// src/utils/report.ts
|
|
1390
1421
|
/**
|
|
1391
1422
|
* Shared reporters: `reportClassReplacements` for the "first-as-fix,
|
|
1392
1423
|
* rest-as-suggestion" pattern, `reportClassSuggestion` for a suggestion alone.
|
|
@@ -1478,8 +1509,7 @@ function reportClassSuggestion(context, loc, split, classes, { cls, replacement
|
|
|
1478
1509
|
}]
|
|
1479
1510
|
});
|
|
1480
1511
|
}
|
|
1481
|
-
|
|
1482
|
-
//#region src/utils/class-parser.ts
|
|
1512
|
+
// src/utils/class-parser.ts
|
|
1483
1513
|
/**
|
|
1484
1514
|
* Extracts variants from a class string, respecting bracket depth.
|
|
1485
1515
|
* e.g. "[&>svg]:hover:w-4" → ["[&>svg]", "hover"]
|
|
@@ -1749,8 +1779,7 @@ function isSelectorBarrier(variant, facts) {
|
|
|
1749
1779
|
function changesTarget(variant, facts) {
|
|
1750
1780
|
return isPseudoElementVariant(variant, facts) || isSelectorBarrier(variant, facts);
|
|
1751
1781
|
}
|
|
1752
|
-
|
|
1753
|
-
//#region src/design-system/css-declarations.ts
|
|
1782
|
+
// src/design-system/css-declarations.ts
|
|
1754
1783
|
const EMPTY_DECLS = [];
|
|
1755
1784
|
const EMPTY_VARS = [];
|
|
1756
1785
|
/** Splits a scope token into its decoded parts. Unknown tokens degrade to `element`. */
|
|
@@ -1845,8 +1874,7 @@ function isCssDeclarationIndex(value) {
|
|
|
1845
1874
|
const i = value;
|
|
1846
1875
|
return Array.isArray(i.scopes) && i.scopes.length > 0 && i.scopes[0] === "" && Array.isArray(i.props) && Array.isArray(i.values) && Array.isArray(i.vars) && Array.isArray(i.table) && Array.isArray(i.pureValues) && Array.isArray(i.partial) && typeof i.byClass === "object" && i.byClass !== null && typeof i.valueVars === "object" && i.valueVars !== null && typeof i.valueFallbackVars === "object" && i.valueFallbackVars !== null;
|
|
1847
1876
|
}
|
|
1848
|
-
|
|
1849
|
-
//#region src/utils/floating-point.ts
|
|
1877
|
+
// src/utils/floating-point.ts
|
|
1850
1878
|
/**
|
|
1851
1879
|
* Rounds rem/em/px values in class strings to avoid
|
|
1852
1880
|
* JavaScript floating point issues.
|
|
@@ -1860,8 +1888,7 @@ function roundRemValue(className) {
|
|
|
1860
1888
|
return `[${Number.parseFloat(Number.parseFloat(num).toFixed(6))}${unit}]`;
|
|
1861
1889
|
});
|
|
1862
1890
|
}
|
|
1863
|
-
|
|
1864
|
-
//#region src/design-system/cache.ts
|
|
1891
|
+
// src/design-system/cache.ts
|
|
1865
1892
|
const EMPTY_DECLARATIONS = [];
|
|
1866
1893
|
const EMPTY_TOKEN_VALUES = [];
|
|
1867
1894
|
/** Off-scale numeric value: `w-45`, `min-h-17.5`, `gap-13`. */
|
|
@@ -2421,8 +2448,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
2421
2448
|
return null;
|
|
2422
2449
|
}
|
|
2423
2450
|
};
|
|
2424
|
-
|
|
2425
|
-
//#region src/utils/fatal.ts
|
|
2451
|
+
// src/utils/fatal.ts
|
|
2426
2452
|
/**
|
|
2427
2453
|
* Fatal error types and reporter for the deterministic v1 design.
|
|
2428
2454
|
*
|
|
@@ -2535,8 +2561,7 @@ function softGetDS(getDS) {
|
|
|
2535
2561
|
throw err;
|
|
2536
2562
|
}
|
|
2537
2563
|
}
|
|
2538
|
-
|
|
2539
|
-
//#region src/design-system/tailwind-node.ts
|
|
2564
|
+
// src/design-system/tailwind-node.ts
|
|
2540
2565
|
/**
|
|
2541
2566
|
* Resolves the Tailwind engine (`@tailwindcss/node`) the plugin runs against.
|
|
2542
2567
|
*
|
|
@@ -2680,8 +2705,7 @@ function resolveTailwindNodeFor(cssPath) {
|
|
|
2680
2705
|
resolutionCache.set(cssDir, result);
|
|
2681
2706
|
return result;
|
|
2682
2707
|
}
|
|
2683
|
-
|
|
2684
|
-
//#region src/design-system/sync-loader.ts
|
|
2708
|
+
// src/design-system/sync-loader.ts
|
|
2685
2709
|
/**
|
|
2686
2710
|
* Synchronous design system loader using a worker_thread.
|
|
2687
2711
|
*
|
|
@@ -3600,6 +3624,18 @@ async function main() {
|
|
|
3600
3624
|
// SINGLE because a class that declares more than the original is not an
|
|
3601
3625
|
// equivalent: \`text-sm\` sets \`line-height\` too, so \`text-[14px]\` is not it.
|
|
3602
3626
|
const NUMERIC_LITERAL = /^-?\\d*\\.?\\d+(rem|px|em|%|s|ms|deg)?$/;
|
|
3627
|
+
// The utility a token class belongs to is the class minus the token's own
|
|
3628
|
+
// name: \`p-brand-md\` reads \`--spacing-brand-md\`, so its utility is \`p\`, not
|
|
3629
|
+
// \`p-brand\`. Cutting at the last dash only works for one-word token names.
|
|
3630
|
+
// A class whose variable shares no suffix with it keeps that last-dash cut.
|
|
3631
|
+
function tokenPrefix(cls, variable) {
|
|
3632
|
+
const name = variable.slice(2);
|
|
3633
|
+
for (let dash = cls.indexOf('-'); dash > 0; dash = cls.indexOf('-', dash + 1)) {
|
|
3634
|
+
if (name.endsWith(cls.slice(dash))) return cls.slice(0, dash);
|
|
3635
|
+
}
|
|
3636
|
+
const last = cls.lastIndexOf('-');
|
|
3637
|
+
return last > 0 ? cls.slice(0, last) : '';
|
|
3638
|
+
}
|
|
3603
3639
|
const tokenValues = {};
|
|
3604
3640
|
for (const cls of validClasses) {
|
|
3605
3641
|
if (cls.includes('[') || cls.includes('/')) continue;
|
|
@@ -3611,11 +3647,13 @@ async function main() {
|
|
|
3611
3647
|
const body = css.slice(open + 1, close).replace(/\\s+/g, ' ').replace(/;\\s*$/, '').trim();
|
|
3612
3648
|
const m = /^([a-z-]+):\\s*var\\((--[\\w-]+)\\)$/.exec(body);
|
|
3613
3649
|
if (!m) continue;
|
|
3650
|
+
// \`mt-1\` reads the bare \`--spacing\`: it is a step of the scale, the second
|
|
3651
|
+
// family, not a named token. Filed here it would tie with a project token
|
|
3652
|
+
// of the same value and win on name order.
|
|
3653
|
+
if (m[2] === '--spacing') continue;
|
|
3614
3654
|
const value = themeValues.get(m[2]);
|
|
3615
3655
|
if (!value || !NUMERIC_LITERAL.test(value)) continue;
|
|
3616
|
-
const
|
|
3617
|
-
if (dash <= 0) continue;
|
|
3618
|
-
const prefix = unpfx(cls).slice(0, unpfx(cls).lastIndexOf('-'));
|
|
3656
|
+
const prefix = tokenPrefix(unpfx(cls), m[2]);
|
|
3619
3657
|
if (!prefix) continue;
|
|
3620
3658
|
if (!tokenValues[prefix]) tokenValues[prefix] = [];
|
|
3621
3659
|
tokenValues[prefix].push([value, unpfx(cls)]);
|
|
@@ -4121,8 +4159,7 @@ function loadDesignSystemSync(cssPath, timeout, onPrecompute) {
|
|
|
4121
4159
|
pruneCacheDir();
|
|
4122
4160
|
return data;
|
|
4123
4161
|
}
|
|
4124
|
-
|
|
4125
|
-
//#region src/design-system/debug.ts
|
|
4162
|
+
// src/design-system/debug.ts
|
|
4126
4163
|
const PREFIX = "[oxlint-tailwindcss]";
|
|
4127
4164
|
let _enabled = null;
|
|
4128
4165
|
/**
|
|
@@ -4149,8 +4186,7 @@ function setDebugEnabled(enabled) {
|
|
|
4149
4186
|
function debugLog(message) {
|
|
4150
4187
|
if (_enabled || process.env.DEBUG === "oxlint-tailwindcss") console.error(`${PREFIX} ${message}`);
|
|
4151
4188
|
}
|
|
4152
|
-
|
|
4153
|
-
//#region src/design-system/engine-guard.ts
|
|
4189
|
+
// src/design-system/engine-guard.ts
|
|
4154
4190
|
/**
|
|
4155
4191
|
* Version safeguards for the consumer-resolved Tailwind engine.
|
|
4156
4192
|
*
|
|
@@ -4364,8 +4400,7 @@ function allowUntestedEngineFromSettings(settings) {
|
|
|
4364
4400
|
if (tw && typeof tw === "object" && "allowUntestedEngine" in tw) return tw.allowUntestedEngine === true;
|
|
4365
4401
|
return false;
|
|
4366
4402
|
}
|
|
4367
|
-
|
|
4368
|
-
//#region src/design-system/ds-worker.ts
|
|
4403
|
+
// src/design-system/ds-worker.ts
|
|
4369
4404
|
/**
|
|
4370
4405
|
* Generic worker-thread service wrapping `__unstable__loadDesignSystem`.
|
|
4371
4406
|
*
|
|
@@ -4721,8 +4756,7 @@ var DesignSystemWorker = class {
|
|
|
4721
4756
|
} catch {}
|
|
4722
4757
|
}
|
|
4723
4758
|
};
|
|
4724
|
-
|
|
4725
|
-
//#region src/design-system/canonicalize-service.ts
|
|
4759
|
+
// src/design-system/canonicalize-service.ts
|
|
4726
4760
|
/**
|
|
4727
4761
|
* Persistent canonicalize service backed by `DesignSystemWorker`.
|
|
4728
4762
|
*
|
|
@@ -5158,8 +5192,7 @@ function canonicalizeClassesSync(cssPath, classes, rem) {
|
|
|
5158
5192
|
}
|
|
5159
5193
|
return out;
|
|
5160
5194
|
}
|
|
5161
|
-
|
|
5162
|
-
//#region src/design-system/loader.ts
|
|
5195
|
+
// src/design-system/loader.ts
|
|
5163
5196
|
const dsCache = /* @__PURE__ */ new Map();
|
|
5164
5197
|
/**
|
|
5165
5198
|
* Memoizes DS-load FAILURES per entry point, keyed by `(resolvedPath, mtime)`.
|
|
@@ -5251,7 +5284,7 @@ function resolveByGlobMapping(mappings, filePath, baseDir) {
|
|
|
5251
5284
|
}
|
|
5252
5285
|
/**
|
|
5253
5286
|
* oxlint discovers nested configuration by walking up from each linted file
|
|
5254
|
-
* looking for files with these names (oxlint 1.
|
|
5287
|
+
* looking for files with these names (oxlint 1.89: JSON, JSONC, and the JS
|
|
5255
5288
|
* configs it loads through Node). We mirror that walk to find the config
|
|
5256
5289
|
* directory a relative `entryPoint` should be anchored to — which is also
|
|
5257
5290
|
* where an `oxlint.config.ts` passes it through `oxlint-tailwindcss/config`.
|
|
@@ -5598,8 +5631,7 @@ function validateClassesSync(cssPath, cache, classes) {
|
|
|
5598
5631
|
ask(cssPath, cache, classes);
|
|
5599
5632
|
return answersFor(cache);
|
|
5600
5633
|
}
|
|
5601
|
-
|
|
5602
|
-
//#region src/rules/no-unknown-classes.ts
|
|
5634
|
+
// src/rules/no-unknown-classes.ts
|
|
5603
5635
|
/**
|
|
5604
5636
|
* Utility used to probe a variant chain. Any always-valid utility works; `flex`
|
|
5605
5637
|
* is the shortest one every Tailwind build has.
|
|
@@ -5836,8 +5868,7 @@ const noUnknownClasses = defineRule({
|
|
|
5836
5868
|
return createExtractorVisitors(context, check);
|
|
5837
5869
|
}
|
|
5838
5870
|
});
|
|
5839
|
-
|
|
5840
|
-
//#region src/rules/no-conflicting-classes/spec.ts
|
|
5871
|
+
// src/rules/no-conflicting-classes/spec.ts
|
|
5841
5872
|
const COMPLEMENTARY_GROUPS = [{
|
|
5842
5873
|
pattern: /^prose(?:-|$)/,
|
|
5843
5874
|
reason: "`prose` + `prose-sm`/`prose-lg`/`prose-xl` modify the same scope and are designed to compose."
|
|
@@ -5864,8 +5895,7 @@ const COMPOSITION_PAIRS = [
|
|
|
5864
5895
|
reason: "`mask-{add,subtract,intersect,exclude}` are mask-composite modes that compose with mask-gradient utilities."
|
|
5865
5896
|
}
|
|
5866
5897
|
];
|
|
5867
|
-
|
|
5868
|
-
//#region src/rules/no-conflicting-classes/decide.ts
|
|
5898
|
+
// src/rules/no-conflicting-classes/decide.ts
|
|
5869
5899
|
/** Builds the comparison key. Same property on two different boxes never clashes. */
|
|
5870
5900
|
function declKey(decl) {
|
|
5871
5901
|
return decl.scope === "element" ? decl.prop : `${decl.pseudo || ">"}|${decl.prop}`;
|
|
@@ -6061,8 +6091,7 @@ function redundantSide(verdict) {
|
|
|
6061
6091
|
};
|
|
6062
6092
|
return null;
|
|
6063
6093
|
}
|
|
6064
|
-
|
|
6065
|
-
//#region src/rules/no-conflicting-classes.ts
|
|
6094
|
+
// src/rules/no-conflicting-classes.ts
|
|
6066
6095
|
/**
|
|
6067
6096
|
* Compiles the `allow` option.
|
|
6068
6097
|
*
|
|
@@ -6278,8 +6307,7 @@ const noConflictingClasses = defineRule({
|
|
|
6278
6307
|
return createExtractorVisitors(context, check);
|
|
6279
6308
|
}
|
|
6280
6309
|
});
|
|
6281
|
-
|
|
6282
|
-
//#region src/utils/replacement.ts
|
|
6310
|
+
// src/utils/replacement.ts
|
|
6283
6311
|
/**
|
|
6284
6312
|
* Returns a predicate that answers "would this replacement produce CSS?".
|
|
6285
6313
|
*
|
|
@@ -6292,8 +6320,7 @@ function makeReplacementGuard(cache) {
|
|
|
6292
6320
|
if (!cache) return () => true;
|
|
6293
6321
|
return (replacement) => cache.isValid(replacement);
|
|
6294
6322
|
}
|
|
6295
|
-
|
|
6296
|
-
//#region src/rules/no-deprecated-classes.ts
|
|
6323
|
+
// src/rules/no-deprecated-classes.ts
|
|
6297
6324
|
/**
|
|
6298
6325
|
* Fallback rename map, for when no design system is available.
|
|
6299
6326
|
*
|
|
@@ -6371,8 +6398,7 @@ const noDeprecatedClasses = defineRule({
|
|
|
6371
6398
|
return createExtractorVisitors(context, check);
|
|
6372
6399
|
}
|
|
6373
6400
|
});
|
|
6374
|
-
|
|
6375
|
-
//#region src/rules/enforce-canonical.ts
|
|
6401
|
+
// src/rules/enforce-canonical.ts
|
|
6376
6402
|
/**
|
|
6377
6403
|
* Preserve the user's `!` position after canonicalization.
|
|
6378
6404
|
*
|
|
@@ -6561,8 +6587,7 @@ const sortWorker = new DesignSystemWorker({
|
|
|
6561
6587
|
function sortClassesSync(cssPath, classes) {
|
|
6562
6588
|
return sortWorker.callSync(cssPath, classes);
|
|
6563
6589
|
}
|
|
6564
|
-
|
|
6565
|
-
//#region src/rules/enforce-sort-order.ts
|
|
6590
|
+
// src/rules/enforce-sort-order.ts
|
|
6566
6591
|
const enforceSortOrder = defineRule({
|
|
6567
6592
|
meta: {
|
|
6568
6593
|
type: "suggestion",
|
|
@@ -6660,8 +6685,7 @@ const enforceSortOrder = defineRule({
|
|
|
6660
6685
|
return createExtractorVisitors(context, check);
|
|
6661
6686
|
}
|
|
6662
6687
|
});
|
|
6663
|
-
|
|
6664
|
-
//#region src/utils/declared-values.ts
|
|
6688
|
+
// src/utils/declared-values.ts
|
|
6665
6689
|
/** A plain number or fraction: always the shared numeric/`--spacing` scale. */
|
|
6666
6690
|
const NUMERIC_VALUE_RE = /^\d+(?:\.\d+)?(?:\/\d+(?:\.\d+)?)?$/;
|
|
6667
6691
|
/** The value is a literal the user wrote, injected verbatim into every part. */
|
|
@@ -6685,8 +6709,7 @@ function sameValues(a, b) {
|
|
|
6685
6709
|
for (const value of a) if (!b.has(value)) return false;
|
|
6686
6710
|
return true;
|
|
6687
6711
|
}
|
|
6688
|
-
|
|
6689
|
-
//#region src/rules/enforce-shorthand.ts
|
|
6712
|
+
// src/rules/enforce-shorthand.ts
|
|
6690
6713
|
/**
|
|
6691
6714
|
* The `m`/`p` shape, shared by `margin`, `padding`, `scroll-margin` and
|
|
6692
6715
|
* `scroll-padding`: four sides, each axis, and the logical pairs (`ms`+`me` IS
|
|
@@ -7054,8 +7077,7 @@ const enforceShorthand = defineRule({
|
|
|
7054
7077
|
return createExtractorVisitors(context, check);
|
|
7055
7078
|
}
|
|
7056
7079
|
});
|
|
7057
|
-
|
|
7058
|
-
//#region src/rules/enforce-logical.ts
|
|
7080
|
+
// src/rules/enforce-logical.ts
|
|
7059
7081
|
const LOGICAL_PHYSICAL_SCHEMA = {
|
|
7060
7082
|
type: "object",
|
|
7061
7083
|
properties: {
|
|
@@ -7534,8 +7556,7 @@ const enforceLogical = defineRule({
|
|
|
7534
7556
|
return createExtractorVisitors(context, check);
|
|
7535
7557
|
}
|
|
7536
7558
|
});
|
|
7537
|
-
|
|
7538
|
-
//#region src/rules/enforce-physical.ts
|
|
7559
|
+
// src/rules/enforce-physical.ts
|
|
7539
7560
|
const PHYSICAL_MAPPINGS = invertAxisMappings(PHYSICAL_TO_LOGICAL_MAPPINGS);
|
|
7540
7561
|
const enforcePhysical = defineRule({
|
|
7541
7562
|
meta: {
|
|
@@ -7568,8 +7589,7 @@ const enforcePhysical = defineRule({
|
|
|
7568
7589
|
return createExtractorVisitors(context, check);
|
|
7569
7590
|
}
|
|
7570
7591
|
});
|
|
7571
|
-
|
|
7572
|
-
//#region src/rules/max-class-count.ts
|
|
7592
|
+
// src/rules/max-class-count.ts
|
|
7573
7593
|
const DEFAULT_MAX = 20;
|
|
7574
7594
|
const EXPRESSION = "\0";
|
|
7575
7595
|
/**
|
|
@@ -7632,8 +7652,7 @@ const maxClassCount = defineRule({
|
|
|
7632
7652
|
return createExtractorVisitors(context, check, { raw: true });
|
|
7633
7653
|
}
|
|
7634
7654
|
});
|
|
7635
|
-
|
|
7636
|
-
//#region src/rules/no-restricted-classes.ts
|
|
7655
|
+
// src/rules/no-restricted-classes.ts
|
|
7637
7656
|
const noRestrictedClasses = defineRule({
|
|
7638
7657
|
meta: {
|
|
7639
7658
|
type: "problem",
|
|
@@ -7725,8 +7744,7 @@ const noRestrictedClasses = defineRule({
|
|
|
7725
7744
|
return createExtractorVisitors(context, check);
|
|
7726
7745
|
}
|
|
7727
7746
|
});
|
|
7728
|
-
|
|
7729
|
-
//#region src/utils/measure.ts
|
|
7747
|
+
// src/utils/measure.ts
|
|
7730
7748
|
/** A length or plain number. Anything else can't be compared arithmetically. */
|
|
7731
7749
|
const LENGTH_RE = /^(-?\d*\.?\d+)(rem|px|em)?$/;
|
|
7732
7750
|
/**
|
|
@@ -7755,6 +7773,11 @@ function measure(value, rootFontSize) {
|
|
|
7755
7773
|
default: return null;
|
|
7756
7774
|
}
|
|
7757
7775
|
}
|
|
7776
|
+
/** The unit a length is written in (`'px'`, `'rem'`, `'em'`, `''` for none); null for anything else. */
|
|
7777
|
+
function lengthUnit(value) {
|
|
7778
|
+
const match = LENGTH_RE.exec(value.trim());
|
|
7779
|
+
return match ? match[2] ?? "" : null;
|
|
7780
|
+
}
|
|
7758
7781
|
/**
|
|
7759
7782
|
* Same value, allowing for float noise (`0.875rem` × 16 = 13.999999999999998).
|
|
7760
7783
|
* A unitless number and a length are never the same value, whatever the digits.
|
|
@@ -7805,20 +7828,23 @@ function closestOnScale(cache, bare, rootFontSize, limit = 3) {
|
|
|
7805
7828
|
distance: Math.abs(px - written.px)
|
|
7806
7829
|
});
|
|
7807
7830
|
};
|
|
7831
|
+
const sign = written.px < 0 ? -1 : 1;
|
|
7832
|
+
const named = (className) => sign < 0 ? `-${className}` : className;
|
|
7808
7833
|
for (const [literal, className] of cache.tokenValuesFor(prefix)) {
|
|
7809
7834
|
const token = measure(literal, rootFontSize);
|
|
7810
|
-
if (token
|
|
7835
|
+
if (token === null || token.unitless) continue;
|
|
7836
|
+
if (sign > 0 || cache.isValid(named(className))) add(named(className), sign * token.px);
|
|
7811
7837
|
}
|
|
7812
7838
|
const scale = cache.scale;
|
|
7813
7839
|
if (scale && cache.readsScale(prefix)) {
|
|
7814
7840
|
const unit = measure(scale.unit, rootFontSize);
|
|
7815
7841
|
if (unit !== null && !unit.unitless && unit.px > 0) {
|
|
7816
|
-
const steps = written.px / unit.px / scale.step;
|
|
7842
|
+
const steps = sign * written.px / unit.px / scale.step;
|
|
7817
7843
|
for (const n of /* @__PURE__ */ new Set([Math.floor(steps + 1e-9), Math.ceil(steps - 1e-9)])) {
|
|
7818
7844
|
const count = n * scale.step;
|
|
7819
|
-
if (count < 0) continue;
|
|
7820
|
-
const className = `${prefix}-${formatStep(count)}
|
|
7821
|
-
if (cache.isValid(className)) add(className, count * unit.px);
|
|
7845
|
+
if (count < 0 || sign < 0 && count === 0) continue;
|
|
7846
|
+
const className = named(`${prefix}-${formatStep(count)}`);
|
|
7847
|
+
if (cache.isValid(className)) add(className, sign * count * unit.px);
|
|
7822
7848
|
}
|
|
7823
7849
|
}
|
|
7824
7850
|
}
|
|
@@ -7840,8 +7866,7 @@ function formatOptions(options) {
|
|
|
7840
7866
|
const parts = options.map((o) => `${o.className} (${o.value})`);
|
|
7841
7867
|
return parts.length <= 1 ? parts[0] ?? "" : `${parts.slice(0, -1).join(", ")} or ${parts.at(-1)}`;
|
|
7842
7868
|
}
|
|
7843
|
-
|
|
7844
|
-
//#region src/rules/no-arbitrary-value.ts
|
|
7869
|
+
// src/rules/no-arbitrary-value.ts
|
|
7845
7870
|
const SHORTHAND_VAR = /^-?[a-z][\w-]*?-\((?:[a-z-]+:)?(--[\w-]+)\)(?:\/.+)?$/;
|
|
7846
7871
|
const EXPLICIT_VAR = /^-?[a-z][\w-]*?-\[(?:[a-z-]+:)?var\((--[\w-]+)(?:,[^\]]*)?\)\](?:\/.+)?$/;
|
|
7847
7872
|
/**
|
|
@@ -7958,8 +7983,7 @@ const noArbitraryValue = defineRule({
|
|
|
7958
7983
|
return createExtractorVisitors(context, check);
|
|
7959
7984
|
}
|
|
7960
7985
|
});
|
|
7961
|
-
|
|
7962
|
-
//#region src/rules/enforce-consistent-important-position.ts
|
|
7986
|
+
// src/rules/enforce-consistent-important-position.ts
|
|
7963
7987
|
const enforceConsistentImportantPosition = defineRule({
|
|
7964
7988
|
meta: {
|
|
7965
7989
|
type: "suggestion",
|
|
@@ -8013,8 +8037,7 @@ const enforceConsistentImportantPosition = defineRule({
|
|
|
8013
8037
|
return createExtractorVisitors(context, check);
|
|
8014
8038
|
}
|
|
8015
8039
|
});
|
|
8016
|
-
|
|
8017
|
-
//#region src/rules/enforce-negative-arbitrary-values.ts
|
|
8040
|
+
// src/rules/enforce-negative-arbitrary-values.ts
|
|
8018
8041
|
const SIMPLE_DIMENSION = /^\d*\.?\d+[a-z%]*$/;
|
|
8019
8042
|
function fixClass(cls) {
|
|
8020
8043
|
const { utility, variant } = splitUtilityAndVariant(cls);
|
|
@@ -8071,8 +8094,7 @@ const enforceNegativeArbitraryValues = defineRule({
|
|
|
8071
8094
|
return createExtractorVisitors(context, check);
|
|
8072
8095
|
}
|
|
8073
8096
|
});
|
|
8074
|
-
|
|
8075
|
-
//#region src/rules/enforce-consistent-variable-syntax.ts
|
|
8097
|
+
// src/rules/enforce-consistent-variable-syntax.ts
|
|
8076
8098
|
const enforceConsistentVariableSyntax = defineRule({
|
|
8077
8099
|
meta: {
|
|
8078
8100
|
type: "suggestion",
|
|
@@ -8120,8 +8142,7 @@ const enforceConsistentVariableSyntax = defineRule({
|
|
|
8120
8142
|
return createExtractorVisitors(context, check);
|
|
8121
8143
|
}
|
|
8122
8144
|
});
|
|
8123
|
-
|
|
8124
|
-
//#region src/rules/no-dark-without-light.ts
|
|
8145
|
+
// src/rules/no-dark-without-light.ts
|
|
8125
8146
|
const DEFAULT_VARIANTS = ["dark"];
|
|
8126
8147
|
const KNOWN_PREFIXES = [
|
|
8127
8148
|
"rounded-tl",
|
|
@@ -8375,8 +8396,7 @@ const noDarkWithoutLight = defineRule({
|
|
|
8375
8396
|
return createExtractorVisitors(context, check);
|
|
8376
8397
|
}
|
|
8377
8398
|
});
|
|
8378
|
-
|
|
8379
|
-
//#region src/utils/color-literal.ts
|
|
8399
|
+
// src/utils/color-literal.ts
|
|
8380
8400
|
/**
|
|
8381
8401
|
* Does this CSS value contain a hardcoded color literal, anywhere in it?
|
|
8382
8402
|
*
|
|
@@ -8500,8 +8520,7 @@ function containsColorLiteral(value) {
|
|
|
8500
8520
|
}
|
|
8501
8521
|
return false;
|
|
8502
8522
|
}
|
|
8503
|
-
|
|
8504
|
-
//#region src/utils/theme-colors.ts
|
|
8523
|
+
// src/utils/theme-colors.ts
|
|
8505
8524
|
/** How many of the project's colors a message names before `(+N more)`. */
|
|
8506
8525
|
const LISTED = 12;
|
|
8507
8526
|
const listed = /* @__PURE__ */ new WeakMap();
|
|
@@ -8520,8 +8539,7 @@ function themeColorList(cache) {
|
|
|
8520
8539
|
}
|
|
8521
8540
|
return list;
|
|
8522
8541
|
}
|
|
8523
|
-
|
|
8524
|
-
//#region src/rules/no-hardcoded-colors.ts
|
|
8542
|
+
// src/rules/no-hardcoded-colors.ts
|
|
8525
8543
|
const VAR_REF_RE = /var\(\s*--[\w-]+/i;
|
|
8526
8544
|
/**
|
|
8527
8545
|
* Does the arbitrary value the user wrote carry a hardcoded colour?
|
|
@@ -8602,8 +8620,7 @@ const noHardcodedColors = defineRule({
|
|
|
8602
8620
|
return createExtractorVisitors(context, check);
|
|
8603
8621
|
}
|
|
8604
8622
|
});
|
|
8605
|
-
|
|
8606
|
-
//#region src/rules/no-contradicting-variants.ts
|
|
8623
|
+
// src/rules/no-contradicting-variants.ts
|
|
8607
8624
|
const STATIC_PROP_GROUPS = /* @__PURE__ */ new Map([
|
|
8608
8625
|
["block", "display"],
|
|
8609
8626
|
["inline-block", "display"],
|
|
@@ -8701,8 +8718,7 @@ const noContradictingVariants = defineRule({
|
|
|
8701
8718
|
return createExtractorVisitors(context, check);
|
|
8702
8719
|
}
|
|
8703
8720
|
});
|
|
8704
|
-
|
|
8705
|
-
//#region src/rules/consistent-variant-order.ts
|
|
8721
|
+
// src/rules/consistent-variant-order.ts
|
|
8706
8722
|
/**
|
|
8707
8723
|
* The order chains are written in, outermost first: where the page is
|
|
8708
8724
|
* (viewport, features, color scheme, container, media type, direction), then
|
|
@@ -8946,8 +8962,7 @@ const consistentVariantOrder = defineRule({
|
|
|
8946
8962
|
return createExtractorVisitors(context, check);
|
|
8947
8963
|
}
|
|
8948
8964
|
});
|
|
8949
|
-
|
|
8950
|
-
//#region src/rules/enforce-consistent-line-wrapping.ts
|
|
8965
|
+
// src/rules/enforce-consistent-line-wrapping.ts
|
|
8951
8966
|
const DEFAULT_PRINT_WIDTH = 80;
|
|
8952
8967
|
const DEFAULT_GROUP = "newLine";
|
|
8953
8968
|
const DEFAULT_WRAP_STRINGS = "never";
|
|
@@ -9303,8 +9318,7 @@ const enforceConsistentLineWrapping = defineRule({
|
|
|
9303
9318
|
return createExtractorVisitors(context, check, { raw: true });
|
|
9304
9319
|
}
|
|
9305
9320
|
});
|
|
9306
|
-
|
|
9307
|
-
//#region src/rules/no-unnecessary-arbitrary-value.ts
|
|
9321
|
+
// src/rules/no-unnecessary-arbitrary-value.ts
|
|
9308
9322
|
const noUnnecessaryArbitraryValue = defineRule({
|
|
9309
9323
|
meta: {
|
|
9310
9324
|
type: "suggestion",
|
|
@@ -9354,8 +9368,7 @@ const noUnnecessaryArbitraryValue = defineRule({
|
|
|
9354
9368
|
return createExtractorVisitors(context, check);
|
|
9355
9369
|
}
|
|
9356
9370
|
});
|
|
9357
|
-
|
|
9358
|
-
//#region src/rules/prefer-theme-tokens.ts
|
|
9371
|
+
// src/rules/prefer-theme-tokens.ts
|
|
9359
9372
|
/**
|
|
9360
9373
|
* Match `prefix-(--name)` or `prefix-(--name)/modifier`.
|
|
9361
9374
|
* Captures: 1=prefix, 2=variable name, 3=optional `/modifier` (kept verbatim).
|
|
@@ -9437,8 +9450,7 @@ const preferThemeTokens = defineRule({
|
|
|
9437
9450
|
return createExtractorVisitors(context, check);
|
|
9438
9451
|
}
|
|
9439
9452
|
});
|
|
9440
|
-
|
|
9441
|
-
//#region src/rules/prefer-scale-token.ts
|
|
9453
|
+
// src/rules/prefer-scale-token.ts
|
|
9442
9454
|
const preferScaleToken = defineRule({
|
|
9443
9455
|
meta: {
|
|
9444
9456
|
type: "suggestion",
|
|
@@ -9457,7 +9469,8 @@ const preferScaleToken = defineRule({
|
|
|
9457
9469
|
allow: {
|
|
9458
9470
|
type: "array",
|
|
9459
9471
|
items: { type: "string" }
|
|
9460
|
-
}
|
|
9472
|
+
},
|
|
9473
|
+
sameUnit: { type: "boolean" }
|
|
9461
9474
|
},
|
|
9462
9475
|
additionalProperties: false
|
|
9463
9476
|
}],
|
|
@@ -9473,7 +9486,8 @@ const preferScaleToken = defineRule({
|
|
|
9473
9486
|
const getDS = createLazyLoader(context);
|
|
9474
9487
|
const getOptions = createLazyOptions(context, (o) => ({
|
|
9475
9488
|
step: typeof o?.step === "number" ? o.step : null,
|
|
9476
|
-
allow: o?.allow ?? []
|
|
9489
|
+
allow: o?.allow ?? [],
|
|
9490
|
+
sameUnit: o?.sameUnit === true
|
|
9477
9491
|
}));
|
|
9478
9492
|
const rootFontSize = createLazySettings(context, rootFontSizeFromSettings);
|
|
9479
9493
|
/**
|
|
@@ -9485,7 +9499,7 @@ const preferScaleToken = defineRule({
|
|
|
9485
9499
|
* from the design system, so neither is a name table.
|
|
9486
9500
|
*/
|
|
9487
9501
|
function equivalentOf(cache, bare) {
|
|
9488
|
-
const { step: stepOverride, allow } = getOptions();
|
|
9502
|
+
const { step: stepOverride, allow, sameUnit } = getOptions();
|
|
9489
9503
|
if (allow.some((prefix) => bare.startsWith(prefix))) return null;
|
|
9490
9504
|
if (cache.getNamedEquivalent(bare)) return null;
|
|
9491
9505
|
const value = getArbitraryValue(bare);
|
|
@@ -9494,15 +9508,21 @@ const preferScaleToken = defineRule({
|
|
|
9494
9508
|
if (written === null) return null;
|
|
9495
9509
|
const prefix = arbitraryPrefix(bare);
|
|
9496
9510
|
if (!prefix) return null;
|
|
9511
|
+
const writtenUnit = lengthUnit(value);
|
|
9512
|
+
const unitAllowed = (literal) => {
|
|
9513
|
+
const unit = lengthUnit(literal);
|
|
9514
|
+
return sameUnit ? unit === writtenUnit : unit === "em" === (writtenUnit === "em");
|
|
9515
|
+
};
|
|
9497
9516
|
for (const [literal, className] of cache.tokenValuesFor(prefix)) {
|
|
9498
9517
|
const token = measure(literal, rootFontSize());
|
|
9499
|
-
if (token !== null && sameMeasure(written, token)) return className;
|
|
9518
|
+
if (token !== null && sameMeasure(written, token) && unitAllowed(literal)) return className;
|
|
9500
9519
|
}
|
|
9501
9520
|
if (!cache.readsScale(prefix)) return null;
|
|
9502
9521
|
const scale = cache.scale;
|
|
9503
9522
|
if (!scale) return null;
|
|
9504
9523
|
const unit = measure(scale.unit, rootFontSize());
|
|
9505
9524
|
if (unit === null || unit.px <= 0 || unit.unitless !== written.unitless) return null;
|
|
9525
|
+
if (!unitAllowed(scale.unit)) return null;
|
|
9506
9526
|
const steps = written.px / unit.px;
|
|
9507
9527
|
if (steps < 0) return null;
|
|
9508
9528
|
if (!isOnStep(steps, stepOverride ?? scale.step)) return null;
|
|
@@ -9539,8 +9559,7 @@ const preferScaleToken = defineRule({
|
|
|
9539
9559
|
return createExtractorVisitors(context, check);
|
|
9540
9560
|
}
|
|
9541
9561
|
});
|
|
9542
|
-
|
|
9543
|
-
//#region src/rules/no-dynamic-classes.ts
|
|
9562
|
+
// src/rules/no-dynamic-classes.ts
|
|
9544
9563
|
const STATIC_UTILITY_ROOTS = [
|
|
9545
9564
|
"@container",
|
|
9546
9565
|
"accent",
|
|
@@ -9888,8 +9907,7 @@ const noDynamicClasses = defineRule({
|
|
|
9888
9907
|
return createExtractorVisitors(context, check, { raw: true });
|
|
9889
9908
|
}
|
|
9890
9909
|
});
|
|
9891
|
-
|
|
9892
|
-
//#region src/rules/no-default-palette.ts
|
|
9910
|
+
// src/rules/no-default-palette.ts
|
|
9893
9911
|
const COLOR_VAR = "--color-";
|
|
9894
9912
|
/** `white`, `gray-*` → a test on palette color names. */
|
|
9895
9913
|
function compileAllow(allow) {
|
|
@@ -9964,8 +9982,7 @@ const noDefaultPalette = defineRule({
|
|
|
9964
9982
|
return createExtractorVisitors(context, check);
|
|
9965
9983
|
}
|
|
9966
9984
|
});
|
|
9967
|
-
|
|
9968
|
-
//#region src/utils/component-scanner.ts
|
|
9985
|
+
// src/utils/component-scanner.ts
|
|
9969
9986
|
const PUNCT = /* @__PURE__ */ new Set([
|
|
9970
9987
|
"(",
|
|
9971
9988
|
")",
|
|
@@ -10330,8 +10347,7 @@ function rootClasses(p, start, end, definitions) {
|
|
|
10330
10347
|
};
|
|
10331
10348
|
}
|
|
10332
10349
|
}
|
|
10333
|
-
|
|
10334
|
-
//#region src/utils/style-signature.ts
|
|
10350
|
+
// src/utils/style-signature.ts
|
|
10335
10351
|
/**
|
|
10336
10352
|
* Where the element sits and how it lays out its children — which a copy
|
|
10337
10353
|
* adapts to its page — rather than what it looks like.
|
|
@@ -10557,8 +10573,7 @@ function resemblance(component, element) {
|
|
|
10557
10573
|
sharedSurface
|
|
10558
10574
|
};
|
|
10559
10575
|
}
|
|
10560
|
-
|
|
10561
|
-
//#region src/rules/no-borrowed-component-styles.ts
|
|
10576
|
+
// src/rules/no-borrowed-component-styles.ts
|
|
10562
10577
|
/** Fewer shared declarations than this is a coincidence, not a copy. */
|
|
10563
10578
|
const MIN_SHARED = 4;
|
|
10564
10579
|
/** Shared declarations over all the declarations either side sets. */
|
|
@@ -10660,8 +10675,7 @@ function nativeTag(attribute) {
|
|
|
10660
10675
|
if (element?.type !== "JSXOpeningElement" || element.name.type !== "JSXIdentifier") return null;
|
|
10661
10676
|
return /^[a-z]/.test(element.name.name) ? element.name : null;
|
|
10662
10677
|
}
|
|
10663
|
-
|
|
10664
|
-
//#region src/index.ts
|
|
10678
|
+
// src/index.ts
|
|
10665
10679
|
const plugin = definePlugin({
|
|
10666
10680
|
meta: { name: "tailwindcss" },
|
|
10667
10681
|
rules: {
|
|
@@ -10783,5 +10797,4 @@ const plugin = definePlugin({
|
|
|
10783
10797
|
})
|
|
10784
10798
|
}
|
|
10785
10799
|
});
|
|
10786
|
-
//#endregion
|
|
10787
10800
|
module.exports = plugin;
|