oxlint-tailwindcss 0.7.1 → 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 +12 -2
- package/dist/index.cjs +165 -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 +165 -58
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -815,7 +815,7 @@ Detects arbitrary values that have a named Tailwind equivalent. The arbitrary fo
|
|
|
815
815
|
|
|
816
816
|
Suggests replacing raw CSS variable references like `border-(--border)` or `bg-[var(--primary)]` with the equivalent named theme-token utility (`border-border`, `bg-primary`) when one exists in your design system.
|
|
817
817
|
|
|
818
|
-
Unlike `no-unnecessary-arbitrary-value`, this rule fires even when the named utility produces _different_ CSS — for example, in
|
|
818
|
+
Unlike `no-unnecessary-arbitrary-value`, this rule fires even when the named utility produces _different_ CSS — for example, in themes that wrap the raw variable in a color function (`--color-border: hsl(var(--border))`). Useful to match the official Tailwind VS Code extension's `suggestCanonicalClasses` behavior. **Off by default** because the replacement may change observable CSS in those setups. (When the theme exposes the variable directly with no wrapping function, `border-[var(--border)]` is CSS-equivalent to `border-border` and is owned by `no-unnecessary-arbitrary-value` instead.)
|
|
819
819
|
|
|
820
820
|
```tsx
|
|
821
821
|
// ❌ Bad → ✅ Fixed (when border-border is a valid utility)
|
|
@@ -843,11 +843,21 @@ The class parser correctly handles:
|
|
|
843
843
|
## Known limitations
|
|
844
844
|
|
|
845
845
|
- **`enforce-canonical`**: Named classes are canonicalized via the precomputed map (covers everything in `getClassList()` plus a curated list of legacy v3 spellings like `break-words`, `flex-grow`, `start-N`, `bg-gradient-to-*`). Arbitrary/CSS-var forms (`p-[2px]`, `bg-(--c)`) are canonicalized dynamically via the worker. Some valid v4 classes that don't appear in `getClassList()` and have no canonical rewrite (e.g. `border-1` is valid as a dynamic numeric value but isn't enumerated) are left untouched.
|
|
846
|
-
- **`no-conflicting-classes`**: Uses exact CSS property name matching. Shorthand vs longhand
|
|
846
|
+
- **`no-conflicting-classes`**: Uses exact CSS property name matching plus composition heuristics: CSS-var composition (`shadow` + `ring`), narrowing-override (later class is a strict subset of earlier — handles `size-4 h-6`, `rounded-t-lg rounded-tl-sm`, `truncate text-clip`), complementary groups (gradient stops, transition family, transform axes, mask gradient family across edges/axes/`linear`/`radial`/`conic`), and composition pairs (e.g. `mask-add` + any mask gradient). Shorthand vs longhand cases where Tailwind emits the shorthand and Tailwind's longhand has a different CSS property name (e.g., `p-4` vs `px-2`: `padding` vs `padding-left`/`padding-right`) are still not detected.
|
|
847
847
|
- **`no-dark-without-light`**: Groups by utility prefix heuristic. May not perfectly match all multi-part utility prefixes.
|
|
848
848
|
- **`no-unnecessary-arbitrary-value`**: Only detects equivalences for classes with a single CSS property. Multi-property utilities may have arbitrary forms that aren't detected.
|
|
849
849
|
- **Component classes**: Only first-level `@import` relative paths are followed. Deeply nested imports or absolute paths are not resolved.
|
|
850
850
|
|
|
851
|
+
## Supported plugins
|
|
852
|
+
|
|
853
|
+
The plugin loads classes through `@tailwindcss/node`, so any plugin imported into your CSS entry point — `@plugin '...'` or `@import '...'` — is recognized automatically by every rule. The following are exercised by the test suite:
|
|
854
|
+
|
|
855
|
+
- **[`@tailwindcss/typography`](https://github.com/tailwindlabs/tailwindcss-typography)** — `prose`, `prose-sm/lg/xl`, `not-prose`. `no-conflicting-classes` extracts only root-level CSS properties from `prose`, so utilities like `prose overflow-x-auto` aren't reported as conflicts.
|
|
856
|
+
- **[`tailwindcss-animate`](https://github.com/jamiebuilds/tailwindcss-animate)** — `animate-in`, `animate-out`, `fade-{in,out}-*`, `zoom-{in,out}-*`, `spin-{in,out}-*`, `slide-{in-from,out-to}-*`, `duration-*`, `delay-*`, `ease-*`, `direction-*`, `fill-mode-*`, `repeat-*`, `running`, `paused`. `animate-in`/`animate-out` initialize all `--tw-enter-*` / `--tw-exit-*` custom properties to `initial`, and modifiers (`fade-in`, `zoom-in`, `slide-in-from-*`, etc.) each override one of them; this composition is recognized by `no-conflicting-classes`.
|
|
857
|
+
- **[`tw-animate-css`](https://github.com/Wombosvideo/tw-animate-css)** — v4-native rewrite of `tailwindcss-animate`. Adds `blur-{in,out}-*`, logical (RTL-aware) `slide-{in-from,out-to}-{start,end}-*`, `play-state-*`, `animation-duration-*`, and the `animate-accordion-{up,down}` / `animate-collapsible-{up,down}` / `animate-caret-blink` keyframe animations used by Radix-style headless component libraries.
|
|
858
|
+
|
|
859
|
+
Other plugins that emit classes through standard `getClassList()` and CSS output should work out of the box. If you find one that doesn't, open an issue.
|
|
860
|
+
|
|
851
861
|
## Requirements
|
|
852
862
|
|
|
853
863
|
- Node.js >= 20
|
package/dist/index.cjs
CHANGED
|
@@ -656,7 +656,7 @@ function getArbitraryValue(cls) {
|
|
|
656
656
|
//#endregion
|
|
657
657
|
//#region src/design-system/cache.ts
|
|
658
658
|
/** Strip `!` modifier from start or end: `!flex` → `flex`, `flex!` → `flex` */
|
|
659
|
-
function stripImportant(cls) {
|
|
659
|
+
function stripImportant$1(cls) {
|
|
660
660
|
if (cls.startsWith("!")) return {
|
|
661
661
|
bare: cls.slice(1),
|
|
662
662
|
important: true
|
|
@@ -710,7 +710,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
710
710
|
const canonicalUtility = this.canonicalMap.get(utility);
|
|
711
711
|
if (canonicalUtility !== void 0) return className.slice(0, className.length - utility.length) + canonicalUtility;
|
|
712
712
|
}
|
|
713
|
-
const { bare, important } = stripImportant(utility);
|
|
713
|
+
const { bare, important } = stripImportant$1(utility);
|
|
714
714
|
if (important) {
|
|
715
715
|
const canonicalBare = this.canonicalMap.get(bare);
|
|
716
716
|
if (canonicalBare !== void 0) {
|
|
@@ -768,7 +768,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
768
768
|
if (this.validitySet.has(className)) return true;
|
|
769
769
|
const utility = extractUtility(className);
|
|
770
770
|
if (utility !== className && this.validitySet.has(utility)) return true;
|
|
771
|
-
const { bare } = stripImportant(utility);
|
|
771
|
+
const { bare } = stripImportant$1(utility);
|
|
772
772
|
if (bare !== utility && this.validitySet.has(bare)) return true;
|
|
773
773
|
const slashIdx = bare.lastIndexOf("/");
|
|
774
774
|
if (slashIdx > 0) {
|
|
@@ -792,7 +792,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
792
792
|
const hasVariant = utility !== className;
|
|
793
793
|
let baseOrder = this.orderMap.get(utility) ?? void 0;
|
|
794
794
|
if (baseOrder === void 0) {
|
|
795
|
-
const { bare, important } = stripImportant(utility);
|
|
795
|
+
const { bare, important } = stripImportant$1(utility);
|
|
796
796
|
if (important) baseOrder = this.orderMap.get(bare) ?? void 0;
|
|
797
797
|
}
|
|
798
798
|
if (baseOrder === void 0) {
|
|
@@ -801,13 +801,13 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
801
801
|
const base = utility.slice(0, slashIdx);
|
|
802
802
|
baseOrder = this.orderMap.get(base) ?? void 0;
|
|
803
803
|
if (baseOrder === void 0) {
|
|
804
|
-
const { bare, important } = stripImportant(base);
|
|
804
|
+
const { bare, important } = stripImportant$1(base);
|
|
805
805
|
if (important) baseOrder = this.orderMap.get(bare) ?? void 0;
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
809
|
if (baseOrder === void 0) {
|
|
810
|
-
const stripped = stripImportant(utility).bare;
|
|
810
|
+
const stripped = stripImportant$1(utility).bare;
|
|
811
811
|
const bracketIdx = stripped.indexOf("[");
|
|
812
812
|
if (bracketIdx > 0) {
|
|
813
813
|
const prefix = stripped.slice(0, bracketIdx);
|
|
@@ -815,7 +815,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
817
|
if (baseOrder === void 0) {
|
|
818
|
-
const stripped = stripImportant(utility).bare;
|
|
818
|
+
const stripped = stripImportant$1(utility).bare;
|
|
819
819
|
const parenIdx = stripped.indexOf("(");
|
|
820
820
|
if (parenIdx > 0) {
|
|
821
821
|
const prefix = stripped.slice(0, parenIdx);
|
|
@@ -823,7 +823,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
825
|
if (baseOrder === void 0) {
|
|
826
|
-
const stripped = stripImportant(utility).bare;
|
|
826
|
+
const stripped = stripImportant$1(utility).bare;
|
|
827
827
|
const numericMatch = /^(.+)-(\d+\.?\d*)$/.exec(stripped);
|
|
828
828
|
if (numericMatch && this.getKnownPrefixes().has(numericMatch[1])) baseOrder = this.findOrderByPrefix(numericMatch[1] + "-");
|
|
829
829
|
}
|
|
@@ -842,7 +842,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
842
842
|
getCssProperties(className) {
|
|
843
843
|
const result = this.cssPropsMap.get(className);
|
|
844
844
|
if (result) return result;
|
|
845
|
-
const { bare, important } = stripImportant(className);
|
|
845
|
+
const { bare, important } = stripImportant$1(className);
|
|
846
846
|
if (important) return this.cssPropsMap.get(bare) ?? [];
|
|
847
847
|
return [];
|
|
848
848
|
}
|
|
@@ -855,7 +855,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
855
855
|
getNamedEquivalent(className) {
|
|
856
856
|
const result = this.arbitraryEquivMap.get(className);
|
|
857
857
|
if (result) return result;
|
|
858
|
-
const { bare, important } = stripImportant(className);
|
|
858
|
+
const { bare, important } = stripImportant$1(className);
|
|
859
859
|
if (important) return this.arbitraryEquivMap.get(bare) ?? null;
|
|
860
860
|
return null;
|
|
861
861
|
}
|
|
@@ -1193,7 +1193,12 @@ async function main() {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
}
|
|
1195
1195
|
|
|
1196
|
-
// Arbitrary equivalents: map arbitrary forms to named equivalents
|
|
1196
|
+
// Arbitrary equivalents: map arbitrary forms to named equivalents.
|
|
1197
|
+
// Enumerate every dash split point so multi-segment utilities (e.g.
|
|
1198
|
+
// bg-card-foreground) emit candidates for every prefix; lastIndexOf
|
|
1199
|
+
// alone drops the shorter prefix and misses multi-segment mappings.
|
|
1200
|
+
// Start at indexOf('-', 1) so negative utilities (e.g. -translate-x-1)
|
|
1201
|
+
// keep their leading '-' in every prefix instead of producing '' + '-[…]'.
|
|
1197
1202
|
const arbitraryEquivalents = {};
|
|
1198
1203
|
const candidates = [];
|
|
1199
1204
|
for (const cls of validClasses) {
|
|
@@ -1205,10 +1210,10 @@ async function main() {
|
|
|
1205
1210
|
const pvMatch = cssText.match(/^\\s+([\\w-]+)\\s*:\\s*(.+?)\\s*;?\\s*$/m);
|
|
1206
1211
|
if (!pvMatch) continue;
|
|
1207
1212
|
const value = pvMatch[2].trim().replace(/;$/, '');
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1213
|
+
for (let dashPos = cls.indexOf('-', 1); dashPos > 0; dashPos = cls.indexOf('-', dashPos + 1)) {
|
|
1214
|
+
const prefix = cls.slice(0, dashPos);
|
|
1215
|
+
candidates.push({ arbitraryForm: prefix + '-[' + value + ']', namedCls: cls, namedCss: cssText });
|
|
1216
|
+
}
|
|
1212
1217
|
}
|
|
1213
1218
|
function extractDeclarations(css) {
|
|
1214
1219
|
const openBrace = css.indexOf('{');
|
|
@@ -1232,7 +1237,37 @@ async function main() {
|
|
|
1232
1237
|
main().catch(e => { process.stderr.write(e.message); process.exit(1); });
|
|
1233
1238
|
`;
|
|
1234
1239
|
const CACHE_DIR = (0, node_path.join)((0, node_os.tmpdir)(), "oxlint-tailwindcss");
|
|
1235
|
-
|
|
1240
|
+
/**
|
|
1241
|
+
* Cache key derived from:
|
|
1242
|
+
* - md5(PRECOMPUTE_SCRIPT): auto-invalidates when our precompute logic changes,
|
|
1243
|
+
* since the shape and content of the cached JSON is fully determined by what
|
|
1244
|
+
* this script prints to stdout.
|
|
1245
|
+
* - @tailwindcss/node version: auto-invalidates when the consumer upgrades
|
|
1246
|
+
* tailwindcss (e.g. 4.2 → 4.3 adding `zoom-*`, `tab-*`, `scrollbar-*` etc.),
|
|
1247
|
+
* so `validClasses`, `cssProps`, `canonical`, and `arbitraryEquivalents`
|
|
1248
|
+
* reflect the installed version. @tailwindcss/node and tailwindcss are
|
|
1249
|
+
* published together, so their versions match.
|
|
1250
|
+
*/
|
|
1251
|
+
function computeCacheKey(scriptContent, tailwindVersion) {
|
|
1252
|
+
return `${(0, node_crypto.createHash)("md5").update(scriptContent).digest("hex").slice(0, 8)}:${tailwindVersion}`;
|
|
1253
|
+
}
|
|
1254
|
+
function readTailwindVersion() {
|
|
1255
|
+
try {
|
|
1256
|
+
let dir = (0, node_path.dirname)(require.resolve("@tailwindcss/node"));
|
|
1257
|
+
while (true) {
|
|
1258
|
+
const candidate = (0, node_path.join)(dir, "package.json");
|
|
1259
|
+
if ((0, node_fs.existsSync)(candidate)) {
|
|
1260
|
+
const pkg = JSON.parse((0, node_fs.readFileSync)(candidate, "utf-8"));
|
|
1261
|
+
if (pkg.name === "@tailwindcss/node" && pkg.version) return pkg.version;
|
|
1262
|
+
}
|
|
1263
|
+
const parent = (0, node_path.dirname)(dir);
|
|
1264
|
+
if (parent === dir) break;
|
|
1265
|
+
dir = parent;
|
|
1266
|
+
}
|
|
1267
|
+
} catch {}
|
|
1268
|
+
return "unknown";
|
|
1269
|
+
}
|
|
1270
|
+
const CACHE_KEY = computeCacheKey(PRECOMPUTE_SCRIPT, readTailwindVersion());
|
|
1236
1271
|
/**
|
|
1237
1272
|
* Two-level disk cache for monorepo deduplication:
|
|
1238
1273
|
*
|
|
@@ -1243,10 +1278,10 @@ const CACHE_VERSION = 13;
|
|
|
1243
1278
|
* paths share a single content cache entry, avoiding redundant child process spawns.
|
|
1244
1279
|
*/
|
|
1245
1280
|
function getMtimeIndexPath(cssPath, mtime) {
|
|
1246
|
-
return (0, node_path.join)(CACHE_DIR, `${(0, node_crypto.createHash)("md5").update(
|
|
1281
|
+
return (0, node_path.join)(CACHE_DIR, `${(0, node_crypto.createHash)("md5").update(`${CACHE_KEY}:${cssPath}:${mtime}`).digest("hex")}.idx`);
|
|
1247
1282
|
}
|
|
1248
1283
|
function computeContentHash(content) {
|
|
1249
|
-
return (0, node_crypto.createHash)("md5").update(
|
|
1284
|
+
return (0, node_crypto.createHash)("md5").update(`${CACHE_KEY}:${content}`).digest("hex");
|
|
1250
1285
|
}
|
|
1251
1286
|
function getContentCachePath(contentHash) {
|
|
1252
1287
|
return (0, node_path.join)(CACHE_DIR, `${contentHash}.json`);
|
|
@@ -1503,6 +1538,38 @@ function cachedAutoDetect(filePath) {
|
|
|
1503
1538
|
return result;
|
|
1504
1539
|
}
|
|
1505
1540
|
/**
|
|
1541
|
+
* Pure resolution of which CSS entry point to use for a given context.
|
|
1542
|
+
*
|
|
1543
|
+
* Resolution order: rule option `entryPoint` > `settingsEntry` (string or
|
|
1544
|
+
* closest-of-array) > `autoDetect(filePath)` > `lastPath` fallback.
|
|
1545
|
+
*
|
|
1546
|
+
* Returns `isExplicit: true` when the result came from a rule option or
|
|
1547
|
+
* settings (not auto-detect / lastPath) — the caller uses this to decide
|
|
1548
|
+
* whether to update the shared `lastLoadedPath` fallback. Auto-detect
|
|
1549
|
+
* results never update the fallback (prevents cross-package contamination
|
|
1550
|
+
* in monorepos).
|
|
1551
|
+
*
|
|
1552
|
+
* `autoDetect` is injected for testability; in production it's
|
|
1553
|
+
* `cachedAutoDetect`. Pure: does not touch module state.
|
|
1554
|
+
*/
|
|
1555
|
+
function resolveCssPath(args) {
|
|
1556
|
+
const { entryPoint, settingsEntry, filePath, lastPath, autoDetect } = args;
|
|
1557
|
+
const explicit = entryPoint ?? (Array.isArray(settingsEntry) ? resolveClosestEntryPoint(settingsEntry, filePath) : settingsEntry);
|
|
1558
|
+
if (explicit) return {
|
|
1559
|
+
path: explicit,
|
|
1560
|
+
isExplicit: true
|
|
1561
|
+
};
|
|
1562
|
+
const detected = autoDetect(filePath);
|
|
1563
|
+
if (detected) return {
|
|
1564
|
+
path: detected,
|
|
1565
|
+
isExplicit: false
|
|
1566
|
+
};
|
|
1567
|
+
return {
|
|
1568
|
+
path: lastPath ?? null,
|
|
1569
|
+
isExplicit: false
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
/**
|
|
1506
1573
|
* Returns the design system cache, loading synchronously on first call.
|
|
1507
1574
|
* Uses execFileSync internally to bridge the async Tailwind API.
|
|
1508
1575
|
*
|
|
@@ -1513,16 +1580,20 @@ function cachedAutoDetect(filePath) {
|
|
|
1513
1580
|
* Resolution order: rule option `entryPoint` > `settings.tailwindcss.entryPoint` > auto-detect.
|
|
1514
1581
|
*/
|
|
1515
1582
|
function getLoadedDesignSystem(entryPoint, settings, filePath) {
|
|
1516
|
-
const
|
|
1517
|
-
|
|
1518
|
-
|
|
1583
|
+
const { path: cssPath, isExplicit } = resolveCssPath({
|
|
1584
|
+
entryPoint,
|
|
1585
|
+
settingsEntry: entryPointFromSettings(settings),
|
|
1586
|
+
filePath,
|
|
1587
|
+
lastPath: lastLoadedPath,
|
|
1588
|
+
autoDetect: cachedAutoDetect
|
|
1589
|
+
});
|
|
1519
1590
|
if (!cssPath) return null;
|
|
1520
1591
|
const resolvedPath = (0, node_path.resolve)(cssPath);
|
|
1521
1592
|
try {
|
|
1522
1593
|
const mtime = (0, node_fs.statSync)(resolvedPath).mtimeMs;
|
|
1523
1594
|
const cached = dsCache.get(resolvedPath);
|
|
1524
1595
|
if (cached && cached.mtime === mtime) {
|
|
1525
|
-
if (
|
|
1596
|
+
if (isExplicit) lastLoadedPath = resolvedPath;
|
|
1526
1597
|
return {
|
|
1527
1598
|
cache: cached.cache,
|
|
1528
1599
|
entryPoint: resolvedPath
|
|
@@ -1536,7 +1607,7 @@ function getLoadedDesignSystem(entryPoint, settings, filePath) {
|
|
|
1536
1607
|
mtime
|
|
1537
1608
|
});
|
|
1538
1609
|
debugLog(`Loaded design system from "${resolvedPath}"`);
|
|
1539
|
-
if (
|
|
1610
|
+
if (isExplicit) lastLoadedPath = resolvedPath;
|
|
1540
1611
|
return {
|
|
1541
1612
|
cache,
|
|
1542
1613
|
entryPoint: resolvedPath
|
|
@@ -1837,6 +1908,74 @@ const noUnknownClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1837
1908
|
});
|
|
1838
1909
|
//#endregion
|
|
1839
1910
|
//#region src/rules/no-conflicting-classes.ts
|
|
1911
|
+
const COMPLEMENTARY_GROUPS = [
|
|
1912
|
+
/^(from|via|to)-/,
|
|
1913
|
+
/^(transition|duration|ease|delay)(?:-|$)/,
|
|
1914
|
+
/^-?(translate|scale|rotate|skew)-/,
|
|
1915
|
+
/^-?mask-((?:linear|radial|conic|[trblxy])(?:-(?:from|via|to|at))?)(?:-|$)/,
|
|
1916
|
+
/^prose(?:-|$)/
|
|
1917
|
+
];
|
|
1918
|
+
const COMPOSITION_PAIRS = [
|
|
1919
|
+
[/^text-/, /^leading-/],
|
|
1920
|
+
[/^text-/, /^tracking-/],
|
|
1921
|
+
[/^border(?:-[0-9]|$)/, /^border-(?:solid|dashed|dotted|double|hidden|none)$/],
|
|
1922
|
+
[/^divide-/, /^border(?:-[trblxyse])?-/],
|
|
1923
|
+
[/^prose(?:-|$)/, /^max-w-/],
|
|
1924
|
+
[/^animate-in$/, /^(?:fade|spin|zoom|blur)-in(?:-|$)|^slide-in-from-/],
|
|
1925
|
+
[/^animate-out$/, /^(?:fade|spin|zoom|blur)-out(?:-|$)|^slide-out-to-/],
|
|
1926
|
+
[/^mask-(?:add|subtract|intersect|exclude)$/, /^-?mask-(?:linear|radial|conic|[trblxy])-/]
|
|
1927
|
+
];
|
|
1928
|
+
function stripImportant(utility) {
|
|
1929
|
+
if (utility.startsWith("!")) return utility.slice(1);
|
|
1930
|
+
if (utility.endsWith("!")) return utility.slice(0, -1);
|
|
1931
|
+
return utility;
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Two utilities compose via CSS custom properties if both define their own
|
|
1935
|
+
* --tw-* properties that don't overlap — they each contribute to a shared
|
|
1936
|
+
* shorthand (e.g. `shadow` and `ring` both end up in `box-shadow` via
|
|
1937
|
+
* different intermediate vars).
|
|
1938
|
+
*/
|
|
1939
|
+
function isCompositionViaCssVars(propsA, propsB) {
|
|
1940
|
+
const customA = propsA.filter((p) => p.startsWith("--"));
|
|
1941
|
+
const customB = propsB.filter((p) => p.startsWith("--"));
|
|
1942
|
+
if (customA.length === 0 || customB.length === 0) return false;
|
|
1943
|
+
return !customA.some((p) => customB.includes(p));
|
|
1944
|
+
}
|
|
1945
|
+
/**
|
|
1946
|
+
* Detect a narrowing override: the later class's CSS properties are a strict
|
|
1947
|
+
* subset of the earlier class's, so the later class refines one of the
|
|
1948
|
+
* shorthand's properties (size-4 h-6, rounded-t-lg rounded-tl-sm, truncate
|
|
1949
|
+
* text-clip). Direction-sensitive: the inverse means the wider later class
|
|
1950
|
+
* clobbers a prior narrower override.
|
|
1951
|
+
*/
|
|
1952
|
+
function isNarrowingOverride(propsEarlier, propsLater) {
|
|
1953
|
+
if (propsLater.length === 0 || propsLater.length >= propsEarlier.length) return false;
|
|
1954
|
+
const setEarlier = new Set(propsEarlier);
|
|
1955
|
+
return propsLater.every((p) => setEarlier.has(p));
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Returns true if two classes (within the same variant) should NOT be reported
|
|
1959
|
+
* as conflicting despite sharing CSS properties. Pure: regex tables are passed
|
|
1960
|
+
* in (or default to the module-level constants).
|
|
1961
|
+
*/
|
|
1962
|
+
function shouldSkipPair(a, b, propsA, propsB, rules = {}) {
|
|
1963
|
+
if (isCompositionViaCssVars(propsA, propsB)) return true;
|
|
1964
|
+
if (isNarrowingOverride(propsA, propsB)) return true;
|
|
1965
|
+
const ua = stripImportant(extractUtility(a));
|
|
1966
|
+
const ub = stripImportant(extractUtility(b));
|
|
1967
|
+
const groups = rules.complementaryGroups ?? COMPLEMENTARY_GROUPS;
|
|
1968
|
+
for (const re of groups) {
|
|
1969
|
+
const ma = ua.match(re);
|
|
1970
|
+
const mb = ub.match(re);
|
|
1971
|
+
if (!ma || !mb) continue;
|
|
1972
|
+
if (ma[1] === void 0) return true;
|
|
1973
|
+
if (ma[1] !== mb[1]) return true;
|
|
1974
|
+
}
|
|
1975
|
+
const pairs = rules.compositionPairs ?? COMPOSITION_PAIRS;
|
|
1976
|
+
for (const [reA, reB] of pairs) if (reA.test(ua) && reB.test(ub) || reA.test(ub) && reB.test(ua)) return true;
|
|
1977
|
+
return false;
|
|
1978
|
+
}
|
|
1840
1979
|
const noConflictingClasses = (0, _oxlint_plugins.defineRule)({
|
|
1841
1980
|
meta: {
|
|
1842
1981
|
type: "problem",
|
|
@@ -1868,43 +2007,9 @@ const noConflictingClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1868
2007
|
if (variantClasses.length < 2) continue;
|
|
1869
2008
|
const propsMap = /* @__PURE__ */ new Map();
|
|
1870
2009
|
for (const cls of variantClasses) {
|
|
1871
|
-
|
|
1872
|
-
if (utility.startsWith("!")) utility = utility.slice(1);
|
|
1873
|
-
else if (utility.endsWith("!")) utility = utility.slice(0, -1);
|
|
1874
|
-
const props = cache.getCssProperties(utility);
|
|
2010
|
+
const props = cache.getCssProperties(stripImportant(extractUtility(cls)));
|
|
1875
2011
|
propsMap.set(cls, props);
|
|
1876
2012
|
}
|
|
1877
|
-
const COMPLEMENTARY_GROUPS = [
|
|
1878
|
-
/^(?:from|via|to)-/,
|
|
1879
|
-
/^(?:transition|duration|ease|delay)(?:-|$)/,
|
|
1880
|
-
/^-?(?:translate|scale|rotate|skew)-/,
|
|
1881
|
-
/^prose(?:-|$)/
|
|
1882
|
-
];
|
|
1883
|
-
const COMPOSITION_PAIRS = [
|
|
1884
|
-
[/^text-/, /^leading-/],
|
|
1885
|
-
[/^text-/, /^tracking-/],
|
|
1886
|
-
[/^border(?:-[0-9]|$)/, /^border-(?:solid|dashed|dotted|double|hidden|none)$/],
|
|
1887
|
-
[/^divide-/, /^border(?:-[trblxyse])?-/],
|
|
1888
|
-
[/^prose(?:-|$)/, /^max-w-/]
|
|
1889
|
-
];
|
|
1890
|
-
function isCompositionViaCssVars(propsA, propsB) {
|
|
1891
|
-
const customA = propsA.filter((p) => p.startsWith("--"));
|
|
1892
|
-
const customB = propsB.filter((p) => p.startsWith("--"));
|
|
1893
|
-
if (customA.length === 0 || customB.length === 0) return false;
|
|
1894
|
-
return !customA.some((p) => customB.includes(p));
|
|
1895
|
-
}
|
|
1896
|
-
function shouldSkipPair(a, b, propsA, propsB) {
|
|
1897
|
-
if (isCompositionViaCssVars(propsA, propsB)) return true;
|
|
1898
|
-
let ua = extractUtility(a);
|
|
1899
|
-
let ub = extractUtility(b);
|
|
1900
|
-
if (ua.startsWith("!")) ua = ua.slice(1);
|
|
1901
|
-
else if (ua.endsWith("!")) ua = ua.slice(0, -1);
|
|
1902
|
-
if (ub.startsWith("!")) ub = ub.slice(1);
|
|
1903
|
-
else if (ub.endsWith("!")) ub = ub.slice(0, -1);
|
|
1904
|
-
for (const re of COMPLEMENTARY_GROUPS) if (re.test(ua) && re.test(ub)) return true;
|
|
1905
|
-
for (const [reA, reB] of COMPOSITION_PAIRS) if (reA.test(ua) && reB.test(ub) || reA.test(ub) && reB.test(ua)) return true;
|
|
1906
|
-
return false;
|
|
1907
|
-
}
|
|
1908
2013
|
for (let i = 0; i < variantClasses.length; i++) {
|
|
1909
2014
|
const classA = variantClasses[i];
|
|
1910
2015
|
const propsA = propsMap.get(classA) ?? [];
|
|
@@ -3415,8 +3520,10 @@ const LCH_RE = /^lch\s*\(/;
|
|
|
3415
3520
|
const LAB_RE = /^lab\s*\(/;
|
|
3416
3521
|
const HWB_RE = /^hwb\s*\(/;
|
|
3417
3522
|
const COLOR_RE = /^color\s*\(/;
|
|
3523
|
+
const VAR_REF_RE = /var\(\s*--[\w-]+/i;
|
|
3418
3524
|
function isHardcodedColor(value) {
|
|
3419
3525
|
const trimmed = value.trim();
|
|
3526
|
+
if (VAR_REF_RE.test(trimmed)) return false;
|
|
3420
3527
|
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);
|
|
3421
3528
|
}
|
|
3422
3529
|
function isColorUtility(utility) {
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";cAyBM,MAAA,4BAAM,MA2BV;AAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as _$_oxlint_plugins0 from "@oxlint/plugins";
|
|
2
|
-
|
|
3
1
|
//#region src/index.d.ts
|
|
4
|
-
declare const plugin:
|
|
2
|
+
declare const plugin: import("@oxlint/plugins").Plugin;
|
|
5
3
|
//#endregion
|
|
6
4
|
export { plugin as default };
|
|
7
5
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";cAyBM,MAAA,4BAAM,MA2BV"}
|