oxlint-tailwindcss 1.0.1 → 1.2.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 +149 -54
- package/dist/index.cjs +146 -34
- package/dist/index.mjs +146 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -10
package/README.md
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
1
1
|
# oxlint-tailwindcss
|
|
2
2
|
|
|
3
|
-
23 Tailwind CSS linting rules for [oxlint](https://oxc.rs/docs/guide/usage/linter). Built for
|
|
3
|
+
23 Tailwind CSS linting rules for [oxlint](https://oxc.rs/docs/guide/usage/linter). Built for
|
|
4
|
+
Tailwind CSS v4 with deterministic config, typo suggestions, and autofixes.
|
|
4
5
|
|
|
5
|
-
> **v1.0.0** — Upgrading from v0.x? See the
|
|
6
|
+
> **v1.0.0** — Upgrading from v0.x? See the
|
|
7
|
+
> **[migration guide](https://oxlint-tailwindcss.pages.dev/migration/v0-to-v1)**. The headline
|
|
8
|
+
> change: `settings.tailwindcss.entryPoint` is now required.
|
|
6
9
|
|
|
7
|
-
Read the story behind this plugin:
|
|
10
|
+
Read the story behind this plugin:
|
|
11
|
+
[oxlint-tailwindcss: The Linting Plugin Tailwind v4 Needed](https://sergioazocar.com/en/blog/oxlint-tailwindcss-the-linting-plugin-tailwind-v4-needed)
|
|
8
12
|
|
|
9
13
|
## Highlights
|
|
10
14
|
|
|
11
|
-
- **Configure once, never fails** — `settings.tailwindcss.entryPoint` is explicit. Same input → same
|
|
12
|
-
|
|
13
|
-
- **
|
|
14
|
-
|
|
15
|
-
- **
|
|
16
|
-
-
|
|
15
|
+
- **Configure once, never fails** — `settings.tailwindcss.entryPoint` is explicit. Same input → same
|
|
16
|
+
output on every machine.
|
|
17
|
+
- **Monorepo-ready** — Single root config with a glob → CSS mapping array, or one `.oxlintrc.json`
|
|
18
|
+
per package. Both fully deterministic.
|
|
19
|
+
- **Coexists with oxfmt and Prettier** — Point all tools at the same CSS and they agree
|
|
20
|
+
byte-for-byte. See the [interop guide](https://oxlint-tailwindcss.pages.dev/interop).
|
|
21
|
+
- **Tailwind CSS v4** — Designed for v4 from day one. Reads your `@theme { ... }` custom tokens,
|
|
22
|
+
your shadcn variables, your typography plugin.
|
|
23
|
+
- **Fail loud** — Misconfiguration surfaces as a single `designSystemUnavailable` diagnostic with an
|
|
24
|
+
actionable hint. Never silently skipped rules.
|
|
25
|
+
- **Fast** — Native oxlint plugin with per-entry-point caching and content-hash disk cache for
|
|
26
|
+
monorepo deduplication.
|
|
17
27
|
- **Typo suggestions** — `itms-center` → "Did you mean `items-center`?"
|
|
18
28
|
- **Conflict detection** — Shows exactly which CSS properties conflict and which class wins.
|
|
19
29
|
- **Lightweight** — Only 2 runtime dependencies: `@tailwindcss/node` and `tailwindcss`.
|
|
20
|
-
- **23 rules** — Correctness, style, complexity, and restriction rules with autofixes where
|
|
30
|
+
- **23 rules** — Correctness, style, complexity, and restriction rules with autofixes where
|
|
31
|
+
possible.
|
|
21
32
|
- **Variable detection** — Lints variables named `className`, `classes`, `style` automatically.
|
|
22
|
-
- **Customizable** — Extend class detection with custom attributes, callees, tags, and variable
|
|
33
|
+
- **Customizable** — Extend class detection with custom attributes, callees, tags, and variable
|
|
34
|
+
patterns.
|
|
23
35
|
- **Component class support** — Recognizes `@layer components { .btn {} }` in your CSS.
|
|
24
36
|
|
|
25
|
-
Full documentation: **https://oxlint-tailwindcss.pages.dev** (English) ·
|
|
37
|
+
Full documentation: **https://oxlint-tailwindcss.pages.dev** (English) ·
|
|
38
|
+
**https://oxlint-tailwindcss.pages.dev/es** (Español)
|
|
26
39
|
|
|
27
40
|
## Installation
|
|
28
41
|
|
|
@@ -86,13 +99,15 @@ Declare your Tailwind CSS entry point in `settings.tailwindcss.entryPoint`:
|
|
|
86
99
|
}
|
|
87
100
|
```
|
|
88
101
|
|
|
89
|
-
That's the only required setting. The plugin loads your design system from that file once and shares
|
|
102
|
+
That's the only required setting. The plugin loads your design system from that file once and shares
|
|
103
|
+
it across every rule.
|
|
90
104
|
|
|
91
105
|
### Monorepos
|
|
92
106
|
|
|
93
107
|
Two patterns, both fully deterministic:
|
|
94
108
|
|
|
95
|
-
**Pattern A — single root config with a glob → CSS mapping.** First match wins, evaluation in array
|
|
109
|
+
**Pattern A — single root config with a glob → CSS mapping.** First match wins, evaluation in array
|
|
110
|
+
order:
|
|
96
111
|
|
|
97
112
|
```jsonc
|
|
98
113
|
{
|
|
@@ -108,7 +123,8 @@ Two patterns, both fully deterministic:
|
|
|
108
123
|
}
|
|
109
124
|
```
|
|
110
125
|
|
|
111
|
-
**Pattern B — one `.oxlintrc.json` per package**, each with its own string `entryPoint`. oxlint
|
|
126
|
+
**Pattern B — one `.oxlintrc.json` per package**, each with its own string `entryPoint`. oxlint
|
|
127
|
+
resolves the closest config to the file being linted.
|
|
112
128
|
|
|
113
129
|
See the full [monorepo guide](https://oxlint-tailwindcss.pages.dev/monorepo) for examples of both.
|
|
114
130
|
|
|
@@ -124,7 +140,9 @@ You can also override per rule if needed:
|
|
|
124
140
|
}
|
|
125
141
|
```
|
|
126
142
|
|
|
127
|
-
Resolution order: rule option > `settings.tailwindcss.entryPoint`. If neither resolves a CSS file,
|
|
143
|
+
Resolution order: rule option > `settings.tailwindcss.entryPoint`. If neither resolves a CSS file,
|
|
144
|
+
DS-dependent rules emit a single `designSystemUnavailable` diagnostic per file (with the migration
|
|
145
|
+
hint inline). v1.0.0 removed the filesystem auto-detect — explicit `entryPoint` is mandatory.
|
|
128
146
|
|
|
129
147
|
### Timeout
|
|
130
148
|
|
|
@@ -142,7 +160,8 @@ For slow environments (large monorepos, CI), you can increase the design system
|
|
|
142
160
|
|
|
143
161
|
### Root font size
|
|
144
162
|
|
|
145
|
-
The `enforce-canonical` rule converts px-based arbitrary values to named classes (e.g. `p-[2px]` →
|
|
163
|
+
The `enforce-canonical` rule converts px-based arbitrary values to named classes (e.g. `p-[2px]` →
|
|
164
|
+
`p-0.5`). This conversion depends on the root font size:
|
|
146
165
|
|
|
147
166
|
```jsonc
|
|
148
167
|
{
|
|
@@ -182,13 +201,21 @@ Output:
|
|
|
182
201
|
[oxlint-tailwindcss] packages/admin/src/Dashboard.tsx → packages/admin/src/styles.css
|
|
183
202
|
```
|
|
184
203
|
|
|
185
|
-
If no entry point is configured, the DS-dependent rules (`no-unknown-classes`,
|
|
204
|
+
If no entry point is configured, the DS-dependent rules (`no-unknown-classes`,
|
|
205
|
+
`no-conflicting-classes`, `no-deprecated-classes`, `enforce-canonical`, `enforce-sort-order`,
|
|
206
|
+
`no-unnecessary-arbitrary-value`, `prefer-theme-tokens`) emit a single `designSystemUnavailable`
|
|
207
|
+
diagnostic per file with an actionable hint — no more silent skips. `consistent-variant-order` is
|
|
208
|
+
the lone exception: its static fallback is itself deterministic, so a missing entryPoint is
|
|
209
|
+
tolerated there. All non-DS rules work without an entry point.
|
|
186
210
|
|
|
187
211
|
## Custom class detection
|
|
188
212
|
|
|
189
|
-
By default the plugin detects Tailwind classes in `className`/`class` attributes, 14 utility
|
|
213
|
+
By default the plugin detects Tailwind classes in `className`/`class` attributes, 14 utility
|
|
214
|
+
functions (`cn`, `clsx`, `cva`, `tv`, `classed`, etc.), `tw` tagged templates, and variables named
|
|
215
|
+
`className`/`classes`/`style`.
|
|
190
216
|
|
|
191
|
-
You can extend these defaults via `settings.tailwindcss`. All values are **additive** — your custom
|
|
217
|
+
You can extend these defaults via `settings.tailwindcss`. All values are **additive** — your custom
|
|
218
|
+
entries are appended to the built-in defaults:
|
|
192
219
|
|
|
193
220
|
```jsonc
|
|
194
221
|
{
|
|
@@ -212,7 +239,8 @@ You can extend these defaults via `settings.tailwindcss`. All values are **addit
|
|
|
212
239
|
}
|
|
213
240
|
```
|
|
214
241
|
|
|
215
|
-
This applies to all 23 rules at once. For example, adding `"classNames"` to `attributes` makes every
|
|
242
|
+
This applies to all 23 rules at once. For example, adding `"classNames"` to `attributes` makes every
|
|
243
|
+
rule lint `<Input classNames={{ root: "..." }} />`.
|
|
216
244
|
|
|
217
245
|
To **remove** specific items from the built-in defaults, use `exclude`:
|
|
218
246
|
|
|
@@ -231,7 +259,8 @@ To **remove** specific items from the built-in defaults, use `exclude`:
|
|
|
231
259
|
}
|
|
232
260
|
```
|
|
233
261
|
|
|
234
|
-
For `variablePatterns`, exclusions match against the regex source (e.g. `"^styles?$"` removes the
|
|
262
|
+
For `variablePatterns`, exclusions match against the regex source (e.g. `"^styles?$"` removes the
|
|
263
|
+
default `/^styles?$/` pattern).
|
|
235
264
|
|
|
236
265
|
## Supported patterns
|
|
237
266
|
|
|
@@ -329,7 +358,8 @@ Reports classes not recognized by Tailwind CSS. Includes typo suggestions.
|
|
|
329
358
|
|
|
330
359
|
#### `no-duplicate-classes`
|
|
331
360
|
|
|
332
|
-
Detects repeated classes in the same string. `hover:flex` and `focus:flex` are **not** considered
|
|
361
|
+
Detects repeated classes in the same string. `hover:flex` and `focus:flex` are **not** considered
|
|
362
|
+
duplicates (different variants).
|
|
333
363
|
|
|
334
364
|
```tsx
|
|
335
365
|
// ❌ Bad
|
|
@@ -345,7 +375,8 @@ Detects repeated classes in the same string. `hover:flex` and `focus:flex` are *
|
|
|
345
375
|
|
|
346
376
|
#### `no-conflicting-classes`
|
|
347
377
|
|
|
348
|
-
Detects classes that set the same CSS property. Reports which property conflicts and which class
|
|
378
|
+
Detects classes that set the same CSS property. Reports which property conflicts and which class
|
|
379
|
+
wins.
|
|
349
380
|
|
|
350
381
|
```tsx
|
|
351
382
|
// ❌ Bad
|
|
@@ -357,7 +388,8 @@ Detects classes that set the same CSS property. Reports which property conflicts
|
|
|
357
388
|
// "mt-2" and "mt-4" affect "margin-top".
|
|
358
389
|
```
|
|
359
390
|
|
|
360
|
-
> **Note:** Shorthand vs longhand conflicts (e.g., `p-4` vs `px-2`) are not currently detected. See
|
|
391
|
+
> **Note:** Shorthand vs longhand conflicts (e.g., `p-4` vs `px-2`) are not currently detected. See
|
|
392
|
+
> [Known limitations](#known-limitations).
|
|
361
393
|
|
|
362
394
|
**Requires design system.** No autofix.
|
|
363
395
|
|
|
@@ -422,7 +454,8 @@ Requires a base (light) utility when using the `dark:` variant on the same eleme
|
|
|
422
454
|
<div className="text-black dark:text-white" />
|
|
423
455
|
```
|
|
424
456
|
|
|
425
|
-
Groups by utility prefix (`bg-`, `text-`, `border-`, etc.) — only checks that a base utility of the
|
|
457
|
+
Groups by utility prefix (`bg-`, `text-`, `border-`, etc.) — only checks that a base utility of the
|
|
458
|
+
same type exists.
|
|
426
459
|
|
|
427
460
|
**Options:**
|
|
428
461
|
|
|
@@ -436,7 +469,8 @@ Groups by utility prefix (`bg-`, `text-`, `border-`, etc.) — only checks that
|
|
|
436
469
|
|
|
437
470
|
#### `no-contradicting-variants`
|
|
438
471
|
|
|
439
|
-
Detects variant-prefixed classes that are redundant because the base class already applies
|
|
472
|
+
Detects variant-prefixed classes that are redundant because the base class already applies
|
|
473
|
+
unconditionally.
|
|
440
474
|
|
|
441
475
|
```tsx
|
|
442
476
|
// ❌ Bad — dark:flex is redundant because flex already applies always
|
|
@@ -450,7 +484,9 @@ Detects variant-prefixed classes that are redundant because the base class alrea
|
|
|
450
484
|
<div className="shrink-0 [&>svg]:shrink-0" />
|
|
451
485
|
```
|
|
452
486
|
|
|
453
|
-
Only flags when the exact same utility exists both as base and with a conditional variant. Variants
|
|
487
|
+
Only flags when the exact same utility exists both as base and with a conditional variant. Variants
|
|
488
|
+
that change the selector target (pseudo-elements, child/descendant selectors, arbitrary selectors)
|
|
489
|
+
are not flagged.
|
|
454
490
|
|
|
455
491
|
**No options.** **No autofix.**
|
|
456
492
|
|
|
@@ -460,7 +496,8 @@ Only flags when the exact same utility exists both as base and with a conditiona
|
|
|
460
496
|
|
|
461
497
|
#### `enforce-canonical`
|
|
462
498
|
|
|
463
|
-
Enforces canonical Tailwind CSS class names. Uses `canonicalizeCandidates()` from the Tailwind CSS
|
|
499
|
+
Enforces canonical Tailwind CSS class names. Uses `canonicalizeCandidates()` from the Tailwind CSS
|
|
500
|
+
engine dynamically — the same API that powers Tailwind CSS IntelliSense's `suggestCanonicalClasses`.
|
|
464
501
|
|
|
465
502
|
```tsx
|
|
466
503
|
// ❌ Bad → ✅ Fixed
|
|
@@ -480,7 +517,10 @@ The px→named conversion (e.g. `p-[2px]` → `p-0.5`) depends on `rootFontSize`
|
|
|
480
517
|
|
|
481
518
|
#### `enforce-sort-order`
|
|
482
519
|
|
|
483
|
-
Sorts classes according to Tailwind's official class order — identical to
|
|
520
|
+
Sorts classes according to Tailwind's official class order — identical to
|
|
521
|
+
[oxfmt](https://oxc.rs/docs/guide/usage/formatter) and
|
|
522
|
+
[prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss). Uses
|
|
523
|
+
`ds.getClassOrder()` from the Tailwind CSS engine for exact results.
|
|
484
524
|
|
|
485
525
|
```tsx
|
|
486
526
|
// ❌ Bad
|
|
@@ -490,7 +530,8 @@ Sorts classes according to Tailwind's official class order — identical to [oxf
|
|
|
490
530
|
<div className="flex items-center p-4 text-red-500" />
|
|
491
531
|
```
|
|
492
532
|
|
|
493
|
-
In `strict` mode, classes are grouped by variant prefix, sorted within each group by DS sort order,
|
|
533
|
+
In `strict` mode, classes are grouped by variant prefix, sorted within each group by DS sort order,
|
|
534
|
+
and groups are ordered: no-variant first, then by variant priority.
|
|
494
535
|
|
|
495
536
|
```tsx
|
|
496
537
|
// ❌ Bad (strict mode)
|
|
@@ -522,6 +563,8 @@ Suggests shorthand classes when all axes have the same value.
|
|
|
522
563
|
"pt-4 pr-4 pb-4 pl-4" → "p-4"
|
|
523
564
|
"pt-4 pb-4" → "py-4"
|
|
524
565
|
"pl-4 pr-4" → "px-4"
|
|
566
|
+
"px-4 py-4" → "p-4"
|
|
567
|
+
"mx-2 my-2" → "m-2"
|
|
525
568
|
"w-full h-full" → "size-full"
|
|
526
569
|
"rounded-tl-lg rounded-tr-lg rounded-br-lg rounded-bl-lg" → "rounded-lg"
|
|
527
570
|
```
|
|
@@ -544,7 +587,8 @@ Converts physical properties to logical ones for LTR/RTL support.
|
|
|
544
587
|
"right-0" → "end-0"
|
|
545
588
|
```
|
|
546
589
|
|
|
547
|
-
Also converts `border-l/r`, `rounded-l/r/tl/tr/bl/br`, and `scroll-ml/mr/pl/pr` to their logical
|
|
590
|
+
Also converts `border-l/r`, `rounded-l/r/tl/tr/bl/br`, and `scroll-ml/mr/pl/pr` to their logical
|
|
591
|
+
equivalents.
|
|
548
592
|
|
|
549
593
|
**Autofix:** Replaces with logical equivalent.
|
|
550
594
|
|
|
@@ -552,7 +596,8 @@ Also converts `border-l/r`, `rounded-l/r/tl/tr/bl/br`, and `scroll-ml/mr/pl/pr`
|
|
|
552
596
|
|
|
553
597
|
#### `enforce-physical`
|
|
554
598
|
|
|
555
|
-
The inverse of `enforce-logical`. Converts logical properties back to physical ones for consistency
|
|
599
|
+
The inverse of `enforce-logical`. Converts logical properties back to physical ones for consistency
|
|
600
|
+
in LTR-only projects.
|
|
556
601
|
|
|
557
602
|
```tsx
|
|
558
603
|
// ❌ Bad → ✅ Fixed
|
|
@@ -590,7 +635,9 @@ Handles variants correctly — the `!` is placed on the utility, not the variant
|
|
|
590
635
|
| ---------- | ------------------------ | ---------- | ------------------------------- |
|
|
591
636
|
| `position` | `"prefix"` \| `"suffix"` | `"suffix"` | Where to place the `!` modifier |
|
|
592
637
|
|
|
593
|
-
> **Note:** The default is `"suffix"` to match Tailwind CSS v4's canonical form. The prefix form
|
|
638
|
+
> **Note:** The default is `"suffix"` to match Tailwind CSS v4's canonical form. The prefix form
|
|
639
|
+
> (`!flex`) is deprecated in v4. Using `"prefix"` may conflict with `enforce-canonical`, which also
|
|
640
|
+
> normalizes `!` to the suffix position.
|
|
594
641
|
|
|
595
642
|
**Autofix:** Moves `!` to the correct position.
|
|
596
643
|
|
|
@@ -618,7 +665,8 @@ Moves the negative sign inside arbitrary value brackets for consistency.
|
|
|
618
665
|
|
|
619
666
|
#### `enforce-consistent-variable-syntax`
|
|
620
667
|
|
|
621
|
-
Enforces consistent CSS variable syntax between Tailwind v4 shorthand `bg-(--var)` and explicit
|
|
668
|
+
Enforces consistent CSS variable syntax between Tailwind v4 shorthand `bg-(--var)` and explicit
|
|
669
|
+
`bg-[var(--var)]`.
|
|
622
670
|
|
|
623
671
|
```tsx
|
|
624
672
|
// ❌ Bad (default: shorthand)
|
|
@@ -651,7 +699,11 @@ Does NOT convert complex expressions — only simple `var(--name)` wrappers:
|
|
|
651
699
|
|
|
652
700
|
Enforces a consistent order for variant prefixes.
|
|
653
701
|
|
|
654
|
-
Uses the design system's variant order when available, falls back to a sensible static default. Only
|
|
702
|
+
Uses the design system's variant order when available, falls back to a sensible static default. Only
|
|
703
|
+
checks classes with 2+ variants. Pseudo-element variants (`before:`, `after:`, `placeholder:`, etc.)
|
|
704
|
+
are always kept innermost (closest to the utility) regardless of the ordering source — placing them
|
|
705
|
+
before element-selecting variants like `[&>svg]:` or `has-[.active]:` produces broken CSS in
|
|
706
|
+
Tailwind v4.
|
|
655
707
|
|
|
656
708
|
**Options:**
|
|
657
709
|
|
|
@@ -667,7 +719,8 @@ Uses the design system's variant order when available, falls back to a sensible
|
|
|
667
719
|
|
|
668
720
|
#### `max-class-count`
|
|
669
721
|
|
|
670
|
-
Warns when an element has too many Tailwind classes, suggesting extraction into a component or
|
|
722
|
+
Warns when an element has too many Tailwind classes, suggesting extraction into a component or
|
|
723
|
+
utility.
|
|
671
724
|
|
|
672
725
|
```tsx
|
|
673
726
|
// ❌ Bad (with default max: 20)
|
|
@@ -741,7 +794,8 @@ Blocks specific Tailwind classes by exact name or regex pattern with optional cu
|
|
|
741
794
|
|
|
742
795
|
#### `no-arbitrary-value`
|
|
743
796
|
|
|
744
|
-
Prohibits arbitrary values (`[...]`) in Tailwind classes. Useful for teams that want to enforce
|
|
797
|
+
Prohibits arbitrary values (`[...]`) in Tailwind classes. Useful for teams that want to enforce
|
|
798
|
+
strict design system adherence.
|
|
745
799
|
|
|
746
800
|
```tsx
|
|
747
801
|
// ❌ Bad
|
|
@@ -779,7 +833,9 @@ Flags hardcoded color values in arbitrary brackets. Encourages use of design tok
|
|
|
779
833
|
<div className="tracking-[0.5em]" />
|
|
780
834
|
```
|
|
781
835
|
|
|
782
|
-
Detects hex, rgb/rgba, hsl/hsla, oklch, oklab, and other color function values inside `[...]` on
|
|
836
|
+
Detects hex, rgb/rgba, hsl/hsla, oklch, oklab, and other color function values inside `[...]` on
|
|
837
|
+
color-related utility prefixes (`bg-`, `text-`, `border-`, `ring-`, `shadow-`, `fill-`, `stroke-`,
|
|
838
|
+
etc.).
|
|
783
839
|
|
|
784
840
|
**Options:**
|
|
785
841
|
|
|
@@ -793,7 +849,8 @@ Detects hex, rgb/rgba, hsl/hsla, oklch, oklab, and other color function values i
|
|
|
793
849
|
|
|
794
850
|
#### `no-unnecessary-arbitrary-value`
|
|
795
851
|
|
|
796
|
-
Detects arbitrary values that have a named Tailwind equivalent. The arbitrary form produces the
|
|
852
|
+
Detects arbitrary values that have a named Tailwind equivalent. The arbitrary form produces the
|
|
853
|
+
exact same CSS, so the named class is preferred.
|
|
797
854
|
|
|
798
855
|
```tsx
|
|
799
856
|
// ❌ Bad → ✅ Fixed
|
|
@@ -811,9 +868,17 @@ Detects arbitrary values that have a named Tailwind equivalent. The arbitrary fo
|
|
|
811
868
|
|
|
812
869
|
#### `prefer-theme-tokens`
|
|
813
870
|
|
|
814
|
-
Suggests replacing raw CSS variable references like `border-(--border)` or `bg-[var(--primary)]`
|
|
871
|
+
Suggests replacing raw CSS variable references like `border-(--border)` or `bg-[var(--primary)]`
|
|
872
|
+
with the equivalent named theme-token utility (`border-border`, `bg-primary`) when one exists in
|
|
873
|
+
your design system.
|
|
815
874
|
|
|
816
|
-
Unlike `no-unnecessary-arbitrary-value`, this rule fires even when the named utility produces
|
|
875
|
+
Unlike `no-unnecessary-arbitrary-value`, this rule fires even when the named utility produces
|
|
876
|
+
_different_ CSS — for example, in themes that wrap the raw variable in a color function
|
|
877
|
+
(`--color-border: hsl(var(--border))`). Useful to match the official Tailwind VS Code extension's
|
|
878
|
+
`suggestCanonicalClasses` behavior. **Off by default** because the replacement may change observable
|
|
879
|
+
CSS in those setups. (When the theme exposes the variable directly with no wrapping function,
|
|
880
|
+
`border-[var(--border)]` is CSS-equivalent to `border-border` and is owned by
|
|
881
|
+
`no-unnecessary-arbitrary-value` instead.)
|
|
817
882
|
|
|
818
883
|
```tsx
|
|
819
884
|
// ❌ Bad → ✅ Fixed (when border-border is a valid utility)
|
|
@@ -840,21 +905,51 @@ The class parser correctly handles:
|
|
|
840
905
|
|
|
841
906
|
## Known limitations
|
|
842
907
|
|
|
843
|
-
- **`enforce-canonical`**: Named classes are canonicalized via the precomputed map (covers
|
|
844
|
-
|
|
845
|
-
-
|
|
846
|
-
|
|
847
|
-
|
|
908
|
+
- **`enforce-canonical`**: Named classes are canonicalized via the precomputed map (covers
|
|
909
|
+
everything in `getClassList()` plus a curated list of legacy v3 spellings like `break-words`,
|
|
910
|
+
`flex-grow`, `start-N`, `bg-gradient-to-*`). Arbitrary/CSS-var forms (`p-[2px]`, `bg-(--c)`) are
|
|
911
|
+
canonicalized dynamically via the worker. Some valid v4 classes that don't appear in
|
|
912
|
+
`getClassList()` and have no canonical rewrite (e.g. `border-1` is valid as a dynamic numeric
|
|
913
|
+
value but isn't enumerated) are left untouched.
|
|
914
|
+
- **`no-conflicting-classes`**: Uses exact CSS property name matching plus composition heuristics:
|
|
915
|
+
CSS-var composition (`shadow` + `ring`), narrowing-override (later class is a strict subset of
|
|
916
|
+
earlier — handles `size-4 h-6`, `rounded-t-lg rounded-tl-sm`, `truncate text-clip`), complementary
|
|
917
|
+
groups (gradient stops, transition family, transform axes, mask gradient family across
|
|
918
|
+
edges/axes/`linear`/`radial`/`conic`), and composition pairs (e.g. `mask-add` + any mask
|
|
919
|
+
gradient). Shorthand vs longhand cases where Tailwind emits the shorthand and Tailwind's longhand
|
|
920
|
+
has a different CSS property name (e.g., `p-4` vs `px-2`: `padding` vs
|
|
921
|
+
`padding-left`/`padding-right`) are still not detected.
|
|
922
|
+
- **`no-dark-without-light`**: Groups by utility prefix heuristic. May not perfectly match all
|
|
923
|
+
multi-part utility prefixes.
|
|
924
|
+
- **`no-unnecessary-arbitrary-value`**: Only detects equivalences for classes with a single CSS
|
|
925
|
+
property. Multi-property utilities may have arbitrary forms that aren't detected.
|
|
926
|
+
- **Component classes**: Only first-level `@import` relative paths are followed. Deeply nested
|
|
927
|
+
imports or absolute paths are not resolved.
|
|
848
928
|
|
|
849
929
|
## Supported plugins
|
|
850
930
|
|
|
851
|
-
The plugin loads classes through `@tailwindcss/node`, so any plugin imported into your CSS entry
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
- **[`
|
|
856
|
-
|
|
857
|
-
|
|
931
|
+
The plugin loads classes through `@tailwindcss/node`, so any plugin imported into your CSS entry
|
|
932
|
+
point — `@plugin '...'` or `@import '...'` — is recognized automatically by every rule. The
|
|
933
|
+
following are exercised by the test suite:
|
|
934
|
+
|
|
935
|
+
- **[`@tailwindcss/typography`](https://github.com/tailwindlabs/tailwindcss-typography)** — `prose`,
|
|
936
|
+
`prose-sm/lg/xl`, `not-prose`. `no-conflicting-classes` extracts only root-level CSS properties
|
|
937
|
+
from `prose`, so utilities like `prose overflow-x-auto` aren't reported as conflicts.
|
|
938
|
+
- **[`tailwindcss-animate`](https://github.com/jamiebuilds/tailwindcss-animate)** — `animate-in`,
|
|
939
|
+
`animate-out`, `fade-{in,out}-*`, `zoom-{in,out}-*`, `spin-{in,out}-*`,
|
|
940
|
+
`slide-{in-from,out-to}-*`, `duration-*`, `delay-*`, `ease-*`, `direction-*`, `fill-mode-*`,
|
|
941
|
+
`repeat-*`, `running`, `paused`. `animate-in`/`animate-out` initialize all `--tw-enter-*` /
|
|
942
|
+
`--tw-exit-*` custom properties to `initial`, and modifiers (`fade-in`, `zoom-in`,
|
|
943
|
+
`slide-in-from-*`, etc.) each override one of them; this composition is recognized by
|
|
944
|
+
`no-conflicting-classes`.
|
|
945
|
+
- **[`tw-animate-css`](https://github.com/Wombosvideo/tw-animate-css)** — v4-native rewrite of
|
|
946
|
+
`tailwindcss-animate`. Adds `blur-{in,out}-*`, logical (RTL-aware)
|
|
947
|
+
`slide-{in-from,out-to}-{start,end}-*`, `play-state-*`, `animation-duration-*`, and the
|
|
948
|
+
`animate-accordion-{up,down}` / `animate-collapsible-{up,down}` / `animate-caret-blink` keyframe
|
|
949
|
+
animations used by Radix-style headless component libraries.
|
|
950
|
+
|
|
951
|
+
Other plugins that emit classes through standard `getClassList()` and CSS output should work out of
|
|
952
|
+
the box. If you find one that doesn't, open an issue.
|
|
858
953
|
|
|
859
954
|
## Requirements
|
|
860
955
|
|