oxlint-tailwindcss 0.4.0 → 0.5.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 +53 -1
- package/dist/index.cjs +272 -56
- package/dist/index.mjs +406 -194
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ assets/{name}.css assets/css/{name}.css resources/css/{name}.css
|
|
|
76
76
|
|
|
77
77
|
Where `{name}` is one of: `app`, `globals`, `global`, `style`, `styles`, `index`, `main`, `tailwind`, `tailwindcss`.
|
|
78
78
|
|
|
79
|
-
The search is monorepo-aware — it stops at `package.json` boundaries so each package resolves its own Tailwind config. If the signal isn't found directly in the CSS file, the auto-detector follows `@import` statements one level deep — supporting both relative paths and package imports (e.g. `@import '@company/theme/tailwind.config.css'`).
|
|
79
|
+
The search is monorepo-aware — it stops at `package.json` boundaries so each package resolves its own Tailwind config. Packages without a Tailwind CSS file are silently skipped (DS-dependent rules produce no diagnostics). If the signal isn't found directly in the CSS file, the auto-detector follows `@import` statements one level deep — supporting both relative paths and package imports (e.g. `@import '@company/theme/tailwind.config.css'`).
|
|
80
80
|
|
|
81
81
|
If auto-detection doesn't find your CSS file, set `entryPoint` once in `settings`:
|
|
82
82
|
|
|
@@ -97,6 +97,28 @@ If auto-detection doesn't find your CSS file, set `entryPoint` once in `settings
|
|
|
97
97
|
|
|
98
98
|
The design system is loaded once per entry point and shared across all rules. In monorepos, each package resolves its own entry point automatically via `package.json` boundaries.
|
|
99
99
|
|
|
100
|
+
### Multiple entry points (monorepos)
|
|
101
|
+
|
|
102
|
+
For monorepos where auto-detection isn't enough, `entryPoint` accepts an array. The plugin picks the closest entry point for each file based on directory proximity:
|
|
103
|
+
|
|
104
|
+
```jsonc
|
|
105
|
+
{
|
|
106
|
+
"settings": {
|
|
107
|
+
"tailwindcss": {
|
|
108
|
+
"entryPoint": [
|
|
109
|
+
"packages/web/src/globals.css",
|
|
110
|
+
"packages/admin/src/styles.css",
|
|
111
|
+
"packages/marketing/src/tailwind.css",
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For example, `packages/web/src/App.tsx` resolves to `packages/web/src/globals.css` and `packages/admin/src/Dashboard.tsx` resolves to `packages/admin/src/styles.css`.
|
|
119
|
+
|
|
120
|
+
### Per-rule override
|
|
121
|
+
|
|
100
122
|
You can also override per rule if needed:
|
|
101
123
|
|
|
102
124
|
```jsonc
|
|
@@ -109,6 +131,8 @@ You can also override per rule if needed:
|
|
|
109
131
|
|
|
110
132
|
Resolution order: rule option > `settings.tailwindcss.entryPoint` > auto-detect.
|
|
111
133
|
|
|
134
|
+
### Timeout
|
|
135
|
+
|
|
112
136
|
For slow environments (large monorepos, CI), you can increase the design system loading timeout:
|
|
113
137
|
|
|
114
138
|
```jsonc
|
|
@@ -121,6 +145,34 @@ For slow environments (large monorepos, CI), you can increase the design system
|
|
|
121
145
|
}
|
|
122
146
|
```
|
|
123
147
|
|
|
148
|
+
### Debug logging
|
|
149
|
+
|
|
150
|
+
To see which design system is used for each file, enable debug mode:
|
|
151
|
+
|
|
152
|
+
```jsonc
|
|
153
|
+
{
|
|
154
|
+
"settings": {
|
|
155
|
+
"tailwindcss": {
|
|
156
|
+
"debug": true,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Or use the environment variable (no config changes needed):
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
DEBUG=oxlint-tailwindcss oxlint .
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Output:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
[oxlint-tailwindcss] Loaded design system from "packages/web/src/globals.css"
|
|
172
|
+
[oxlint-tailwindcss] packages/web/src/App.tsx → packages/web/src/globals.css
|
|
173
|
+
[oxlint-tailwindcss] packages/admin/src/Dashboard.tsx → packages/admin/src/styles.css
|
|
174
|
+
```
|
|
175
|
+
|
|
124
176
|
If no entry point is found (neither configured nor auto-detected), rules that require the design system (`no-unknown-classes`, `no-conflicting-classes`, `no-deprecated-classes`, `enforce-canonical`, `enforce-sort-order`, `no-unnecessary-arbitrary-value`, `consistent-variant-order`) are silently disabled. All other rules work without it.
|
|
125
177
|
|
|
126
178
|
## Custom class detection
|
package/dist/index.cjs
CHANGED
|
@@ -173,6 +173,10 @@ function extractFromClassedCall(node) {
|
|
|
173
173
|
skippedFirst = true;
|
|
174
174
|
continue;
|
|
175
175
|
}
|
|
176
|
+
if (!skippedFirst && arg.type === "TemplateLiteral") {
|
|
177
|
+
skippedFirst = true;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
176
180
|
skippedFirst = true;
|
|
177
181
|
if (arg.type === "ObjectExpression") results.push(...extractFromCvaConfig(arg));
|
|
178
182
|
else results.push(...extractFromExpression(arg));
|
|
@@ -1257,42 +1261,83 @@ function autoDetectEntryPoint(filePath) {
|
|
|
1257
1261
|
continue;
|
|
1258
1262
|
}
|
|
1259
1263
|
}
|
|
1264
|
+
if ((0, node_fs.existsSync)((0, node_path.join)(currentDir, "package.json"))) break;
|
|
1260
1265
|
const parentDir = (0, node_path.dirname)(currentDir);
|
|
1261
1266
|
if (parentDir === currentDir) break;
|
|
1262
|
-
if (depth > 0 && (0, node_fs.existsSync)((0, node_path.join)(parentDir, "package.json"))) {
|
|
1263
|
-
for (const candidate of CANDIDATE_PATHS) {
|
|
1264
|
-
const fullPath = (0, node_path.join)(parentDir, candidate);
|
|
1265
|
-
if (!(0, node_fs.existsSync)(fullPath)) continue;
|
|
1266
|
-
try {
|
|
1267
|
-
const content = (0, node_fs.readFileSync)(fullPath, "utf-8");
|
|
1268
|
-
if (TAILWIND_SIGNALS.some((signal) => content.includes(signal))) return fullPath;
|
|
1269
|
-
if (hasTailwindSignalInImports(content, (0, node_path.dirname)(fullPath), TAILWIND_SIGNALS)) return fullPath;
|
|
1270
|
-
} catch {
|
|
1271
|
-
continue;
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
break;
|
|
1275
|
-
}
|
|
1276
1267
|
currentDir = parentDir;
|
|
1277
1268
|
}
|
|
1278
1269
|
return null;
|
|
1279
1270
|
}
|
|
1280
1271
|
//#endregion
|
|
1272
|
+
//#region src/design-system/debug.ts
|
|
1273
|
+
const PREFIX = "[oxlint-tailwindcss]";
|
|
1274
|
+
let _enabled = null;
|
|
1275
|
+
/**
|
|
1276
|
+
* Check if debug logging is enabled.
|
|
1277
|
+
* Activated by `settings.tailwindcss.debug: true` or `DEBUG=oxlint-tailwindcss` env var.
|
|
1278
|
+
*/
|
|
1279
|
+
function isDebugEnabled(settings) {
|
|
1280
|
+
if (process.env.DEBUG === "oxlint-tailwindcss") return true;
|
|
1281
|
+
if (settings !== void 0) {
|
|
1282
|
+
const tw = settings?.tailwindcss;
|
|
1283
|
+
if (tw && typeof tw === "object" && "debug" in tw) return tw.debug === true;
|
|
1284
|
+
}
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Enable debug mode (called once when settings become available).
|
|
1289
|
+
*/
|
|
1290
|
+
function setDebugEnabled(enabled) {
|
|
1291
|
+
_enabled = enabled;
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Log a debug message if debug mode is active.
|
|
1295
|
+
*/
|
|
1296
|
+
function debugLog(message) {
|
|
1297
|
+
if (_enabled || process.env.DEBUG === "oxlint-tailwindcss") console.error(`${PREFIX} ${message}`);
|
|
1298
|
+
}
|
|
1299
|
+
//#endregion
|
|
1281
1300
|
//#region src/design-system/loader.ts
|
|
1282
1301
|
const dsCache = /* @__PURE__ */ new Map();
|
|
1283
1302
|
const autoDetectCache = /* @__PURE__ */ new Map();
|
|
1284
1303
|
let lastLoadedPath = null;
|
|
1285
1304
|
/**
|
|
1286
1305
|
* Extracts `entryPoint` from `context.settings.tailwindcss`.
|
|
1306
|
+
* Supports both `string` and `string[]` (for monorepos).
|
|
1287
1307
|
*/
|
|
1288
1308
|
function entryPointFromSettings(settings) {
|
|
1289
1309
|
const tw = settings?.tailwindcss;
|
|
1290
1310
|
if (tw && typeof tw === "object" && "entryPoint" in tw) {
|
|
1291
1311
|
const ep = tw.entryPoint;
|
|
1292
1312
|
if (typeof ep === "string") return ep;
|
|
1313
|
+
if (Array.isArray(ep) && ep.length > 0 && ep.every((e) => typeof e === "string")) return ep;
|
|
1293
1314
|
}
|
|
1294
1315
|
}
|
|
1295
1316
|
/**
|
|
1317
|
+
* Given an array of entry points and a file path, pick the one that shares
|
|
1318
|
+
* the longest common directory prefix with the file. Falls back to first entry.
|
|
1319
|
+
*/
|
|
1320
|
+
function resolveClosestEntryPoint(entryPoints, filePath) {
|
|
1321
|
+
if (entryPoints.length === 1 || !filePath) return entryPoints[0];
|
|
1322
|
+
const fileDir = (0, node_path.dirname)((0, node_path.resolve)(filePath));
|
|
1323
|
+
let best = entryPoints[0];
|
|
1324
|
+
let bestLen = 0;
|
|
1325
|
+
for (const ep of entryPoints) {
|
|
1326
|
+
const len = commonPrefixLength(fileDir, (0, node_path.dirname)((0, node_path.resolve)(ep)));
|
|
1327
|
+
if (len > bestLen) {
|
|
1328
|
+
bestLen = len;
|
|
1329
|
+
best = ep;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
return best;
|
|
1333
|
+
}
|
|
1334
|
+
function commonPrefixLength(a, b) {
|
|
1335
|
+
const len = Math.min(a.length, b.length);
|
|
1336
|
+
let i = 0;
|
|
1337
|
+
while (i < len && a[i] === b[i]) i++;
|
|
1338
|
+
return i;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1296
1341
|
* Extracts `timeout` from `context.settings.tailwindcss`.
|
|
1297
1342
|
*/
|
|
1298
1343
|
function timeoutFromSettings(settings) {
|
|
@@ -1326,16 +1371,21 @@ function cachedAutoDetect(filePath) {
|
|
|
1326
1371
|
* Resolution order: rule option `entryPoint` > `settings.tailwindcss.entryPoint` > auto-detect.
|
|
1327
1372
|
*/
|
|
1328
1373
|
function getLoadedDesignSystem(entryPoint, settings, filePath) {
|
|
1329
|
-
const
|
|
1374
|
+
const settingsEntry = entryPointFromSettings(settings);
|
|
1375
|
+
const explicitEntry = entryPoint ?? (Array.isArray(settingsEntry) ? resolveClosestEntryPoint(settingsEntry, filePath) : settingsEntry);
|
|
1376
|
+
const cssPath = explicitEntry ?? cachedAutoDetect(filePath) ?? lastLoadedPath;
|
|
1330
1377
|
if (!cssPath) return null;
|
|
1331
1378
|
const resolvedPath = (0, node_path.resolve)(cssPath);
|
|
1332
1379
|
try {
|
|
1333
1380
|
const mtime = (0, node_fs.statSync)(resolvedPath).mtimeMs;
|
|
1334
1381
|
const cached = dsCache.get(resolvedPath);
|
|
1335
|
-
if (cached && cached.mtime === mtime)
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1382
|
+
if (cached && cached.mtime === mtime) {
|
|
1383
|
+
if (explicitEntry) lastLoadedPath = resolvedPath;
|
|
1384
|
+
return {
|
|
1385
|
+
cache: cached.cache,
|
|
1386
|
+
entryPoint: resolvedPath
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1339
1389
|
const data = loadDesignSystemSync(resolvedPath, timeoutFromSettings(settings));
|
|
1340
1390
|
if (!data) return null;
|
|
1341
1391
|
const cache = DesignSystemCache.fromPrecomputed(data);
|
|
@@ -1343,7 +1393,8 @@ function getLoadedDesignSystem(entryPoint, settings, filePath) {
|
|
|
1343
1393
|
cache,
|
|
1344
1394
|
mtime
|
|
1345
1395
|
});
|
|
1346
|
-
|
|
1396
|
+
debugLog(`Loaded design system from "${resolvedPath}"`);
|
|
1397
|
+
if (explicitEntry) lastLoadedPath = resolvedPath;
|
|
1347
1398
|
return {
|
|
1348
1399
|
cache,
|
|
1349
1400
|
entryPoint: resolvedPath
|
|
@@ -1367,6 +1418,7 @@ function createLazyLoader(context) {
|
|
|
1367
1418
|
let lastResult = null;
|
|
1368
1419
|
let fixedEntryResolved = false;
|
|
1369
1420
|
let fixedResult = null;
|
|
1421
|
+
let debugInitialized = false;
|
|
1370
1422
|
return () => {
|
|
1371
1423
|
let entryPoint;
|
|
1372
1424
|
try {
|
|
@@ -1380,16 +1432,31 @@ function createLazyLoader(context) {
|
|
|
1380
1432
|
try {
|
|
1381
1433
|
filePath = context.filename;
|
|
1382
1434
|
} catch {}
|
|
1383
|
-
|
|
1435
|
+
if (!debugInitialized && settings) {
|
|
1436
|
+
debugInitialized = true;
|
|
1437
|
+
setDebugEnabled(isDebugEnabled(settings));
|
|
1438
|
+
}
|
|
1439
|
+
const settingsEntry = entryPointFromSettings(settings);
|
|
1440
|
+
const fixedEntry = entryPoint ?? (typeof settingsEntry === "string" ? settingsEntry : void 0);
|
|
1384
1441
|
if (fixedEntry) {
|
|
1385
1442
|
if (fixedEntryResolved) return fixedResult;
|
|
1386
1443
|
fixedEntryResolved = true;
|
|
1387
1444
|
fixedResult = getLoadedDesignSystem(fixedEntry, settings, filePath);
|
|
1445
|
+
if (fixedResult && filePath) debugLog(`${(0, node_path.relative)(process.cwd(), filePath)} → ${(0, node_path.relative)(process.cwd(), fixedResult.entryPoint)}`);
|
|
1388
1446
|
return fixedResult;
|
|
1389
1447
|
}
|
|
1448
|
+
if (Array.isArray(settingsEntry)) {
|
|
1449
|
+
const closest = resolveClosestEntryPoint(settingsEntry, filePath);
|
|
1450
|
+
if (filePath && filePath === lastFilePath) return lastResult;
|
|
1451
|
+
if (filePath) lastFilePath = filePath;
|
|
1452
|
+
lastResult = getLoadedDesignSystem(closest, settings, filePath);
|
|
1453
|
+
if (lastResult && filePath) debugLog(`${(0, node_path.relative)(process.cwd(), filePath)} → ${(0, node_path.relative)(process.cwd(), lastResult.entryPoint)}`);
|
|
1454
|
+
return lastResult;
|
|
1455
|
+
}
|
|
1390
1456
|
if (filePath && filePath === lastFilePath) return lastResult;
|
|
1391
1457
|
if (filePath) lastFilePath = filePath;
|
|
1392
1458
|
lastResult = getLoadedDesignSystem(void 0, settings, filePath);
|
|
1459
|
+
if (lastResult && filePath) debugLog(`${(0, node_path.relative)(process.cwd(), filePath)} → ${(0, node_path.relative)(process.cwd(), lastResult.entryPoint)}`);
|
|
1393
1460
|
return lastResult;
|
|
1394
1461
|
};
|
|
1395
1462
|
}
|
|
@@ -1440,7 +1507,11 @@ const noDeprecatedClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1440
1507
|
properties: { entryPoint: { type: "string" } },
|
|
1441
1508
|
additionalProperties: false
|
|
1442
1509
|
}],
|
|
1443
|
-
|
|
1510
|
+
hasSuggestions: true,
|
|
1511
|
+
messages: {
|
|
1512
|
+
deprecated: "\"{{className}}\" is deprecated in Tailwind v4. Use \"{{replacement}}\" instead.",
|
|
1513
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
1514
|
+
}
|
|
1444
1515
|
},
|
|
1445
1516
|
createOnce(context) {
|
|
1446
1517
|
const getDS = createLazyLoader(context);
|
|
@@ -1488,7 +1559,17 @@ const noDeprecatedClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1488
1559
|
data: {
|
|
1489
1560
|
className: cls,
|
|
1490
1561
|
replacement
|
|
1491
|
-
}
|
|
1562
|
+
},
|
|
1563
|
+
suggest: [{
|
|
1564
|
+
messageId: "suggestReplace",
|
|
1565
|
+
data: {
|
|
1566
|
+
className: cls,
|
|
1567
|
+
replacement
|
|
1568
|
+
},
|
|
1569
|
+
fix(fixer) {
|
|
1570
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1571
|
+
}
|
|
1572
|
+
}]
|
|
1492
1573
|
});
|
|
1493
1574
|
}
|
|
1494
1575
|
}
|
|
@@ -1517,9 +1598,15 @@ const noUnknownClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1517
1598
|
},
|
|
1518
1599
|
additionalProperties: false
|
|
1519
1600
|
}],
|
|
1601
|
+
hasSuggestions: true,
|
|
1602
|
+
defaultOptions: [{
|
|
1603
|
+
allowlist: [],
|
|
1604
|
+
ignorePrefixes: []
|
|
1605
|
+
}],
|
|
1520
1606
|
messages: {
|
|
1521
1607
|
unknown: "\"{{className}}\" is not a valid Tailwind class.",
|
|
1522
|
-
unknownWithSuggestion: "\"{{className}}\" is not a valid Tailwind class. Did you mean \"{{suggestion}}\"?"
|
|
1608
|
+
unknownWithSuggestion: "\"{{className}}\" is not a valid Tailwind class. Did you mean \"{{suggestion}}\"?",
|
|
1609
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
1523
1610
|
}
|
|
1524
1611
|
},
|
|
1525
1612
|
createOnce(context) {
|
|
@@ -1560,15 +1647,27 @@ const noUnknownClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1560
1647
|
if (cache.isValid(stripped)) continue;
|
|
1561
1648
|
if (DEPRECATED_MAP[stripped]) continue;
|
|
1562
1649
|
const suggestion = findBestSuggestion(stripped, cache.validClasses);
|
|
1563
|
-
if (suggestion)
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1650
|
+
if (suggestion) {
|
|
1651
|
+
const fixedValue = classes.map((c) => c === cls ? suggestion : c).join(" ");
|
|
1652
|
+
context.report({
|
|
1653
|
+
node: loc.node,
|
|
1654
|
+
messageId: "unknownWithSuggestion",
|
|
1655
|
+
data: {
|
|
1656
|
+
className: cls,
|
|
1657
|
+
suggestion
|
|
1658
|
+
},
|
|
1659
|
+
suggest: [{
|
|
1660
|
+
messageId: "suggestReplace",
|
|
1661
|
+
data: {
|
|
1662
|
+
className: cls,
|
|
1663
|
+
replacement: suggestion
|
|
1664
|
+
},
|
|
1665
|
+
fix(fixer) {
|
|
1666
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1667
|
+
}
|
|
1668
|
+
}]
|
|
1669
|
+
});
|
|
1670
|
+
} else context.report({
|
|
1572
1671
|
node: loc.node,
|
|
1573
1672
|
messageId: "unknown",
|
|
1574
1673
|
data: { className: cls }
|
|
@@ -1626,6 +1725,7 @@ const noConflictingClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1626
1725
|
];
|
|
1627
1726
|
const COMPOSITION_PAIRS = [
|
|
1628
1727
|
[/^text-/, /^leading-/],
|
|
1728
|
+
[/^text-/, /^tracking-/],
|
|
1629
1729
|
[/^border(?:-[0-9]|$)/, /^border-(?:solid|dashed|dotted|double|hidden|none)$/],
|
|
1630
1730
|
[/^divide-/, /^border(?:-[trblxyse])?-/],
|
|
1631
1731
|
[/^prose(?:-|$)/, /^max-w-/]
|
|
@@ -1689,7 +1789,11 @@ const enforceCanonical = (0, _oxlint_plugins.defineRule)({
|
|
|
1689
1789
|
properties: { entryPoint: { type: "string" } },
|
|
1690
1790
|
additionalProperties: false
|
|
1691
1791
|
}],
|
|
1692
|
-
|
|
1792
|
+
hasSuggestions: true,
|
|
1793
|
+
messages: {
|
|
1794
|
+
nonCanonical: "\"{{className}}\" can be written as \"{{canonical}}\". Use the canonical form.",
|
|
1795
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
1796
|
+
}
|
|
1693
1797
|
},
|
|
1694
1798
|
createOnce(context) {
|
|
1695
1799
|
const getDS = createLazyLoader(context);
|
|
@@ -1719,14 +1823,27 @@ const enforceCanonical = (0, _oxlint_plugins.defineRule)({
|
|
|
1719
1823
|
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1720
1824
|
}
|
|
1721
1825
|
});
|
|
1722
|
-
} else
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1826
|
+
} else {
|
|
1827
|
+
const fixedValue = canonicals.join(" ");
|
|
1828
|
+
context.report({
|
|
1829
|
+
node: loc.node,
|
|
1830
|
+
messageId: "nonCanonical",
|
|
1831
|
+
data: {
|
|
1832
|
+
className: cls,
|
|
1833
|
+
canonical
|
|
1834
|
+
},
|
|
1835
|
+
suggest: [{
|
|
1836
|
+
messageId: "suggestReplace",
|
|
1837
|
+
data: {
|
|
1838
|
+
className: cls,
|
|
1839
|
+
replacement: canonical
|
|
1840
|
+
},
|
|
1841
|
+
fix(fixer) {
|
|
1842
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1843
|
+
}
|
|
1844
|
+
}]
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1730
1847
|
}
|
|
1731
1848
|
}
|
|
1732
1849
|
}
|
|
@@ -2148,7 +2265,11 @@ const enforceLogical = (0, _oxlint_plugins.defineRule)({
|
|
|
2148
2265
|
docs: { description: "Enforce logical (RTL-friendly) Tailwind CSS properties instead of physical ones" },
|
|
2149
2266
|
fixable: "code",
|
|
2150
2267
|
schema: [],
|
|
2151
|
-
|
|
2268
|
+
hasSuggestions: true,
|
|
2269
|
+
messages: {
|
|
2270
|
+
useLogical: "\"{{className}}\" uses a physical property. Use \"{{replacement}}\" for LTR/RTL support.",
|
|
2271
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
2272
|
+
}
|
|
2152
2273
|
},
|
|
2153
2274
|
createOnce(context) {
|
|
2154
2275
|
function convertClass(cls) {
|
|
@@ -2195,7 +2316,17 @@ const enforceLogical = (0, _oxlint_plugins.defineRule)({
|
|
|
2195
2316
|
data: {
|
|
2196
2317
|
className: cls,
|
|
2197
2318
|
replacement
|
|
2198
|
-
}
|
|
2319
|
+
},
|
|
2320
|
+
suggest: [{
|
|
2321
|
+
messageId: "suggestReplace",
|
|
2322
|
+
data: {
|
|
2323
|
+
className: cls,
|
|
2324
|
+
replacement
|
|
2325
|
+
},
|
|
2326
|
+
fix(fixer) {
|
|
2327
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
2328
|
+
}
|
|
2329
|
+
}]
|
|
2199
2330
|
});
|
|
2200
2331
|
}
|
|
2201
2332
|
}
|
|
@@ -2213,7 +2344,11 @@ const enforcePhysical = (0, _oxlint_plugins.defineRule)({
|
|
|
2213
2344
|
docs: { description: "Enforce physical Tailwind CSS properties instead of logical ones for consistency in LTR-only projects" },
|
|
2214
2345
|
fixable: "code",
|
|
2215
2346
|
schema: [],
|
|
2216
|
-
|
|
2347
|
+
hasSuggestions: true,
|
|
2348
|
+
messages: {
|
|
2349
|
+
usePhysical: "\"{{className}}\" uses a logical property. Use \"{{replacement}}\" for consistency.",
|
|
2350
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
2351
|
+
}
|
|
2217
2352
|
},
|
|
2218
2353
|
createOnce(context) {
|
|
2219
2354
|
function convertClass(cls) {
|
|
@@ -2260,7 +2395,17 @@ const enforcePhysical = (0, _oxlint_plugins.defineRule)({
|
|
|
2260
2395
|
data: {
|
|
2261
2396
|
className: cls,
|
|
2262
2397
|
replacement
|
|
2263
|
-
}
|
|
2398
|
+
},
|
|
2399
|
+
suggest: [{
|
|
2400
|
+
messageId: "suggestReplace",
|
|
2401
|
+
data: {
|
|
2402
|
+
className: cls,
|
|
2403
|
+
replacement
|
|
2404
|
+
},
|
|
2405
|
+
fix(fixer) {
|
|
2406
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
2407
|
+
}
|
|
2408
|
+
}]
|
|
2264
2409
|
});
|
|
2265
2410
|
}
|
|
2266
2411
|
}
|
|
@@ -2280,6 +2425,7 @@ const maxClassCount = (0, _oxlint_plugins.defineRule)({
|
|
|
2280
2425
|
properties: { max: { type: "number" } },
|
|
2281
2426
|
additionalProperties: false
|
|
2282
2427
|
}],
|
|
2428
|
+
defaultOptions: [{ max: DEFAULT_MAX }],
|
|
2283
2429
|
messages: { tooMany: "Too many Tailwind classes ({{count}}). Maximum allowed is {{max}}. Consider extracting into a component or utility." }
|
|
2284
2430
|
},
|
|
2285
2431
|
createOnce(context) {
|
|
@@ -2449,9 +2595,12 @@ const enforceConsistentImportantPosition = (0, _oxlint_plugins.defineRule)({
|
|
|
2449
2595
|
} },
|
|
2450
2596
|
additionalProperties: false
|
|
2451
2597
|
}],
|
|
2598
|
+
hasSuggestions: true,
|
|
2599
|
+
defaultOptions: [{ position: "suffix" }],
|
|
2452
2600
|
messages: {
|
|
2453
2601
|
usePrefix: "\"{{className}}\" uses suffix important. Use \"{{replacement}}\" (prefix) instead.",
|
|
2454
|
-
useSuffix: "\"{{className}}\" uses prefix important. Use \"{{replacement}}\" (suffix) instead."
|
|
2602
|
+
useSuffix: "\"{{className}}\" uses prefix important. Use \"{{replacement}}\" (suffix) instead.",
|
|
2603
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
2455
2604
|
}
|
|
2456
2605
|
},
|
|
2457
2606
|
createOnce(context) {
|
|
@@ -2501,7 +2650,17 @@ const enforceConsistentImportantPosition = (0, _oxlint_plugins.defineRule)({
|
|
|
2501
2650
|
data: {
|
|
2502
2651
|
className: cls,
|
|
2503
2652
|
replacement
|
|
2504
|
-
}
|
|
2653
|
+
},
|
|
2654
|
+
suggest: [{
|
|
2655
|
+
messageId: "suggestReplace",
|
|
2656
|
+
data: {
|
|
2657
|
+
className: cls,
|
|
2658
|
+
replacement
|
|
2659
|
+
},
|
|
2660
|
+
fix(fixer) {
|
|
2661
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
2662
|
+
}
|
|
2663
|
+
}]
|
|
2505
2664
|
});
|
|
2506
2665
|
}
|
|
2507
2666
|
}
|
|
@@ -2536,7 +2695,11 @@ const enforceNegativeArbitraryValues = (0, _oxlint_plugins.defineRule)({
|
|
|
2536
2695
|
docs: { description: "Enforce moving the negative sign inside arbitrary value brackets: -top-[5px] → top-[-5px]" },
|
|
2537
2696
|
fixable: "code",
|
|
2538
2697
|
schema: [],
|
|
2539
|
-
|
|
2698
|
+
hasSuggestions: true,
|
|
2699
|
+
messages: {
|
|
2700
|
+
moveNegative: "\"{{className}}\" has the negative outside brackets. Use \"{{replacement}}\" instead.",
|
|
2701
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
2702
|
+
}
|
|
2540
2703
|
},
|
|
2541
2704
|
createOnce(context) {
|
|
2542
2705
|
function check(locations) {
|
|
@@ -2572,7 +2735,17 @@ const enforceNegativeArbitraryValues = (0, _oxlint_plugins.defineRule)({
|
|
|
2572
2735
|
data: {
|
|
2573
2736
|
className: cls,
|
|
2574
2737
|
replacement
|
|
2575
|
-
}
|
|
2738
|
+
},
|
|
2739
|
+
suggest: [{
|
|
2740
|
+
messageId: "suggestReplace",
|
|
2741
|
+
data: {
|
|
2742
|
+
className: cls,
|
|
2743
|
+
replacement
|
|
2744
|
+
},
|
|
2745
|
+
fix(fixer) {
|
|
2746
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
2747
|
+
}
|
|
2748
|
+
}]
|
|
2576
2749
|
});
|
|
2577
2750
|
}
|
|
2578
2751
|
}
|
|
@@ -2619,9 +2792,12 @@ const enforceConsistentVariableSyntax = (0, _oxlint_plugins.defineRule)({
|
|
|
2619
2792
|
} },
|
|
2620
2793
|
additionalProperties: false
|
|
2621
2794
|
}],
|
|
2795
|
+
hasSuggestions: true,
|
|
2796
|
+
defaultOptions: [{ syntax: "shorthand" }],
|
|
2622
2797
|
messages: {
|
|
2623
2798
|
useShorthand: "\"{{className}}\" uses explicit var() syntax. Use \"{{replacement}}\" (shorthand) instead.",
|
|
2624
|
-
useExplicit: "\"{{className}}\" uses shorthand syntax. Use \"{{replacement}}\" (explicit) instead."
|
|
2799
|
+
useExplicit: "\"{{className}}\" uses shorthand syntax. Use \"{{replacement}}\" (explicit) instead.",
|
|
2800
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
2625
2801
|
}
|
|
2626
2802
|
},
|
|
2627
2803
|
createOnce(context) {
|
|
@@ -2665,7 +2841,17 @@ const enforceConsistentVariableSyntax = (0, _oxlint_plugins.defineRule)({
|
|
|
2665
2841
|
data: {
|
|
2666
2842
|
className: cls,
|
|
2667
2843
|
replacement
|
|
2668
|
-
}
|
|
2844
|
+
},
|
|
2845
|
+
suggest: [{
|
|
2846
|
+
messageId: "suggestReplace",
|
|
2847
|
+
data: {
|
|
2848
|
+
className: cls,
|
|
2849
|
+
replacement
|
|
2850
|
+
},
|
|
2851
|
+
fix(fixer) {
|
|
2852
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
2853
|
+
}
|
|
2854
|
+
}]
|
|
2669
2855
|
});
|
|
2670
2856
|
}
|
|
2671
2857
|
}
|
|
@@ -2733,6 +2919,7 @@ const noDarkWithoutLight = (0, _oxlint_plugins.defineRule)({
|
|
|
2733
2919
|
} },
|
|
2734
2920
|
additionalProperties: false
|
|
2735
2921
|
}],
|
|
2922
|
+
defaultOptions: [{ variants: DEFAULT_VARIANTS }],
|
|
2736
2923
|
messages: { missingBase: "\"{{className}}\" uses the {{variant}} variant, but there is no base \"{{prefix}}-*\" class on this element." }
|
|
2737
2924
|
},
|
|
2738
2925
|
createOnce(context) {
|
|
@@ -3015,7 +3202,11 @@ const consistentVariantOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
3015
3202
|
},
|
|
3016
3203
|
additionalProperties: false
|
|
3017
3204
|
}],
|
|
3018
|
-
|
|
3205
|
+
hasSuggestions: true,
|
|
3206
|
+
messages: {
|
|
3207
|
+
wrongOrder: "\"{{className}}\" has variants in wrong order. Use \"{{replacement}}\" instead.",
|
|
3208
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
3209
|
+
}
|
|
3019
3210
|
},
|
|
3020
3211
|
createOnce(context) {
|
|
3021
3212
|
const getDS = createLazyLoader(context);
|
|
@@ -3104,7 +3295,17 @@ const consistentVariantOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
3104
3295
|
data: {
|
|
3105
3296
|
className: cls,
|
|
3106
3297
|
replacement
|
|
3107
|
-
}
|
|
3298
|
+
},
|
|
3299
|
+
suggest: [{
|
|
3300
|
+
messageId: "suggestReplace",
|
|
3301
|
+
data: {
|
|
3302
|
+
className: cls,
|
|
3303
|
+
replacement
|
|
3304
|
+
},
|
|
3305
|
+
fix(fixer) {
|
|
3306
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
3307
|
+
}
|
|
3308
|
+
}]
|
|
3108
3309
|
});
|
|
3109
3310
|
}
|
|
3110
3311
|
}
|
|
@@ -3128,6 +3329,7 @@ const enforceConsistentLineWrapping = (0, _oxlint_plugins.defineRule)({
|
|
|
3128
3329
|
},
|
|
3129
3330
|
additionalProperties: false
|
|
3130
3331
|
}],
|
|
3332
|
+
defaultOptions: [{ printWidth: DEFAULT_PRINT_WIDTH }],
|
|
3131
3333
|
messages: {
|
|
3132
3334
|
tooLong: "Class string is {{length}} characters long, exceeding the print width of {{printWidth}}. Consider splitting into multiple lines or extracting into a component.",
|
|
3133
3335
|
tooManyPerLine: "Too many classes on a single line ({{count}}). Maximum allowed per line is {{max}}."
|
|
@@ -3201,7 +3403,11 @@ const noUnnecessaryArbitraryValue = (0, _oxlint_plugins.defineRule)({
|
|
|
3201
3403
|
properties: { entryPoint: { type: "string" } },
|
|
3202
3404
|
additionalProperties: false
|
|
3203
3405
|
}],
|
|
3204
|
-
|
|
3406
|
+
hasSuggestions: true,
|
|
3407
|
+
messages: {
|
|
3408
|
+
unnecessaryArbitrary: "\"{{className}}\" can be written as \"{{replacement}}\". Use the named class instead.",
|
|
3409
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
3410
|
+
}
|
|
3205
3411
|
},
|
|
3206
3412
|
createOnce(context) {
|
|
3207
3413
|
const getDS = createLazyLoader(context);
|
|
@@ -3247,7 +3453,17 @@ const noUnnecessaryArbitraryValue = (0, _oxlint_plugins.defineRule)({
|
|
|
3247
3453
|
data: {
|
|
3248
3454
|
className: cls,
|
|
3249
3455
|
replacement
|
|
3250
|
-
}
|
|
3456
|
+
},
|
|
3457
|
+
suggest: [{
|
|
3458
|
+
messageId: "suggestReplace",
|
|
3459
|
+
data: {
|
|
3460
|
+
className: cls,
|
|
3461
|
+
replacement
|
|
3462
|
+
},
|
|
3463
|
+
fix(fixer) {
|
|
3464
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
3465
|
+
}
|
|
3466
|
+
}]
|
|
3251
3467
|
});
|
|
3252
3468
|
}
|
|
3253
3469
|
}
|