oxlint-tailwindcss 0.1.7 → 0.1.9
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 +8 -6
- package/dist/index.cjs +30 -14
- package/dist/index.mjs +34 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -428,13 +428,13 @@ The inverse of `enforce-logical`. Converts logical properties back to physical o
|
|
|
428
428
|
Enforces a consistent position for the `!` (important) modifier — either prefix or suffix.
|
|
429
429
|
|
|
430
430
|
```tsx
|
|
431
|
-
// ❌ Bad (default:
|
|
432
|
-
<div className="font-bold!" />
|
|
433
|
-
<div className="hover:text-red!" />
|
|
434
|
-
|
|
435
|
-
// ✅ Fixed
|
|
431
|
+
// ❌ Bad (default: suffix — Tailwind v4 canonical form)
|
|
436
432
|
<div className="!font-bold" />
|
|
437
433
|
<div className="hover:!text-red" />
|
|
434
|
+
|
|
435
|
+
// ✅ Fixed
|
|
436
|
+
<div className="font-bold!" />
|
|
437
|
+
<div className="hover:text-red!" />
|
|
438
438
|
```
|
|
439
439
|
|
|
440
440
|
Handles variants correctly — the `!` is placed on the utility, not the variant prefix.
|
|
@@ -443,7 +443,9 @@ Handles variants correctly — the `!` is placed on the utility, not the variant
|
|
|
443
443
|
|
|
444
444
|
| Option | Type | Default | Description |
|
|
445
445
|
| ---------- | ------------------------ | ---------- | ------------------------------- |
|
|
446
|
-
| `position` | `"prefix"` \| `"suffix"` | `"
|
|
446
|
+
| `position` | `"prefix"` \| `"suffix"` | `"suffix"` | Where to place the `!` modifier |
|
|
447
|
+
|
|
448
|
+
> **Note:** The default is `"suffix"` to match Tailwind CSS v4's canonical form. The prefix form (`!flex`) is deprecated in v4. Using `"prefix"` may conflict with `enforce-canonical`, which also normalizes `!` to the suffix position.
|
|
447
449
|
|
|
448
450
|
**Autofix:** Moves `!` to the correct position.
|
|
449
451
|
|
package/dist/index.cjs
CHANGED
|
@@ -536,6 +536,9 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
536
536
|
get validClasses() {
|
|
537
537
|
return this._validClasses;
|
|
538
538
|
}
|
|
539
|
+
get maxOrder() {
|
|
540
|
+
return this._maxOrder;
|
|
541
|
+
}
|
|
539
542
|
canonicalize(className) {
|
|
540
543
|
const cached = this.canonicalMap.get(className);
|
|
541
544
|
if (cached !== void 0) return cached;
|
|
@@ -547,7 +550,10 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
547
550
|
const { bare, important } = stripImportant(utility);
|
|
548
551
|
if (important) {
|
|
549
552
|
const canonicalBare = this.canonicalMap.get(bare);
|
|
550
|
-
if (canonicalBare !== void 0)
|
|
553
|
+
if (canonicalBare !== void 0) {
|
|
554
|
+
const variantPrefix = className.slice(0, className.length - utility.length);
|
|
555
|
+
return utility.startsWith("!") ? variantPrefix + "!" + canonicalBare : variantPrefix + canonicalBare + "!";
|
|
556
|
+
}
|
|
551
557
|
}
|
|
552
558
|
return className;
|
|
553
559
|
}
|
|
@@ -653,6 +659,11 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
653
659
|
baseOrder = this.findOrderByPrefix(prefix);
|
|
654
660
|
}
|
|
655
661
|
}
|
|
662
|
+
if (baseOrder === void 0) {
|
|
663
|
+
const stripped = stripImportant(utility).bare;
|
|
664
|
+
const numericMatch = /^(.+)-(\d+\.?\d*)$/.exec(stripped);
|
|
665
|
+
if (numericMatch && this.getKnownPrefixes().has(numericMatch[1])) baseOrder = this.findOrderByPrefix(numericMatch[1] + "-");
|
|
666
|
+
}
|
|
656
667
|
if (baseOrder === void 0) return null;
|
|
657
668
|
if (!hasVariant) return baseOrder;
|
|
658
669
|
const variants = extractVariants(className);
|
|
@@ -1511,7 +1522,7 @@ async function main() {
|
|
|
1511
1522
|
|
|
1512
1523
|
let ds;
|
|
1513
1524
|
try {
|
|
1514
|
-
const { __unstable__loadDesignSystem } = require(
|
|
1525
|
+
const { __unstable__loadDesignSystem } = require(workerData.tailwindNodePath);
|
|
1515
1526
|
const { readFileSync } = require('fs');
|
|
1516
1527
|
const { dirname } = require('path');
|
|
1517
1528
|
const css = readFileSync(cssPath, 'utf-8');
|
|
@@ -1570,6 +1581,7 @@ function ensureService(cssPath) {
|
|
|
1570
1581
|
if (initialized) return available;
|
|
1571
1582
|
initialized = true;
|
|
1572
1583
|
try {
|
|
1584
|
+
const tailwindNodePath = require.resolve("@tailwindcss/node");
|
|
1573
1585
|
const sharedBuffer = new SharedArrayBuffer(BUFFER_SIZE);
|
|
1574
1586
|
controlArray = new Int32Array(sharedBuffer, 0, HEADER_INTS);
|
|
1575
1587
|
lengthView = new DataView(sharedBuffer, HEADER_INTS * 4, 4);
|
|
@@ -1578,7 +1590,8 @@ function ensureService(cssPath) {
|
|
|
1578
1590
|
eval: true,
|
|
1579
1591
|
workerData: {
|
|
1580
1592
|
sharedBuffer,
|
|
1581
|
-
cssPath
|
|
1593
|
+
cssPath,
|
|
1594
|
+
tailwindNodePath
|
|
1582
1595
|
}
|
|
1583
1596
|
});
|
|
1584
1597
|
worker.unref();
|
|
@@ -1675,10 +1688,11 @@ const enforceSortOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
1675
1688
|
const dynamic = sortClassesSync(entryPoint, classes);
|
|
1676
1689
|
if (dynamic) return dynamic;
|
|
1677
1690
|
return [...cache.getClassOrder(classes)].sort((a, b) => {
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
if (
|
|
1681
|
-
if (
|
|
1691
|
+
if (a[1] === null && b[1] === null) return 0;
|
|
1692
|
+
if (a[1] === null) return -1;
|
|
1693
|
+
if (b[1] === null) return 1;
|
|
1694
|
+
if (a[1] < b[1]) return -1;
|
|
1695
|
+
if (a[1] > b[1]) return 1;
|
|
1682
1696
|
return 0;
|
|
1683
1697
|
}).map(([name]) => name);
|
|
1684
1698
|
}
|
|
@@ -1696,10 +1710,11 @@ const enforceSortOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
1696
1710
|
for (const [, groupClasses] of groups) {
|
|
1697
1711
|
const ordered = cache.getClassOrder(groupClasses);
|
|
1698
1712
|
ordered.sort((a, b) => {
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
if (
|
|
1702
|
-
if (
|
|
1713
|
+
if (a[1] === null && b[1] === null) return 0;
|
|
1714
|
+
if (a[1] === null) return -1;
|
|
1715
|
+
if (b[1] === null) return 1;
|
|
1716
|
+
if (a[1] < b[1]) return -1;
|
|
1717
|
+
if (a[1] > b[1]) return 1;
|
|
1703
1718
|
return 0;
|
|
1704
1719
|
});
|
|
1705
1720
|
groupClasses.length = 0;
|
|
@@ -2263,7 +2278,7 @@ const noArbitraryValue = (0, _oxlint_plugins.defineRule)({
|
|
|
2263
2278
|
const enforceConsistentImportantPosition = (0, _oxlint_plugins.defineRule)({
|
|
2264
2279
|
meta: {
|
|
2265
2280
|
type: "suggestion",
|
|
2266
|
-
docs: { description: "Enforce consistent position of the important (!) modifier
|
|
2281
|
+
docs: { description: "Enforce consistent position of the important (!) modifier. Default: suffix (Tailwind v4 canonical form). Note: using \"prefix\" may conflict with enforce-canonical which normalizes to suffix." },
|
|
2267
2282
|
fixable: "code",
|
|
2268
2283
|
schema: [{
|
|
2269
2284
|
type: "object",
|
|
@@ -2281,7 +2296,7 @@ const enforceConsistentImportantPosition = (0, _oxlint_plugins.defineRule)({
|
|
|
2281
2296
|
createOnce(context) {
|
|
2282
2297
|
let _position = null;
|
|
2283
2298
|
function getPosition() {
|
|
2284
|
-
if (_position === null) _position = safeOptions(context)?.position ?? "
|
|
2299
|
+
if (_position === null) _position = safeOptions(context)?.position ?? "suffix";
|
|
2285
2300
|
return _position;
|
|
2286
2301
|
}
|
|
2287
2302
|
function fixUtility(utility, variantPfx) {
|
|
@@ -2829,6 +2844,8 @@ const noContradictingVariants = (0, _oxlint_plugins.defineRule)({
|
|
|
2829
2844
|
//#endregion
|
|
2830
2845
|
//#region src/rules/consistent-variant-order.ts
|
|
2831
2846
|
const DEFAULT_VARIANT_ORDER = [
|
|
2847
|
+
"*",
|
|
2848
|
+
"**",
|
|
2832
2849
|
"sm",
|
|
2833
2850
|
"md",
|
|
2834
2851
|
"lg",
|
|
@@ -2961,7 +2978,6 @@ const consistentVariantOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
2961
2978
|
const dsPriority = dsCache.getVariantPriority(variant);
|
|
2962
2979
|
if (dsPriority !== null) return dsPriority;
|
|
2963
2980
|
}
|
|
2964
|
-
if (variant.startsWith("[")) return -1;
|
|
2965
2981
|
return fallbackPriority;
|
|
2966
2982
|
}
|
|
2967
2983
|
function reorderClass(cls) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
2
3
|
import { execFileSync } from "node:child_process";
|
|
3
4
|
import { createHash } from "node:crypto";
|
|
@@ -5,6 +6,9 @@ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "no
|
|
|
5
6
|
import { dirname, join, resolve } from "node:path";
|
|
6
7
|
import { tmpdir } from "node:os";
|
|
7
8
|
import { Worker } from "node:worker_threads";
|
|
9
|
+
//#region \0rolldown/runtime.js
|
|
10
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
11
|
+
//#endregion
|
|
8
12
|
//#region src/utils/extractors.ts
|
|
9
13
|
/**
|
|
10
14
|
* Preserves leading/trailing spaces in fixed class strings for template literals.
|
|
@@ -536,6 +540,9 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
536
540
|
get validClasses() {
|
|
537
541
|
return this._validClasses;
|
|
538
542
|
}
|
|
543
|
+
get maxOrder() {
|
|
544
|
+
return this._maxOrder;
|
|
545
|
+
}
|
|
539
546
|
canonicalize(className) {
|
|
540
547
|
const cached = this.canonicalMap.get(className);
|
|
541
548
|
if (cached !== void 0) return cached;
|
|
@@ -547,7 +554,10 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
547
554
|
const { bare, important } = stripImportant(utility);
|
|
548
555
|
if (important) {
|
|
549
556
|
const canonicalBare = this.canonicalMap.get(bare);
|
|
550
|
-
if (canonicalBare !== void 0)
|
|
557
|
+
if (canonicalBare !== void 0) {
|
|
558
|
+
const variantPrefix = className.slice(0, className.length - utility.length);
|
|
559
|
+
return utility.startsWith("!") ? variantPrefix + "!" + canonicalBare : variantPrefix + canonicalBare + "!";
|
|
560
|
+
}
|
|
551
561
|
}
|
|
552
562
|
return className;
|
|
553
563
|
}
|
|
@@ -653,6 +663,11 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
653
663
|
baseOrder = this.findOrderByPrefix(prefix);
|
|
654
664
|
}
|
|
655
665
|
}
|
|
666
|
+
if (baseOrder === void 0) {
|
|
667
|
+
const stripped = stripImportant(utility).bare;
|
|
668
|
+
const numericMatch = /^(.+)-(\d+\.?\d*)$/.exec(stripped);
|
|
669
|
+
if (numericMatch && this.getKnownPrefixes().has(numericMatch[1])) baseOrder = this.findOrderByPrefix(numericMatch[1] + "-");
|
|
670
|
+
}
|
|
656
671
|
if (baseOrder === void 0) return null;
|
|
657
672
|
if (!hasVariant) return baseOrder;
|
|
658
673
|
const variants = extractVariants(className);
|
|
@@ -1511,7 +1526,7 @@ async function main() {
|
|
|
1511
1526
|
|
|
1512
1527
|
let ds;
|
|
1513
1528
|
try {
|
|
1514
|
-
const { __unstable__loadDesignSystem } = require(
|
|
1529
|
+
const { __unstable__loadDesignSystem } = require(workerData.tailwindNodePath);
|
|
1515
1530
|
const { readFileSync } = require('fs');
|
|
1516
1531
|
const { dirname } = require('path');
|
|
1517
1532
|
const css = readFileSync(cssPath, 'utf-8');
|
|
@@ -1570,6 +1585,7 @@ function ensureService(cssPath) {
|
|
|
1570
1585
|
if (initialized) return available;
|
|
1571
1586
|
initialized = true;
|
|
1572
1587
|
try {
|
|
1588
|
+
const tailwindNodePath = __require.resolve("@tailwindcss/node");
|
|
1573
1589
|
const sharedBuffer = new SharedArrayBuffer(BUFFER_SIZE);
|
|
1574
1590
|
controlArray = new Int32Array(sharedBuffer, 0, HEADER_INTS);
|
|
1575
1591
|
lengthView = new DataView(sharedBuffer, HEADER_INTS * 4, 4);
|
|
@@ -1578,7 +1594,8 @@ function ensureService(cssPath) {
|
|
|
1578
1594
|
eval: true,
|
|
1579
1595
|
workerData: {
|
|
1580
1596
|
sharedBuffer,
|
|
1581
|
-
cssPath
|
|
1597
|
+
cssPath,
|
|
1598
|
+
tailwindNodePath
|
|
1582
1599
|
}
|
|
1583
1600
|
});
|
|
1584
1601
|
worker.unref();
|
|
@@ -1675,10 +1692,11 @@ const enforceSortOrder = defineRule({
|
|
|
1675
1692
|
const dynamic = sortClassesSync(entryPoint, classes);
|
|
1676
1693
|
if (dynamic) return dynamic;
|
|
1677
1694
|
return [...cache.getClassOrder(classes)].sort((a, b) => {
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
if (
|
|
1681
|
-
if (
|
|
1695
|
+
if (a[1] === null && b[1] === null) return 0;
|
|
1696
|
+
if (a[1] === null) return -1;
|
|
1697
|
+
if (b[1] === null) return 1;
|
|
1698
|
+
if (a[1] < b[1]) return -1;
|
|
1699
|
+
if (a[1] > b[1]) return 1;
|
|
1682
1700
|
return 0;
|
|
1683
1701
|
}).map(([name]) => name);
|
|
1684
1702
|
}
|
|
@@ -1696,10 +1714,11 @@ const enforceSortOrder = defineRule({
|
|
|
1696
1714
|
for (const [, groupClasses] of groups) {
|
|
1697
1715
|
const ordered = cache.getClassOrder(groupClasses);
|
|
1698
1716
|
ordered.sort((a, b) => {
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
if (
|
|
1702
|
-
if (
|
|
1717
|
+
if (a[1] === null && b[1] === null) return 0;
|
|
1718
|
+
if (a[1] === null) return -1;
|
|
1719
|
+
if (b[1] === null) return 1;
|
|
1720
|
+
if (a[1] < b[1]) return -1;
|
|
1721
|
+
if (a[1] > b[1]) return 1;
|
|
1703
1722
|
return 0;
|
|
1704
1723
|
});
|
|
1705
1724
|
groupClasses.length = 0;
|
|
@@ -2263,7 +2282,7 @@ const noArbitraryValue = defineRule({
|
|
|
2263
2282
|
const enforceConsistentImportantPosition = defineRule({
|
|
2264
2283
|
meta: {
|
|
2265
2284
|
type: "suggestion",
|
|
2266
|
-
docs: { description: "Enforce consistent position of the important (!) modifier
|
|
2285
|
+
docs: { description: "Enforce consistent position of the important (!) modifier. Default: suffix (Tailwind v4 canonical form). Note: using \"prefix\" may conflict with enforce-canonical which normalizes to suffix." },
|
|
2267
2286
|
fixable: "code",
|
|
2268
2287
|
schema: [{
|
|
2269
2288
|
type: "object",
|
|
@@ -2281,7 +2300,7 @@ const enforceConsistentImportantPosition = defineRule({
|
|
|
2281
2300
|
createOnce(context) {
|
|
2282
2301
|
let _position = null;
|
|
2283
2302
|
function getPosition() {
|
|
2284
|
-
if (_position === null) _position = safeOptions(context)?.position ?? "
|
|
2303
|
+
if (_position === null) _position = safeOptions(context)?.position ?? "suffix";
|
|
2285
2304
|
return _position;
|
|
2286
2305
|
}
|
|
2287
2306
|
function fixUtility(utility, variantPfx) {
|
|
@@ -2829,6 +2848,8 @@ const noContradictingVariants = defineRule({
|
|
|
2829
2848
|
//#endregion
|
|
2830
2849
|
//#region src/rules/consistent-variant-order.ts
|
|
2831
2850
|
const DEFAULT_VARIANT_ORDER = [
|
|
2851
|
+
"*",
|
|
2852
|
+
"**",
|
|
2832
2853
|
"sm",
|
|
2833
2854
|
"md",
|
|
2834
2855
|
"lg",
|
|
@@ -2961,7 +2982,6 @@ const consistentVariantOrder = defineRule({
|
|
|
2961
2982
|
const dsPriority = dsCache.getVariantPriority(variant);
|
|
2962
2983
|
if (dsPriority !== null) return dsPriority;
|
|
2963
2984
|
}
|
|
2964
|
-
if (variant.startsWith("[")) return -1;
|
|
2965
2985
|
return fallbackPriority;
|
|
2966
2986
|
}
|
|
2967
2987
|
function reorderClass(cls) {
|