oxlint-tailwindcss 0.4.1 → 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 +52 -0
- package/dist/index.cjs +257 -38
- package/dist/index.mjs +391 -176
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -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
|
@@ -1269,21 +1269,75 @@ function autoDetectEntryPoint(filePath) {
|
|
|
1269
1269
|
return null;
|
|
1270
1270
|
}
|
|
1271
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
|
|
1272
1300
|
//#region src/design-system/loader.ts
|
|
1273
1301
|
const dsCache = /* @__PURE__ */ new Map();
|
|
1274
1302
|
const autoDetectCache = /* @__PURE__ */ new Map();
|
|
1275
1303
|
let lastLoadedPath = null;
|
|
1276
1304
|
/**
|
|
1277
1305
|
* Extracts `entryPoint` from `context.settings.tailwindcss`.
|
|
1306
|
+
* Supports both `string` and `string[]` (for monorepos).
|
|
1278
1307
|
*/
|
|
1279
1308
|
function entryPointFromSettings(settings) {
|
|
1280
1309
|
const tw = settings?.tailwindcss;
|
|
1281
1310
|
if (tw && typeof tw === "object" && "entryPoint" in tw) {
|
|
1282
1311
|
const ep = tw.entryPoint;
|
|
1283
1312
|
if (typeof ep === "string") return ep;
|
|
1313
|
+
if (Array.isArray(ep) && ep.length > 0 && ep.every((e) => typeof e === "string")) return ep;
|
|
1284
1314
|
}
|
|
1285
1315
|
}
|
|
1286
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
|
+
/**
|
|
1287
1341
|
* Extracts `timeout` from `context.settings.tailwindcss`.
|
|
1288
1342
|
*/
|
|
1289
1343
|
function timeoutFromSettings(settings) {
|
|
@@ -1317,7 +1371,8 @@ function cachedAutoDetect(filePath) {
|
|
|
1317
1371
|
* Resolution order: rule option `entryPoint` > `settings.tailwindcss.entryPoint` > auto-detect.
|
|
1318
1372
|
*/
|
|
1319
1373
|
function getLoadedDesignSystem(entryPoint, settings, filePath) {
|
|
1320
|
-
const
|
|
1374
|
+
const settingsEntry = entryPointFromSettings(settings);
|
|
1375
|
+
const explicitEntry = entryPoint ?? (Array.isArray(settingsEntry) ? resolveClosestEntryPoint(settingsEntry, filePath) : settingsEntry);
|
|
1321
1376
|
const cssPath = explicitEntry ?? cachedAutoDetect(filePath) ?? lastLoadedPath;
|
|
1322
1377
|
if (!cssPath) return null;
|
|
1323
1378
|
const resolvedPath = (0, node_path.resolve)(cssPath);
|
|
@@ -1338,7 +1393,7 @@ function getLoadedDesignSystem(entryPoint, settings, filePath) {
|
|
|
1338
1393
|
cache,
|
|
1339
1394
|
mtime
|
|
1340
1395
|
});
|
|
1341
|
-
|
|
1396
|
+
debugLog(`Loaded design system from "${resolvedPath}"`);
|
|
1342
1397
|
if (explicitEntry) lastLoadedPath = resolvedPath;
|
|
1343
1398
|
return {
|
|
1344
1399
|
cache,
|
|
@@ -1363,6 +1418,7 @@ function createLazyLoader(context) {
|
|
|
1363
1418
|
let lastResult = null;
|
|
1364
1419
|
let fixedEntryResolved = false;
|
|
1365
1420
|
let fixedResult = null;
|
|
1421
|
+
let debugInitialized = false;
|
|
1366
1422
|
return () => {
|
|
1367
1423
|
let entryPoint;
|
|
1368
1424
|
try {
|
|
@@ -1376,16 +1432,31 @@ function createLazyLoader(context) {
|
|
|
1376
1432
|
try {
|
|
1377
1433
|
filePath = context.filename;
|
|
1378
1434
|
} catch {}
|
|
1379
|
-
|
|
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);
|
|
1380
1441
|
if (fixedEntry) {
|
|
1381
1442
|
if (fixedEntryResolved) return fixedResult;
|
|
1382
1443
|
fixedEntryResolved = true;
|
|
1383
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)}`);
|
|
1384
1446
|
return fixedResult;
|
|
1385
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
|
+
}
|
|
1386
1456
|
if (filePath && filePath === lastFilePath) return lastResult;
|
|
1387
1457
|
if (filePath) lastFilePath = filePath;
|
|
1388
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)}`);
|
|
1389
1460
|
return lastResult;
|
|
1390
1461
|
};
|
|
1391
1462
|
}
|
|
@@ -1436,7 +1507,11 @@ const noDeprecatedClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1436
1507
|
properties: { entryPoint: { type: "string" } },
|
|
1437
1508
|
additionalProperties: false
|
|
1438
1509
|
}],
|
|
1439
|
-
|
|
1510
|
+
hasSuggestions: true,
|
|
1511
|
+
messages: {
|
|
1512
|
+
deprecated: "\"{{className}}\" is deprecated in Tailwind v4. Use \"{{replacement}}\" instead.",
|
|
1513
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
1514
|
+
}
|
|
1440
1515
|
},
|
|
1441
1516
|
createOnce(context) {
|
|
1442
1517
|
const getDS = createLazyLoader(context);
|
|
@@ -1484,7 +1559,17 @@ const noDeprecatedClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1484
1559
|
data: {
|
|
1485
1560
|
className: cls,
|
|
1486
1561
|
replacement
|
|
1487
|
-
}
|
|
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
|
+
}]
|
|
1488
1573
|
});
|
|
1489
1574
|
}
|
|
1490
1575
|
}
|
|
@@ -1513,9 +1598,15 @@ const noUnknownClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1513
1598
|
},
|
|
1514
1599
|
additionalProperties: false
|
|
1515
1600
|
}],
|
|
1601
|
+
hasSuggestions: true,
|
|
1602
|
+
defaultOptions: [{
|
|
1603
|
+
allowlist: [],
|
|
1604
|
+
ignorePrefixes: []
|
|
1605
|
+
}],
|
|
1516
1606
|
messages: {
|
|
1517
1607
|
unknown: "\"{{className}}\" is not a valid Tailwind class.",
|
|
1518
|
-
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}}\"."
|
|
1519
1610
|
}
|
|
1520
1611
|
},
|
|
1521
1612
|
createOnce(context) {
|
|
@@ -1556,15 +1647,27 @@ const noUnknownClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1556
1647
|
if (cache.isValid(stripped)) continue;
|
|
1557
1648
|
if (DEPRECATED_MAP[stripped]) continue;
|
|
1558
1649
|
const suggestion = findBestSuggestion(stripped, cache.validClasses);
|
|
1559
|
-
if (suggestion)
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
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({
|
|
1568
1671
|
node: loc.node,
|
|
1569
1672
|
messageId: "unknown",
|
|
1570
1673
|
data: { className: cls }
|
|
@@ -1686,7 +1789,11 @@ const enforceCanonical = (0, _oxlint_plugins.defineRule)({
|
|
|
1686
1789
|
properties: { entryPoint: { type: "string" } },
|
|
1687
1790
|
additionalProperties: false
|
|
1688
1791
|
}],
|
|
1689
|
-
|
|
1792
|
+
hasSuggestions: true,
|
|
1793
|
+
messages: {
|
|
1794
|
+
nonCanonical: "\"{{className}}\" can be written as \"{{canonical}}\". Use the canonical form.",
|
|
1795
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
1796
|
+
}
|
|
1690
1797
|
},
|
|
1691
1798
|
createOnce(context) {
|
|
1692
1799
|
const getDS = createLazyLoader(context);
|
|
@@ -1716,14 +1823,27 @@ const enforceCanonical = (0, _oxlint_plugins.defineRule)({
|
|
|
1716
1823
|
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1717
1824
|
}
|
|
1718
1825
|
});
|
|
1719
|
-
} else
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
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
|
+
}
|
|
1727
1847
|
}
|
|
1728
1848
|
}
|
|
1729
1849
|
}
|
|
@@ -2145,7 +2265,11 @@ const enforceLogical = (0, _oxlint_plugins.defineRule)({
|
|
|
2145
2265
|
docs: { description: "Enforce logical (RTL-friendly) Tailwind CSS properties instead of physical ones" },
|
|
2146
2266
|
fixable: "code",
|
|
2147
2267
|
schema: [],
|
|
2148
|
-
|
|
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
|
+
}
|
|
2149
2273
|
},
|
|
2150
2274
|
createOnce(context) {
|
|
2151
2275
|
function convertClass(cls) {
|
|
@@ -2192,7 +2316,17 @@ const enforceLogical = (0, _oxlint_plugins.defineRule)({
|
|
|
2192
2316
|
data: {
|
|
2193
2317
|
className: cls,
|
|
2194
2318
|
replacement
|
|
2195
|
-
}
|
|
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
|
+
}]
|
|
2196
2330
|
});
|
|
2197
2331
|
}
|
|
2198
2332
|
}
|
|
@@ -2210,7 +2344,11 @@ const enforcePhysical = (0, _oxlint_plugins.defineRule)({
|
|
|
2210
2344
|
docs: { description: "Enforce physical Tailwind CSS properties instead of logical ones for consistency in LTR-only projects" },
|
|
2211
2345
|
fixable: "code",
|
|
2212
2346
|
schema: [],
|
|
2213
|
-
|
|
2347
|
+
hasSuggestions: true,
|
|
2348
|
+
messages: {
|
|
2349
|
+
usePhysical: "\"{{className}}\" uses a logical property. Use \"{{replacement}}\" for consistency.",
|
|
2350
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
2351
|
+
}
|
|
2214
2352
|
},
|
|
2215
2353
|
createOnce(context) {
|
|
2216
2354
|
function convertClass(cls) {
|
|
@@ -2257,7 +2395,17 @@ const enforcePhysical = (0, _oxlint_plugins.defineRule)({
|
|
|
2257
2395
|
data: {
|
|
2258
2396
|
className: cls,
|
|
2259
2397
|
replacement
|
|
2260
|
-
}
|
|
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
|
+
}]
|
|
2261
2409
|
});
|
|
2262
2410
|
}
|
|
2263
2411
|
}
|
|
@@ -2277,6 +2425,7 @@ const maxClassCount = (0, _oxlint_plugins.defineRule)({
|
|
|
2277
2425
|
properties: { max: { type: "number" } },
|
|
2278
2426
|
additionalProperties: false
|
|
2279
2427
|
}],
|
|
2428
|
+
defaultOptions: [{ max: DEFAULT_MAX }],
|
|
2280
2429
|
messages: { tooMany: "Too many Tailwind classes ({{count}}). Maximum allowed is {{max}}. Consider extracting into a component or utility." }
|
|
2281
2430
|
},
|
|
2282
2431
|
createOnce(context) {
|
|
@@ -2446,9 +2595,12 @@ const enforceConsistentImportantPosition = (0, _oxlint_plugins.defineRule)({
|
|
|
2446
2595
|
} },
|
|
2447
2596
|
additionalProperties: false
|
|
2448
2597
|
}],
|
|
2598
|
+
hasSuggestions: true,
|
|
2599
|
+
defaultOptions: [{ position: "suffix" }],
|
|
2449
2600
|
messages: {
|
|
2450
2601
|
usePrefix: "\"{{className}}\" uses suffix important. Use \"{{replacement}}\" (prefix) instead.",
|
|
2451
|
-
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}}\"."
|
|
2452
2604
|
}
|
|
2453
2605
|
},
|
|
2454
2606
|
createOnce(context) {
|
|
@@ -2498,7 +2650,17 @@ const enforceConsistentImportantPosition = (0, _oxlint_plugins.defineRule)({
|
|
|
2498
2650
|
data: {
|
|
2499
2651
|
className: cls,
|
|
2500
2652
|
replacement
|
|
2501
|
-
}
|
|
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
|
+
}]
|
|
2502
2664
|
});
|
|
2503
2665
|
}
|
|
2504
2666
|
}
|
|
@@ -2533,7 +2695,11 @@ const enforceNegativeArbitraryValues = (0, _oxlint_plugins.defineRule)({
|
|
|
2533
2695
|
docs: { description: "Enforce moving the negative sign inside arbitrary value brackets: -top-[5px] → top-[-5px]" },
|
|
2534
2696
|
fixable: "code",
|
|
2535
2697
|
schema: [],
|
|
2536
|
-
|
|
2698
|
+
hasSuggestions: true,
|
|
2699
|
+
messages: {
|
|
2700
|
+
moveNegative: "\"{{className}}\" has the negative outside brackets. Use \"{{replacement}}\" instead.",
|
|
2701
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
2702
|
+
}
|
|
2537
2703
|
},
|
|
2538
2704
|
createOnce(context) {
|
|
2539
2705
|
function check(locations) {
|
|
@@ -2569,7 +2735,17 @@ const enforceNegativeArbitraryValues = (0, _oxlint_plugins.defineRule)({
|
|
|
2569
2735
|
data: {
|
|
2570
2736
|
className: cls,
|
|
2571
2737
|
replacement
|
|
2572
|
-
}
|
|
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
|
+
}]
|
|
2573
2749
|
});
|
|
2574
2750
|
}
|
|
2575
2751
|
}
|
|
@@ -2616,9 +2792,12 @@ const enforceConsistentVariableSyntax = (0, _oxlint_plugins.defineRule)({
|
|
|
2616
2792
|
} },
|
|
2617
2793
|
additionalProperties: false
|
|
2618
2794
|
}],
|
|
2795
|
+
hasSuggestions: true,
|
|
2796
|
+
defaultOptions: [{ syntax: "shorthand" }],
|
|
2619
2797
|
messages: {
|
|
2620
2798
|
useShorthand: "\"{{className}}\" uses explicit var() syntax. Use \"{{replacement}}\" (shorthand) instead.",
|
|
2621
|
-
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}}\"."
|
|
2622
2801
|
}
|
|
2623
2802
|
},
|
|
2624
2803
|
createOnce(context) {
|
|
@@ -2662,7 +2841,17 @@ const enforceConsistentVariableSyntax = (0, _oxlint_plugins.defineRule)({
|
|
|
2662
2841
|
data: {
|
|
2663
2842
|
className: cls,
|
|
2664
2843
|
replacement
|
|
2665
|
-
}
|
|
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
|
+
}]
|
|
2666
2855
|
});
|
|
2667
2856
|
}
|
|
2668
2857
|
}
|
|
@@ -2730,6 +2919,7 @@ const noDarkWithoutLight = (0, _oxlint_plugins.defineRule)({
|
|
|
2730
2919
|
} },
|
|
2731
2920
|
additionalProperties: false
|
|
2732
2921
|
}],
|
|
2922
|
+
defaultOptions: [{ variants: DEFAULT_VARIANTS }],
|
|
2733
2923
|
messages: { missingBase: "\"{{className}}\" uses the {{variant}} variant, but there is no base \"{{prefix}}-*\" class on this element." }
|
|
2734
2924
|
},
|
|
2735
2925
|
createOnce(context) {
|
|
@@ -3012,7 +3202,11 @@ const consistentVariantOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
3012
3202
|
},
|
|
3013
3203
|
additionalProperties: false
|
|
3014
3204
|
}],
|
|
3015
|
-
|
|
3205
|
+
hasSuggestions: true,
|
|
3206
|
+
messages: {
|
|
3207
|
+
wrongOrder: "\"{{className}}\" has variants in wrong order. Use \"{{replacement}}\" instead.",
|
|
3208
|
+
suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
|
|
3209
|
+
}
|
|
3016
3210
|
},
|
|
3017
3211
|
createOnce(context) {
|
|
3018
3212
|
const getDS = createLazyLoader(context);
|
|
@@ -3101,7 +3295,17 @@ const consistentVariantOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
3101
3295
|
data: {
|
|
3102
3296
|
className: cls,
|
|
3103
3297
|
replacement
|
|
3104
|
-
}
|
|
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
|
+
}]
|
|
3105
3309
|
});
|
|
3106
3310
|
}
|
|
3107
3311
|
}
|
|
@@ -3125,6 +3329,7 @@ const enforceConsistentLineWrapping = (0, _oxlint_plugins.defineRule)({
|
|
|
3125
3329
|
},
|
|
3126
3330
|
additionalProperties: false
|
|
3127
3331
|
}],
|
|
3332
|
+
defaultOptions: [{ printWidth: DEFAULT_PRINT_WIDTH }],
|
|
3128
3333
|
messages: {
|
|
3129
3334
|
tooLong: "Class string is {{length}} characters long, exceeding the print width of {{printWidth}}. Consider splitting into multiple lines or extracting into a component.",
|
|
3130
3335
|
tooManyPerLine: "Too many classes on a single line ({{count}}). Maximum allowed per line is {{max}}."
|
|
@@ -3198,7 +3403,11 @@ const noUnnecessaryArbitraryValue = (0, _oxlint_plugins.defineRule)({
|
|
|
3198
3403
|
properties: { entryPoint: { type: "string" } },
|
|
3199
3404
|
additionalProperties: false
|
|
3200
3405
|
}],
|
|
3201
|
-
|
|
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
|
+
}
|
|
3202
3411
|
},
|
|
3203
3412
|
createOnce(context) {
|
|
3204
3413
|
const getDS = createLazyLoader(context);
|
|
@@ -3244,7 +3453,17 @@ const noUnnecessaryArbitraryValue = (0, _oxlint_plugins.defineRule)({
|
|
|
3244
3453
|
data: {
|
|
3245
3454
|
className: cls,
|
|
3246
3455
|
replacement
|
|
3247
|
-
}
|
|
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
|
+
}]
|
|
3248
3467
|
});
|
|
3249
3468
|
}
|
|
3250
3469
|
}
|