oxlint-tailwindcss 0.7.0 → 0.8.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/README.md +13 -3
- package/dist/index.cjs +206 -58
- package/dist/index.d.cts +1 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +206 -58
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -10
package/dist/index.mjs
CHANGED
|
@@ -660,7 +660,7 @@ function getArbitraryValue(cls) {
|
|
|
660
660
|
//#endregion
|
|
661
661
|
//#region src/design-system/cache.ts
|
|
662
662
|
/** Strip `!` modifier from start or end: `!flex` → `flex`, `flex!` → `flex` */
|
|
663
|
-
function stripImportant(cls) {
|
|
663
|
+
function stripImportant$1(cls) {
|
|
664
664
|
if (cls.startsWith("!")) return {
|
|
665
665
|
bare: cls.slice(1),
|
|
666
666
|
important: true
|
|
@@ -714,7 +714,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
714
714
|
const canonicalUtility = this.canonicalMap.get(utility);
|
|
715
715
|
if (canonicalUtility !== void 0) return className.slice(0, className.length - utility.length) + canonicalUtility;
|
|
716
716
|
}
|
|
717
|
-
const { bare, important } = stripImportant(utility);
|
|
717
|
+
const { bare, important } = stripImportant$1(utility);
|
|
718
718
|
if (important) {
|
|
719
719
|
const canonicalBare = this.canonicalMap.get(bare);
|
|
720
720
|
if (canonicalBare !== void 0) {
|
|
@@ -772,7 +772,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
772
772
|
if (this.validitySet.has(className)) return true;
|
|
773
773
|
const utility = extractUtility(className);
|
|
774
774
|
if (utility !== className && this.validitySet.has(utility)) return true;
|
|
775
|
-
const { bare } = stripImportant(utility);
|
|
775
|
+
const { bare } = stripImportant$1(utility);
|
|
776
776
|
if (bare !== utility && this.validitySet.has(bare)) return true;
|
|
777
777
|
const slashIdx = bare.lastIndexOf("/");
|
|
778
778
|
if (slashIdx > 0) {
|
|
@@ -796,7 +796,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
796
796
|
const hasVariant = utility !== className;
|
|
797
797
|
let baseOrder = this.orderMap.get(utility) ?? void 0;
|
|
798
798
|
if (baseOrder === void 0) {
|
|
799
|
-
const { bare, important } = stripImportant(utility);
|
|
799
|
+
const { bare, important } = stripImportant$1(utility);
|
|
800
800
|
if (important) baseOrder = this.orderMap.get(bare) ?? void 0;
|
|
801
801
|
}
|
|
802
802
|
if (baseOrder === void 0) {
|
|
@@ -805,13 +805,13 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
805
805
|
const base = utility.slice(0, slashIdx);
|
|
806
806
|
baseOrder = this.orderMap.get(base) ?? void 0;
|
|
807
807
|
if (baseOrder === void 0) {
|
|
808
|
-
const { bare, important } = stripImportant(base);
|
|
808
|
+
const { bare, important } = stripImportant$1(base);
|
|
809
809
|
if (important) baseOrder = this.orderMap.get(bare) ?? void 0;
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
813
|
if (baseOrder === void 0) {
|
|
814
|
-
const stripped = stripImportant(utility).bare;
|
|
814
|
+
const stripped = stripImportant$1(utility).bare;
|
|
815
815
|
const bracketIdx = stripped.indexOf("[");
|
|
816
816
|
if (bracketIdx > 0) {
|
|
817
817
|
const prefix = stripped.slice(0, bracketIdx);
|
|
@@ -819,7 +819,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
819
819
|
}
|
|
820
820
|
}
|
|
821
821
|
if (baseOrder === void 0) {
|
|
822
|
-
const stripped = stripImportant(utility).bare;
|
|
822
|
+
const stripped = stripImportant$1(utility).bare;
|
|
823
823
|
const parenIdx = stripped.indexOf("(");
|
|
824
824
|
if (parenIdx > 0) {
|
|
825
825
|
const prefix = stripped.slice(0, parenIdx);
|
|
@@ -827,7 +827,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
829
|
if (baseOrder === void 0) {
|
|
830
|
-
const stripped = stripImportant(utility).bare;
|
|
830
|
+
const stripped = stripImportant$1(utility).bare;
|
|
831
831
|
const numericMatch = /^(.+)-(\d+\.?\d*)$/.exec(stripped);
|
|
832
832
|
if (numericMatch && this.getKnownPrefixes().has(numericMatch[1])) baseOrder = this.findOrderByPrefix(numericMatch[1] + "-");
|
|
833
833
|
}
|
|
@@ -846,7 +846,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
846
846
|
getCssProperties(className) {
|
|
847
847
|
const result = this.cssPropsMap.get(className);
|
|
848
848
|
if (result) return result;
|
|
849
|
-
const { bare, important } = stripImportant(className);
|
|
849
|
+
const { bare, important } = stripImportant$1(className);
|
|
850
850
|
if (important) return this.cssPropsMap.get(bare) ?? [];
|
|
851
851
|
return [];
|
|
852
852
|
}
|
|
@@ -859,7 +859,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
859
859
|
getNamedEquivalent(className) {
|
|
860
860
|
const result = this.arbitraryEquivMap.get(className);
|
|
861
861
|
if (result) return result;
|
|
862
|
-
const { bare, important } = stripImportant(className);
|
|
862
|
+
const { bare, important } = stripImportant$1(className);
|
|
863
863
|
if (important) return this.arbitraryEquivMap.get(bare) ?? null;
|
|
864
864
|
return null;
|
|
865
865
|
}
|
|
@@ -1028,6 +1028,47 @@ async function main() {
|
|
|
1028
1028
|
}
|
|
1029
1029
|
}
|
|
1030
1030
|
|
|
1031
|
+
// Legacy v3 classes that produce valid CSS in v4 but are not enumerated by
|
|
1032
|
+
// getClassList(). Tailwind's canonicalizeCandidates() still rewrites them to
|
|
1033
|
+
// their v4 equivalent, so we feed them in explicitly. Without this pass,
|
|
1034
|
+
// classes like \`break-words\` would be invisible to enforce-canonical
|
|
1035
|
+
// (issue #16).
|
|
1036
|
+
// - Fixed renames mirror the internal v3->v4 map in tailwindcss/canonicalize.
|
|
1037
|
+
// - Pattern renames (start-* -> inset-s-*, end-* -> inset-e-*) are derived
|
|
1038
|
+
// from the inset-{s,e}-* utilities present in validClasses so we cover
|
|
1039
|
+
// every numeric/named value the design system exposes.
|
|
1040
|
+
const legacyCandidates = [
|
|
1041
|
+
'order-none',
|
|
1042
|
+
'break-words',
|
|
1043
|
+
'overflow-ellipsis',
|
|
1044
|
+
'flex-grow', 'flex-grow-0', 'flex-grow-1',
|
|
1045
|
+
'flex-shrink', 'flex-shrink-0', 'flex-shrink-1',
|
|
1046
|
+
'decoration-clone', 'decoration-slice',
|
|
1047
|
+
'bg-gradient-to-t', 'bg-gradient-to-tr', 'bg-gradient-to-r', 'bg-gradient-to-br',
|
|
1048
|
+
'bg-gradient-to-b', 'bg-gradient-to-bl', 'bg-gradient-to-l', 'bg-gradient-to-tl',
|
|
1049
|
+
];
|
|
1050
|
+
for (const cls of validClasses) {
|
|
1051
|
+
if (cls.startsWith('inset-s-')) legacyCandidates.push('start-' + cls.slice(8));
|
|
1052
|
+
else if (cls.startsWith('-inset-s-')) legacyCandidates.push('-start-' + cls.slice(9));
|
|
1053
|
+
else if (cls.startsWith('inset-e-')) legacyCandidates.push('end-' + cls.slice(8));
|
|
1054
|
+
else if (cls.startsWith('-inset-e-')) legacyCandidates.push('-end-' + cls.slice(9));
|
|
1055
|
+
}
|
|
1056
|
+
const legacyToProcess = legacyCandidates.filter(cls => !validSet.has(cls));
|
|
1057
|
+
if (legacyToProcess.length > 0) {
|
|
1058
|
+
const legacyCssResults = ds.candidatesToCss(legacyToProcess);
|
|
1059
|
+
for (let i = 0; i < legacyToProcess.length; i++) {
|
|
1060
|
+
if (legacyCssResults[i] == null) continue;
|
|
1061
|
+
const cls = legacyToProcess[i];
|
|
1062
|
+
const result = ds.canonicalizeCandidates([cls]);
|
|
1063
|
+
if (result[0] && result[0] !== cls) {
|
|
1064
|
+
canonical[cls] = result[0];
|
|
1065
|
+
}
|
|
1066
|
+
// Mark as valid so no-unknown-classes doesn't flag legacy spellings.
|
|
1067
|
+
validClasses.push(cls);
|
|
1068
|
+
validSet.add(cls);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1031
1072
|
// Sort order — include extra candidates so bare utilities (rounded, blur, etc.) get order
|
|
1032
1073
|
const allForOrder = [...classNames];
|
|
1033
1074
|
for (const cls of validClasses) {
|
|
@@ -1156,7 +1197,12 @@ async function main() {
|
|
|
1156
1197
|
}
|
|
1157
1198
|
}
|
|
1158
1199
|
|
|
1159
|
-
// Arbitrary equivalents: map arbitrary forms to named equivalents
|
|
1200
|
+
// Arbitrary equivalents: map arbitrary forms to named equivalents.
|
|
1201
|
+
// Enumerate every dash split point so multi-segment utilities (e.g.
|
|
1202
|
+
// bg-card-foreground) emit candidates for every prefix; lastIndexOf
|
|
1203
|
+
// alone drops the shorter prefix and misses multi-segment mappings.
|
|
1204
|
+
// Start at indexOf('-', 1) so negative utilities (e.g. -translate-x-1)
|
|
1205
|
+
// keep their leading '-' in every prefix instead of producing '' + '-[…]'.
|
|
1160
1206
|
const arbitraryEquivalents = {};
|
|
1161
1207
|
const candidates = [];
|
|
1162
1208
|
for (const cls of validClasses) {
|
|
@@ -1168,10 +1214,10 @@ async function main() {
|
|
|
1168
1214
|
const pvMatch = cssText.match(/^\\s+([\\w-]+)\\s*:\\s*(.+?)\\s*;?\\s*$/m);
|
|
1169
1215
|
if (!pvMatch) continue;
|
|
1170
1216
|
const value = pvMatch[2].trim().replace(/;$/, '');
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1217
|
+
for (let dashPos = cls.indexOf('-', 1); dashPos > 0; dashPos = cls.indexOf('-', dashPos + 1)) {
|
|
1218
|
+
const prefix = cls.slice(0, dashPos);
|
|
1219
|
+
candidates.push({ arbitraryForm: prefix + '-[' + value + ']', namedCls: cls, namedCss: cssText });
|
|
1220
|
+
}
|
|
1175
1221
|
}
|
|
1176
1222
|
function extractDeclarations(css) {
|
|
1177
1223
|
const openBrace = css.indexOf('{');
|
|
@@ -1195,7 +1241,37 @@ async function main() {
|
|
|
1195
1241
|
main().catch(e => { process.stderr.write(e.message); process.exit(1); });
|
|
1196
1242
|
`;
|
|
1197
1243
|
const CACHE_DIR = join(tmpdir(), "oxlint-tailwindcss");
|
|
1198
|
-
|
|
1244
|
+
/**
|
|
1245
|
+
* Cache key derived from:
|
|
1246
|
+
* - md5(PRECOMPUTE_SCRIPT): auto-invalidates when our precompute logic changes,
|
|
1247
|
+
* since the shape and content of the cached JSON is fully determined by what
|
|
1248
|
+
* this script prints to stdout.
|
|
1249
|
+
* - @tailwindcss/node version: auto-invalidates when the consumer upgrades
|
|
1250
|
+
* tailwindcss (e.g. 4.2 → 4.3 adding `zoom-*`, `tab-*`, `scrollbar-*` etc.),
|
|
1251
|
+
* so `validClasses`, `cssProps`, `canonical`, and `arbitraryEquivalents`
|
|
1252
|
+
* reflect the installed version. @tailwindcss/node and tailwindcss are
|
|
1253
|
+
* published together, so their versions match.
|
|
1254
|
+
*/
|
|
1255
|
+
function computeCacheKey(scriptContent, tailwindVersion) {
|
|
1256
|
+
return `${createHash("md5").update(scriptContent).digest("hex").slice(0, 8)}:${tailwindVersion}`;
|
|
1257
|
+
}
|
|
1258
|
+
function readTailwindVersion() {
|
|
1259
|
+
try {
|
|
1260
|
+
let dir = dirname(__require.resolve("@tailwindcss/node"));
|
|
1261
|
+
while (true) {
|
|
1262
|
+
const candidate = join(dir, "package.json");
|
|
1263
|
+
if (existsSync(candidate)) {
|
|
1264
|
+
const pkg = JSON.parse(readFileSync(candidate, "utf-8"));
|
|
1265
|
+
if (pkg.name === "@tailwindcss/node" && pkg.version) return pkg.version;
|
|
1266
|
+
}
|
|
1267
|
+
const parent = dirname(dir);
|
|
1268
|
+
if (parent === dir) break;
|
|
1269
|
+
dir = parent;
|
|
1270
|
+
}
|
|
1271
|
+
} catch {}
|
|
1272
|
+
return "unknown";
|
|
1273
|
+
}
|
|
1274
|
+
const CACHE_KEY = computeCacheKey(PRECOMPUTE_SCRIPT, readTailwindVersion());
|
|
1199
1275
|
/**
|
|
1200
1276
|
* Two-level disk cache for monorepo deduplication:
|
|
1201
1277
|
*
|
|
@@ -1206,10 +1282,10 @@ const CACHE_VERSION = 11;
|
|
|
1206
1282
|
* paths share a single content cache entry, avoiding redundant child process spawns.
|
|
1207
1283
|
*/
|
|
1208
1284
|
function getMtimeIndexPath(cssPath, mtime) {
|
|
1209
|
-
return join(CACHE_DIR, `${createHash("md5").update(
|
|
1285
|
+
return join(CACHE_DIR, `${createHash("md5").update(`${CACHE_KEY}:${cssPath}:${mtime}`).digest("hex")}.idx`);
|
|
1210
1286
|
}
|
|
1211
1287
|
function computeContentHash(content) {
|
|
1212
|
-
return createHash("md5").update(
|
|
1288
|
+
return createHash("md5").update(`${CACHE_KEY}:${content}`).digest("hex");
|
|
1213
1289
|
}
|
|
1214
1290
|
function getContentCachePath(contentHash) {
|
|
1215
1291
|
return join(CACHE_DIR, `${contentHash}.json`);
|
|
@@ -1466,6 +1542,38 @@ function cachedAutoDetect(filePath) {
|
|
|
1466
1542
|
return result;
|
|
1467
1543
|
}
|
|
1468
1544
|
/**
|
|
1545
|
+
* Pure resolution of which CSS entry point to use for a given context.
|
|
1546
|
+
*
|
|
1547
|
+
* Resolution order: rule option `entryPoint` > `settingsEntry` (string or
|
|
1548
|
+
* closest-of-array) > `autoDetect(filePath)` > `lastPath` fallback.
|
|
1549
|
+
*
|
|
1550
|
+
* Returns `isExplicit: true` when the result came from a rule option or
|
|
1551
|
+
* settings (not auto-detect / lastPath) — the caller uses this to decide
|
|
1552
|
+
* whether to update the shared `lastLoadedPath` fallback. Auto-detect
|
|
1553
|
+
* results never update the fallback (prevents cross-package contamination
|
|
1554
|
+
* in monorepos).
|
|
1555
|
+
*
|
|
1556
|
+
* `autoDetect` is injected for testability; in production it's
|
|
1557
|
+
* `cachedAutoDetect`. Pure: does not touch module state.
|
|
1558
|
+
*/
|
|
1559
|
+
function resolveCssPath(args) {
|
|
1560
|
+
const { entryPoint, settingsEntry, filePath, lastPath, autoDetect } = args;
|
|
1561
|
+
const explicit = entryPoint ?? (Array.isArray(settingsEntry) ? resolveClosestEntryPoint(settingsEntry, filePath) : settingsEntry);
|
|
1562
|
+
if (explicit) return {
|
|
1563
|
+
path: explicit,
|
|
1564
|
+
isExplicit: true
|
|
1565
|
+
};
|
|
1566
|
+
const detected = autoDetect(filePath);
|
|
1567
|
+
if (detected) return {
|
|
1568
|
+
path: detected,
|
|
1569
|
+
isExplicit: false
|
|
1570
|
+
};
|
|
1571
|
+
return {
|
|
1572
|
+
path: lastPath ?? null,
|
|
1573
|
+
isExplicit: false
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1469
1577
|
* Returns the design system cache, loading synchronously on first call.
|
|
1470
1578
|
* Uses execFileSync internally to bridge the async Tailwind API.
|
|
1471
1579
|
*
|
|
@@ -1476,16 +1584,20 @@ function cachedAutoDetect(filePath) {
|
|
|
1476
1584
|
* Resolution order: rule option `entryPoint` > `settings.tailwindcss.entryPoint` > auto-detect.
|
|
1477
1585
|
*/
|
|
1478
1586
|
function getLoadedDesignSystem(entryPoint, settings, filePath) {
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1481
|
-
|
|
1587
|
+
const { path: cssPath, isExplicit } = resolveCssPath({
|
|
1588
|
+
entryPoint,
|
|
1589
|
+
settingsEntry: entryPointFromSettings(settings),
|
|
1590
|
+
filePath,
|
|
1591
|
+
lastPath: lastLoadedPath,
|
|
1592
|
+
autoDetect: cachedAutoDetect
|
|
1593
|
+
});
|
|
1482
1594
|
if (!cssPath) return null;
|
|
1483
1595
|
const resolvedPath = resolve(cssPath);
|
|
1484
1596
|
try {
|
|
1485
1597
|
const mtime = statSync(resolvedPath).mtimeMs;
|
|
1486
1598
|
const cached = dsCache.get(resolvedPath);
|
|
1487
1599
|
if (cached && cached.mtime === mtime) {
|
|
1488
|
-
if (
|
|
1600
|
+
if (isExplicit) lastLoadedPath = resolvedPath;
|
|
1489
1601
|
return {
|
|
1490
1602
|
cache: cached.cache,
|
|
1491
1603
|
entryPoint: resolvedPath
|
|
@@ -1499,7 +1611,7 @@ function getLoadedDesignSystem(entryPoint, settings, filePath) {
|
|
|
1499
1611
|
mtime
|
|
1500
1612
|
});
|
|
1501
1613
|
debugLog(`Loaded design system from "${resolvedPath}"`);
|
|
1502
|
-
if (
|
|
1614
|
+
if (isExplicit) lastLoadedPath = resolvedPath;
|
|
1503
1615
|
return {
|
|
1504
1616
|
cache,
|
|
1505
1617
|
entryPoint: resolvedPath
|
|
@@ -1800,6 +1912,74 @@ const noUnknownClasses = defineRule({
|
|
|
1800
1912
|
});
|
|
1801
1913
|
//#endregion
|
|
1802
1914
|
//#region src/rules/no-conflicting-classes.ts
|
|
1915
|
+
const COMPLEMENTARY_GROUPS = [
|
|
1916
|
+
/^(from|via|to)-/,
|
|
1917
|
+
/^(transition|duration|ease|delay)(?:-|$)/,
|
|
1918
|
+
/^-?(translate|scale|rotate|skew)-/,
|
|
1919
|
+
/^-?mask-((?:linear|radial|conic|[trblxy])(?:-(?:from|via|to|at))?)(?:-|$)/,
|
|
1920
|
+
/^prose(?:-|$)/
|
|
1921
|
+
];
|
|
1922
|
+
const COMPOSITION_PAIRS = [
|
|
1923
|
+
[/^text-/, /^leading-/],
|
|
1924
|
+
[/^text-/, /^tracking-/],
|
|
1925
|
+
[/^border(?:-[0-9]|$)/, /^border-(?:solid|dashed|dotted|double|hidden|none)$/],
|
|
1926
|
+
[/^divide-/, /^border(?:-[trblxyse])?-/],
|
|
1927
|
+
[/^prose(?:-|$)/, /^max-w-/],
|
|
1928
|
+
[/^animate-in$/, /^(?:fade|spin|zoom|blur)-in(?:-|$)|^slide-in-from-/],
|
|
1929
|
+
[/^animate-out$/, /^(?:fade|spin|zoom|blur)-out(?:-|$)|^slide-out-to-/],
|
|
1930
|
+
[/^mask-(?:add|subtract|intersect|exclude)$/, /^-?mask-(?:linear|radial|conic|[trblxy])-/]
|
|
1931
|
+
];
|
|
1932
|
+
function stripImportant(utility) {
|
|
1933
|
+
if (utility.startsWith("!")) return utility.slice(1);
|
|
1934
|
+
if (utility.endsWith("!")) return utility.slice(0, -1);
|
|
1935
|
+
return utility;
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Two utilities compose via CSS custom properties if both define their own
|
|
1939
|
+
* --tw-* properties that don't overlap — they each contribute to a shared
|
|
1940
|
+
* shorthand (e.g. `shadow` and `ring` both end up in `box-shadow` via
|
|
1941
|
+
* different intermediate vars).
|
|
1942
|
+
*/
|
|
1943
|
+
function isCompositionViaCssVars(propsA, propsB) {
|
|
1944
|
+
const customA = propsA.filter((p) => p.startsWith("--"));
|
|
1945
|
+
const customB = propsB.filter((p) => p.startsWith("--"));
|
|
1946
|
+
if (customA.length === 0 || customB.length === 0) return false;
|
|
1947
|
+
return !customA.some((p) => customB.includes(p));
|
|
1948
|
+
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Detect a narrowing override: the later class's CSS properties are a strict
|
|
1951
|
+
* subset of the earlier class's, so the later class refines one of the
|
|
1952
|
+
* shorthand's properties (size-4 h-6, rounded-t-lg rounded-tl-sm, truncate
|
|
1953
|
+
* text-clip). Direction-sensitive: the inverse means the wider later class
|
|
1954
|
+
* clobbers a prior narrower override.
|
|
1955
|
+
*/
|
|
1956
|
+
function isNarrowingOverride(propsEarlier, propsLater) {
|
|
1957
|
+
if (propsLater.length === 0 || propsLater.length >= propsEarlier.length) return false;
|
|
1958
|
+
const setEarlier = new Set(propsEarlier);
|
|
1959
|
+
return propsLater.every((p) => setEarlier.has(p));
|
|
1960
|
+
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Returns true if two classes (within the same variant) should NOT be reported
|
|
1963
|
+
* as conflicting despite sharing CSS properties. Pure: regex tables are passed
|
|
1964
|
+
* in (or default to the module-level constants).
|
|
1965
|
+
*/
|
|
1966
|
+
function shouldSkipPair(a, b, propsA, propsB, rules = {}) {
|
|
1967
|
+
if (isCompositionViaCssVars(propsA, propsB)) return true;
|
|
1968
|
+
if (isNarrowingOverride(propsA, propsB)) return true;
|
|
1969
|
+
const ua = stripImportant(extractUtility(a));
|
|
1970
|
+
const ub = stripImportant(extractUtility(b));
|
|
1971
|
+
const groups = rules.complementaryGroups ?? COMPLEMENTARY_GROUPS;
|
|
1972
|
+
for (const re of groups) {
|
|
1973
|
+
const ma = ua.match(re);
|
|
1974
|
+
const mb = ub.match(re);
|
|
1975
|
+
if (!ma || !mb) continue;
|
|
1976
|
+
if (ma[1] === void 0) return true;
|
|
1977
|
+
if (ma[1] !== mb[1]) return true;
|
|
1978
|
+
}
|
|
1979
|
+
const pairs = rules.compositionPairs ?? COMPOSITION_PAIRS;
|
|
1980
|
+
for (const [reA, reB] of pairs) if (reA.test(ua) && reB.test(ub) || reA.test(ub) && reB.test(ua)) return true;
|
|
1981
|
+
return false;
|
|
1982
|
+
}
|
|
1803
1983
|
const noConflictingClasses = defineRule({
|
|
1804
1984
|
meta: {
|
|
1805
1985
|
type: "problem",
|
|
@@ -1831,43 +2011,9 @@ const noConflictingClasses = defineRule({
|
|
|
1831
2011
|
if (variantClasses.length < 2) continue;
|
|
1832
2012
|
const propsMap = /* @__PURE__ */ new Map();
|
|
1833
2013
|
for (const cls of variantClasses) {
|
|
1834
|
-
|
|
1835
|
-
if (utility.startsWith("!")) utility = utility.slice(1);
|
|
1836
|
-
else if (utility.endsWith("!")) utility = utility.slice(0, -1);
|
|
1837
|
-
const props = cache.getCssProperties(utility);
|
|
2014
|
+
const props = cache.getCssProperties(stripImportant(extractUtility(cls)));
|
|
1838
2015
|
propsMap.set(cls, props);
|
|
1839
2016
|
}
|
|
1840
|
-
const COMPLEMENTARY_GROUPS = [
|
|
1841
|
-
/^(?:from|via|to)-/,
|
|
1842
|
-
/^(?:transition|duration|ease|delay)(?:-|$)/,
|
|
1843
|
-
/^-?(?:translate|scale|rotate|skew)-/,
|
|
1844
|
-
/^prose(?:-|$)/
|
|
1845
|
-
];
|
|
1846
|
-
const COMPOSITION_PAIRS = [
|
|
1847
|
-
[/^text-/, /^leading-/],
|
|
1848
|
-
[/^text-/, /^tracking-/],
|
|
1849
|
-
[/^border(?:-[0-9]|$)/, /^border-(?:solid|dashed|dotted|double|hidden|none)$/],
|
|
1850
|
-
[/^divide-/, /^border(?:-[trblxyse])?-/],
|
|
1851
|
-
[/^prose(?:-|$)/, /^max-w-/]
|
|
1852
|
-
];
|
|
1853
|
-
function isCompositionViaCssVars(propsA, propsB) {
|
|
1854
|
-
const customA = propsA.filter((p) => p.startsWith("--"));
|
|
1855
|
-
const customB = propsB.filter((p) => p.startsWith("--"));
|
|
1856
|
-
if (customA.length === 0 || customB.length === 0) return false;
|
|
1857
|
-
return !customA.some((p) => customB.includes(p));
|
|
1858
|
-
}
|
|
1859
|
-
function shouldSkipPair(a, b, propsA, propsB) {
|
|
1860
|
-
if (isCompositionViaCssVars(propsA, propsB)) return true;
|
|
1861
|
-
let ua = extractUtility(a);
|
|
1862
|
-
let ub = extractUtility(b);
|
|
1863
|
-
if (ua.startsWith("!")) ua = ua.slice(1);
|
|
1864
|
-
else if (ua.endsWith("!")) ua = ua.slice(0, -1);
|
|
1865
|
-
if (ub.startsWith("!")) ub = ub.slice(1);
|
|
1866
|
-
else if (ub.endsWith("!")) ub = ub.slice(0, -1);
|
|
1867
|
-
for (const re of COMPLEMENTARY_GROUPS) if (re.test(ua) && re.test(ub)) return true;
|
|
1868
|
-
for (const [reA, reB] of COMPOSITION_PAIRS) if (reA.test(ua) && reB.test(ub) || reA.test(ub) && reB.test(ua)) return true;
|
|
1869
|
-
return false;
|
|
1870
|
-
}
|
|
1871
2017
|
for (let i = 0; i < variantClasses.length; i++) {
|
|
1872
2018
|
const classA = variantClasses[i];
|
|
1873
2019
|
const propsA = propsMap.get(classA) ?? [];
|
|
@@ -3378,8 +3524,10 @@ const LCH_RE = /^lch\s*\(/;
|
|
|
3378
3524
|
const LAB_RE = /^lab\s*\(/;
|
|
3379
3525
|
const HWB_RE = /^hwb\s*\(/;
|
|
3380
3526
|
const COLOR_RE = /^color\s*\(/;
|
|
3527
|
+
const VAR_REF_RE = /var\(\s*--[\w-]+/i;
|
|
3381
3528
|
function isHardcodedColor(value) {
|
|
3382
3529
|
const trimmed = value.trim();
|
|
3530
|
+
if (VAR_REF_RE.test(trimmed)) return false;
|
|
3383
3531
|
return HEX_RE.test(trimmed) || RGB_RE.test(trimmed) || HSL_RE.test(trimmed) || OKLCH_RE.test(trimmed) || OKLAB_RE.test(trimmed) || LCH_RE.test(trimmed) || LAB_RE.test(trimmed) || HWB_RE.test(trimmed) || COLOR_RE.test(trimmed);
|
|
3384
3532
|
}
|
|
3385
3533
|
function isColorUtility(utility) {
|