oxlint-tailwindcss 0.1.3 → 0.1.5
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 +42 -74
- package/dist/index.cjs +290 -112
- package/dist/index.mjs +290 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,16 +64,35 @@ The plugin auto-detects your Tailwind CSS entry point. No configuration needed i
|
|
|
64
64
|
The plugin searches for a CSS file containing a Tailwind import signal (`@import "tailwindcss"`, `@import 'tailwindcss'`, `@import tailwindcss`, `@tailwind base`) in these locations, walking upward from the linted file:
|
|
65
65
|
|
|
66
66
|
```
|
|
67
|
-
src/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
style.css styles/globals.css app/globals.css
|
|
71
|
-
assets/css/tailwind.css
|
|
67
|
+
src/{name}.css {name}.css app/{name}.css
|
|
68
|
+
styles/{name}.css style/{name}.css css/{name}.css
|
|
69
|
+
assets/{name}.css assets/css/{name}.css resources/css/{name}.css
|
|
72
70
|
```
|
|
73
71
|
|
|
72
|
+
Where `{name}` is one of: `app`, `globals`, `global`, `style`, `styles`, `index`, `main`, `tailwind`, `tailwindcss`.
|
|
73
|
+
|
|
74
74
|
The search is monorepo-aware — it stops at `package.json` boundaries so each package resolves its own Tailwind config.
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
If auto-detection doesn't find your CSS file, set `entryPoint` once in `settings`:
|
|
77
|
+
|
|
78
|
+
```jsonc
|
|
79
|
+
{
|
|
80
|
+
"jsPlugins": ["oxlint-tailwindcss"],
|
|
81
|
+
"settings": {
|
|
82
|
+
"tailwindcss": {
|
|
83
|
+
"entryPoint": "app/tailwind.css",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
"rules": {
|
|
87
|
+
"tailwindcss/no-unknown-classes": "error",
|
|
88
|
+
// ...
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The design system is loaded once and shared across all rules.
|
|
94
|
+
|
|
95
|
+
You can also override per rule if needed:
|
|
77
96
|
|
|
78
97
|
```jsonc
|
|
79
98
|
{
|
|
@@ -83,6 +102,10 @@ To override auto-detection, pass `entryPoint` as an option:
|
|
|
83
102
|
}
|
|
84
103
|
```
|
|
85
104
|
|
|
105
|
+
Resolution order: rule option > `settings.tailwindcss.entryPoint` > auto-detect.
|
|
106
|
+
|
|
107
|
+
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.
|
|
108
|
+
|
|
86
109
|
## Supported patterns
|
|
87
110
|
|
|
88
111
|
The plugin extracts Tailwind classes from:
|
|
@@ -98,18 +121,10 @@ The plugin extracts Tailwind classes from:
|
|
|
98
121
|
// Ternaries
|
|
99
122
|
<div className={active ? "bg-blue-500" : "bg-gray-200"} />
|
|
100
123
|
|
|
101
|
-
// Utility functions
|
|
124
|
+
// Utility functions (cn, clsx, cx, cva, twMerge, twJoin, classnames, ctl, cc, clb, cnb, objstr)
|
|
102
125
|
cn("flex items-center", condition && "hidden")
|
|
103
126
|
clsx("flex", { "bg-red-500": isError })
|
|
104
127
|
twMerge("p-4", "p-2")
|
|
105
|
-
cx("flex", "items-center")
|
|
106
|
-
classnames("flex", "items-center")
|
|
107
|
-
ctl("flex items-center")
|
|
108
|
-
twJoin("flex", "items-center")
|
|
109
|
-
cc("flex", "items-center")
|
|
110
|
-
clb("flex", "items-center")
|
|
111
|
-
cnb("flex", "items-center")
|
|
112
|
-
objstr({ "flex": true, "items-center": true })
|
|
113
128
|
|
|
114
129
|
// cva() — full extraction: base, variants, compoundVariants
|
|
115
130
|
cva("flex items-center", {
|
|
@@ -164,7 +179,6 @@ Reports classes not recognized by Tailwind CSS. Includes typo suggestions.
|
|
|
164
179
|
|
|
165
180
|
| Option | Type | Description |
|
|
166
181
|
| ---------------- | ---------- | ------------------------------------- |
|
|
167
|
-
| `entryPoint` | `string` | Path to Tailwind CSS entry file |
|
|
168
182
|
| `allowlist` | `string[]` | Custom classes to allow |
|
|
169
183
|
| `ignorePrefixes` | `string[]` | Prefixes to ignore (e.g. `["data-"]`) |
|
|
170
184
|
|
|
@@ -204,12 +218,6 @@ Detects classes that set the same CSS property. Reports which property conflicts
|
|
|
204
218
|
|
|
205
219
|
> **Note:** Shorthand vs longhand conflicts (e.g., `p-4` vs `px-2`) are not currently detected. See [Known limitations](#known-limitations).
|
|
206
220
|
|
|
207
|
-
**Options:**
|
|
208
|
-
|
|
209
|
-
| Option | Type | Description |
|
|
210
|
-
| ------------ | -------- | ------------------------------- |
|
|
211
|
-
| `entryPoint` | `string` | Path to Tailwind CSS entry file |
|
|
212
|
-
|
|
213
221
|
**Requires design system.** No autofix.
|
|
214
222
|
|
|
215
223
|
---
|
|
@@ -294,21 +302,14 @@ Detects variant-prefixed classes that are redundant because the base class alrea
|
|
|
294
302
|
<div className="flex dark:flex" />
|
|
295
303
|
<div className="hidden hover:hidden" />
|
|
296
304
|
|
|
297
|
-
// ✅ OK — different values,
|
|
305
|
+
// ✅ OK — different values, both conditional, or different selector targets
|
|
298
306
|
<div className="text-white dark:text-black" />
|
|
299
|
-
<div className="bg-white hover:bg-blue-500" />
|
|
300
|
-
|
|
301
|
-
// ✅ OK — no base class, both are conditional
|
|
302
307
|
<div className="hover:flex dark:flex" />
|
|
303
|
-
|
|
304
|
-
// ✅ OK — pseudo-elements and child selectors target different elements
|
|
305
308
|
<div className="absolute after:absolute" />
|
|
306
309
|
<div className="shrink-0 [&>svg]:shrink-0" />
|
|
307
|
-
<div className="bg-transparent file:bg-transparent" />
|
|
308
|
-
<div className="flex *:data-[slot=value]:flex" />
|
|
309
310
|
```
|
|
310
311
|
|
|
311
|
-
Only
|
|
312
|
+
Only flags when the exact same utility exists both as base and with a conditional variant. Variants that change the selector target (pseudo-elements, child/descendant selectors, arbitrary selectors) are not flagged.
|
|
312
313
|
|
|
313
314
|
**No options.** **No autofix.**
|
|
314
315
|
|
|
@@ -327,12 +328,6 @@ Suggests the canonical form of a class when a shorter equivalent exists. Only kn
|
|
|
327
328
|
"-p-0" → "p-0"
|
|
328
329
|
```
|
|
329
330
|
|
|
330
|
-
**Options:**
|
|
331
|
-
|
|
332
|
-
| Option | Type | Description |
|
|
333
|
-
| ------------ | -------- | ------------------------------- |
|
|
334
|
-
| `entryPoint` | `string` | Path to Tailwind CSS entry file |
|
|
335
|
-
|
|
336
331
|
**Requires design system.** **Autofix:** Replaces with canonical form.
|
|
337
332
|
|
|
338
333
|
---
|
|
@@ -361,10 +356,9 @@ In `strict` mode, classes are grouped by variant prefix, sorted within each grou
|
|
|
361
356
|
|
|
362
357
|
**Options:**
|
|
363
358
|
|
|
364
|
-
| Option
|
|
365
|
-
|
|
|
366
|
-
| `
|
|
367
|
-
| `mode` | `"default"` \| `"strict"` | `"default"` | Sort mode |
|
|
359
|
+
| Option | Type | Default | Description |
|
|
360
|
+
| ------ | ------------------------- | ----------- | ----------- |
|
|
361
|
+
| `mode` | `"default"` \| `"strict"` | `"default"` | Sort mode |
|
|
368
362
|
|
|
369
363
|
**Requires design system.** **Autofix:** Reorders classes.
|
|
370
364
|
|
|
@@ -404,22 +398,7 @@ Converts physical properties to logical ones for LTR/RTL support.
|
|
|
404
398
|
"right-0" → "end-0"
|
|
405
399
|
```
|
|
406
400
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
| Physical | Logical |
|
|
410
|
-
| --------------------------- | --------------------------- |
|
|
411
|
-
| `ml` | `ms` |
|
|
412
|
-
| `mr` | `me` |
|
|
413
|
-
| `pl` | `ps` |
|
|
414
|
-
| `pr` | `pe` |
|
|
415
|
-
| `left` | `start` |
|
|
416
|
-
| `right` | `end` |
|
|
417
|
-
| `border-l` / `border-r` | `border-s` / `border-e` |
|
|
418
|
-
| `rounded-l` / `rounded-r` | `rounded-s` / `rounded-e` |
|
|
419
|
-
| `rounded-tl` / `rounded-tr` | `rounded-ss` / `rounded-se` |
|
|
420
|
-
| `rounded-bl` / `rounded-br` | `rounded-es` / `rounded-ee` |
|
|
421
|
-
| `scroll-ml` / `scroll-mr` | `scroll-ms` / `scroll-me` |
|
|
422
|
-
| `scroll-pl` / `scroll-pr` | `scroll-ps` / `scroll-pe` |
|
|
401
|
+
Also converts `border-l/r`, `rounded-l/r/tl/tr/bl/br`, and `scroll-ml/mr/pl/pr` to their logical equivalents.
|
|
423
402
|
|
|
424
403
|
**Autofix:** Replaces with logical equivalent.
|
|
425
404
|
|
|
@@ -506,18 +485,13 @@ Does NOT convert complex expressions — only simple `var(--name)` wrappers:
|
|
|
506
485
|
|
|
507
486
|
Enforces a consistent order for variant prefixes.
|
|
508
487
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
A user-specified `order` option always takes the highest priority, overriding both the design system and the static default.
|
|
512
|
-
|
|
513
|
-
Only checks classes with 2+ variants. Single-variant classes are always valid.
|
|
488
|
+
Uses the design system's variant order when available, falls back to a sensible static default. Only checks classes with 2+ variants.
|
|
514
489
|
|
|
515
490
|
**Options:**
|
|
516
491
|
|
|
517
|
-
| Option
|
|
518
|
-
|
|
|
519
|
-
| `
|
|
520
|
-
| `order` | `string[]` | (DS order or builtin order) | Custom variant priority list |
|
|
492
|
+
| Option | Type | Default | Description |
|
|
493
|
+
| ------- | ---------- | --------------------------- | ---------------------------- |
|
|
494
|
+
| `order` | `string[]` | (DS order or builtin order) | Custom variant priority list |
|
|
521
495
|
|
|
522
496
|
**Optionally uses design system.** **Autofix:** Reorders variants.
|
|
523
497
|
|
|
@@ -570,7 +544,7 @@ Warns when a class string exceeds the configured print width or classes-per-line
|
|
|
570
544
|
| `printWidth` | `number` | `80` | Max class string length |
|
|
571
545
|
| `classesPerLine` | `number` | | Max classes per line |
|
|
572
546
|
|
|
573
|
-
**
|
|
547
|
+
**Autofix:** Only for `classesPerLine` with template literals.
|
|
574
548
|
|
|
575
549
|
---
|
|
576
550
|
|
|
@@ -639,7 +613,7 @@ Flags hardcoded color values in arbitrary brackets. Encourages use of design tok
|
|
|
639
613
|
<div className="tracking-[0.5em]" />
|
|
640
614
|
```
|
|
641
615
|
|
|
642
|
-
Detects hex, rgb/rgba, hsl/hsla, oklch, oklab,
|
|
616
|
+
Detects hex, rgb/rgba, hsl/hsla, oklch, oklab, and other color function values inside `[...]` on color-related utility prefixes (`bg-`, `text-`, `border-`, `ring-`, `shadow-`, `fill-`, `stroke-`, etc.).
|
|
643
617
|
|
|
644
618
|
**Options:**
|
|
645
619
|
|
|
@@ -665,12 +639,6 @@ Detects arbitrary values that have a named Tailwind equivalent. The arbitrary fo
|
|
|
665
639
|
"bg-[#custom]"
|
|
666
640
|
```
|
|
667
641
|
|
|
668
|
-
**Options:**
|
|
669
|
-
|
|
670
|
-
| Option | Type | Description |
|
|
671
|
-
| ------------ | -------- | ------------------------------- |
|
|
672
|
-
| `entryPoint` | `string` | Path to Tailwind CSS entry file |
|
|
673
|
-
|
|
674
642
|
**Requires design system.** **Autofix:** Replaces with named class.
|
|
675
643
|
|
|
676
644
|
---
|