oxlint-tailwindcss 1.12.0 → 1.14.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.
Files changed (6) hide show
  1. package/README.md +104 -1046
  2. package/dist/index.cjs +3966 -1444
  3. package/dist/index.d.cts +3453 -3469
  4. package/dist/index.d.mts +3453 -3469
  5. package/dist/index.mjs +3966 -1445
  6. package/package.json +15 -8
package/README.md CHANGED
@@ -1,1084 +1,142 @@
1
1
  # oxlint-tailwindcss
2
2
 
3
- 24 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.
5
-
6
- > **v1** — 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.
9
-
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)
12
-
13
- ## Highlights
14
-
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.1+** — Designed for v4 from day one. Reads your `@theme { ... }` custom tokens,
22
- your shadcn variables, your typography plugin. It loads _your_ project's Tailwind engine, resolved
23
- per entry point, so the linter and your build agree; an engine older than v4.1, a future major, or
24
- a major-version drift from your build fails loud (opt back in with
25
- `settings.tailwindcss.allowUntestedEngine`).
26
- - **Fail loud** — Misconfiguration surfaces as a single `designSystemUnavailable` diagnostic with an
27
- actionable hint. Never silently skipped rules.
28
- - **Fast** — Native oxlint plugin with per-entry-point caching and content-hash disk cache for
29
- monorepo deduplication.
30
- - **Typo suggestions** — `itms-center` → "Did you mean `items-center`?"
31
- - **Conflict detection** — Shows exactly which CSS properties conflict and which class wins.
32
- - **Lightweight** — Only 2 runtime dependencies: `@tailwindcss/node` and `tailwindcss`.
33
- - **24 rules** — Correctness, style, complexity, and restriction rules with autofixes where
34
- possible.
35
- - **Variable detection** — Lints variables matching `/^classNames?$/`, `/^classes$/`, `/^styles?$/`
36
- (e.g. `className`, `classNames`, `classes`, `styles`) automatically.
37
- - **Customizable** — Extend class detection with custom attributes, attribute patterns (regex, for
38
- `*ClassName` props), callees, tags, and variable patterns.
39
- - **Component class support** — Recognizes `@layer components { .btn {} }` in your CSS.
40
-
41
- Full documentation: **https://oxlint-tailwindcss.pages.dev** (English) ·
42
- **https://oxlint-tailwindcss.pages.dev/es** (Español)
3
+ 27 lint rules for Tailwind CSS v4, for [oxlint](https://oxc.rs/docs/guide/usage/linter). They read
4
+ your own Tailwind build — your theme, your utilities, your plugins — so they know which classes
5
+ exist, which override each other, which are deprecated or have a canonical form, and which colors
6
+ are yours; most fix themselves.
7
+
8
+ **Docs: [oxlint-tailwindcss.pages.dev](https://oxlint-tailwindcss.pages.dev)** (English) ·
9
+ [/es](https://oxlint-tailwindcss.pages.dev/es) (Español) —
10
+ [setup](https://oxlint-tailwindcss.pages.dev/setup), every rule with examples,
11
+ [settings](https://oxlint-tailwindcss.pages.dev/settings),
12
+ [monorepos](https://oxlint-tailwindcss.pages.dev/monorepo),
13
+ [CI](https://oxlint-tailwindcss.pages.dev/ci), the
14
+ [benchmark](https://oxlint-tailwindcss.pages.dev/benchmark) and
15
+ [AI coding agents](https://oxlint-tailwindcss.pages.dev/ai-agents).
43
16
 
44
17
  ## Installation
45
18
 
46
19
  ```bash
47
- pnpm add -D oxlint-tailwindcss
20
+ npm install -D oxlint oxlint-tailwindcss
48
21
  ```
49
22
 
50
23
  ## Setup
51
24
 
52
- Add the plugin to your `.oxlintrc.json`:
25
+ Point the plugin at the CSS file with `@import "tailwindcss"` — `settings.tailwindcss.entryPoint`,
26
+ the one required setting — and list the rules you want: oxlint's `categories` don't turn on a JS
27
+ plugin's rules. This is every rule, at its recommended severity (`"off"` for the opt-in ones):
28
+
29
+ <!-- generated:full-config -->
53
30
 
54
31
  ```jsonc
55
32
  {
56
33
  "jsPlugins": ["oxlint-tailwindcss"],
34
+ "settings": {
35
+ "tailwindcss": {
36
+ "entryPoint": "src/styles.css"
37
+ }
38
+ },
57
39
  "rules": {
58
40
  // Correctness
59
- "tailwindcss/no-unknown-classes": "error",
60
- "tailwindcss/no-duplicate-classes": "error",
61
41
  "tailwindcss/no-conflicting-classes": "error",
62
- "tailwindcss/no-deprecated-classes": "error",
63
- "tailwindcss/no-unnecessary-whitespace": "error",
64
- // These two only inspect literal class lists on native elements; cn()/twMerge() fragments and custom-component classNames are skipped (issue #117).
65
- "tailwindcss/no-dark-without-light": "warn",
66
42
  "tailwindcss/no-contradicting-variants": "warn",
67
- // Style
43
+ "tailwindcss/no-dark-without-light": "warn",
44
+ "tailwindcss/no-duplicate-classes": "warn",
45
+ "tailwindcss/no-dynamic-classes": "error",
46
+ "tailwindcss/no-unknown-classes": "error",
47
+ // Modernization
68
48
  "tailwindcss/enforce-canonical": "warn",
69
- "tailwindcss/enforce-sort-order": "warn",
70
- "tailwindcss/enforce-shorthand": "warn",
71
- "tailwindcss/enforce-logical": "off",
72
- "tailwindcss/enforce-physical": "off",
73
- "tailwindcss/enforce-consistent-important-position": "warn",
74
49
  "tailwindcss/enforce-negative-arbitrary-values": "warn",
75
- "tailwindcss/enforce-consistent-variable-syntax": "warn",
50
+ "tailwindcss/no-deprecated-classes": "error",
51
+ "tailwindcss/no-unnecessary-arbitrary-value": "warn",
52
+ "tailwindcss/prefer-scale-token": "off",
53
+ "tailwindcss/prefer-theme-tokens": "off",
54
+ // Consistency
76
55
  "tailwindcss/consistent-variant-order": "warn",
77
- // Complexity
78
- "tailwindcss/max-class-count": "off",
56
+ "tailwindcss/enforce-consistent-important-position": "warn",
79
57
  "tailwindcss/enforce-consistent-line-wrapping": "off",
80
- // Restrictions
81
- "tailwindcss/no-restricted-classes": "off",
58
+ "tailwindcss/enforce-consistent-variable-syntax": "warn",
59
+ "tailwindcss/enforce-logical": "off",
60
+ "tailwindcss/enforce-physical": "off",
61
+ "tailwindcss/enforce-shorthand": "warn",
62
+ "tailwindcss/enforce-sort-order": "warn",
63
+ "tailwindcss/no-unnecessary-whitespace": "warn",
64
+ // Design-system guardrails
65
+ "tailwindcss/max-class-count": "off",
82
66
  "tailwindcss/no-arbitrary-value": "off",
67
+ "tailwindcss/no-borrowed-component-styles": "off",
68
+ "tailwindcss/no-default-palette": "off",
83
69
  "tailwindcss/no-hardcoded-colors": "warn",
84
- "tailwindcss/no-unnecessary-arbitrary-value": "warn",
85
- "tailwindcss/prefer-theme-tokens": "off",
86
- },
87
- }
88
- ```
89
-
90
- Declare your Tailwind CSS entry point in `settings.tailwindcss.entryPoint`:
91
-
92
- ```jsonc
93
- {
94
- "jsPlugins": ["oxlint-tailwindcss"],
95
- "settings": {
96
- "tailwindcss": {
97
- "entryPoint": "src/styles.css",
98
- },
99
- },
100
- "rules": {
101
- "tailwindcss/no-unknown-classes": "error",
102
- // ...
103
- },
104
- }
105
- ```
106
-
107
- That's the only required setting. The plugin loads your design system from that file once and shares
108
- it across every rule.
109
-
110
- ### Monorepos
111
-
112
- Two patterns, both fully deterministic:
113
-
114
- **Pattern A — single root config with a glob → CSS mapping.** First match wins, evaluation in array
115
- order:
116
-
117
- ```jsonc
118
- {
119
- "settings": {
120
- "tailwindcss": {
121
- "entryPoint": [
122
- { "files": "packages/ui/**", "use": "packages/ui/src/styles.css" },
123
- { "files": "packages/admin/**", "use": "packages/admin/src/admin.css" },
124
- { "files": "**", "use": "src/global.css" },
125
- ],
126
- },
127
- },
128
- }
129
- ```
130
-
131
- **Pattern B — one `.oxlintrc.json` per package**, each with its own string `entryPoint`. oxlint
132
- resolves the closest config to the file being linted, and a relative `entryPoint` is anchored to
133
- that config's directory (falling back to the working directory), so it resolves to the same CSS
134
- whether oxlint runs from the package (CLI) or the workspace root (editor).
135
-
136
- See the full [monorepo guide](https://oxlint-tailwindcss.pages.dev/monorepo) for examples of both.
137
-
138
- ### Per-rule override
139
-
140
- You can also override per rule if needed:
141
-
142
- ```jsonc
143
- {
144
- "rules": {
145
- "tailwindcss/no-unknown-classes": ["error", { "entryPoint": "src/app.css" }],
146
- },
147
- }
148
- ```
149
-
150
- Resolution order: rule option > `settings.tailwindcss.entryPoint`. If neither resolves a CSS file,
151
- DS-dependent rules emit a single `designSystemUnavailable` diagnostic per file (with the migration
152
- hint inline). v1.0.0 removed the filesystem auto-detect — explicit `entryPoint` is mandatory.
153
-
154
- ### Timeout
155
-
156
- For slow environments (large monorepos, CI), you can increase the design system loading timeout:
157
-
158
- ```jsonc
159
- {
160
- "settings": {
161
- "tailwindcss": {
162
- "timeout": 120000, // milliseconds (default: 60000)
163
- },
164
- },
165
- }
166
- ```
167
-
168
- This `timeout` governs the **precompute loader** only. The sort/canonicalize/declaration worker
169
- services used while linting have a separate **30 s per-request** timeout. If a slow-but-functional
170
- machine or CI runner reports `worker request timed out after 30000ms` on valid class lists, raise it
171
- with the `OXLINT_TAILWINDCSS_WORKER_REQUEST_TIMEOUT` environment variable (milliseconds):
172
-
173
- ```bash
174
- OXLINT_TAILWINDCSS_WORKER_REQUEST_TIMEOUT=60000 oxlint
175
- ```
176
-
177
- A timeout no longer costs O(files): after a few consecutive timeouts for one entry point the rest of
178
- the run fails fast, and the state self-heals once the machine recovers.
179
-
180
- ### Root font size
181
-
182
- The `enforce-canonical` rule converts px-based arbitrary values to named classes (e.g. `p-[2px]` →
183
- `p-0.5`). This conversion depends on the root font size:
184
-
185
- ```jsonc
186
- {
187
- "settings": {
188
- "tailwindcss": {
189
- "rootFontSize": 16, // pixels (default: 16)
190
- },
191
- },
70
+ "tailwindcss/no-restricted-classes": "off"
71
+ }
192
72
  }
193
73
  ```
194
74
 
195
- ### Debug logging
75
+ <!-- /generated:full-config -->
196
76
 
197
- To see which design system is used for each file, enable debug mode:
198
-
199
- ```jsonc
200
- {
201
- "settings": {
202
- "tailwindcss": {
203
- "debug": true,
204
- },
205
- },
206
- }
207
- ```
208
-
209
- Or use the environment variable (no config changes needed):
210
-
211
- ```bash
212
- DEBUG=oxlint-tailwindcss oxlint .
213
- ```
214
-
215
- Output:
216
-
217
- ```
218
- [oxlint-tailwindcss] Loaded design system from "packages/web/src/globals.css"
219
- [oxlint-tailwindcss] packages/web/src/App.tsx → packages/web/src/globals.css
220
- [oxlint-tailwindcss] packages/admin/src/Dashboard.tsx → packages/admin/src/styles.css
221
- ```
222
-
223
- If no entry point is configured, the DS-dependent rules (`no-unknown-classes`,
224
- `no-conflicting-classes`, `enforce-canonical`, `enforce-sort-order`,
225
- `no-unnecessary-arbitrary-value`, `prefer-scale-token`, `prefer-theme-tokens`) emit a single
226
- `designSystemUnavailable` diagnostic per file with an actionable hint — no more silent skips.
227
- `consistent-variant-order` tolerates a missing entryPoint (its static fallback is itself
228
- deterministic), and `no-deprecated-classes` tolerates one too — it falls back to a hardcoded v3→v4
229
- rename map, and derives a richer map from the design system when an entry point is configured. All
230
- non-DS rules work without an entry point.
231
-
232
- ## Custom class detection
233
-
234
- By default the plugin detects Tailwind classes in `className`/`class` attributes, 14 utility
235
- functions (`cn`, `clsx`, `cva`, `tv`, `classed`, etc.), `tw` tagged templates, and variables whose
236
- names match `className`/`classNames`/`classes`/`style`/`styles`.
237
-
238
- You can extend these defaults via `settings.tailwindcss`. All values are **additive** — your custom
239
- entries are appended to the built-in defaults:
240
-
241
- ```jsonc
242
- {
243
- "jsPlugins": ["oxlint-tailwindcss"],
244
- "settings": {
245
- "tailwindcss": {
246
- // Additional JSX attribute names to scan (exact match)
247
- "attributes": ["xyzClassName", "classNames", "overlayClassName"],
248
- // Regex patterns for JSX attribute names — catches *ClassName conventions
249
- // (React Native / Uniwind) without listing every prop
250
- "attributePatterns": ["ClassName$"],
251
- // Additional function names to scan
252
- "callees": ["myHelper"],
253
- // Additional tagged template tags to scan
254
- "tags": ["css"],
255
- // Additional regex patterns for variable names (as strings)
256
- "variablePatterns": ["^tw"],
257
- },
258
- },
259
- "rules": {
260
- "tailwindcss/no-unknown-classes": "error",
261
- // ...
262
- },
263
- }
264
- ```
265
-
266
- This applies to all 24 rules at once. For example, adding `"classNames"` to `attributes` makes every
267
- rule lint `<Input classNames={{ root: "..." }} />`.
268
-
269
- > **`attributePatterns` vs `variablePatterns`** — both match by regex, but on different things.
270
- > `attributePatterns` matches **JSX attribute names** (`contentContainerClassName`,
271
- > `tintColorClassName`, …); `variablePatterns` matches **variable declaration names only**
272
- > (`const fooClassName = "..."`), never JSX attributes — despite its default `/^classNames?$/`
273
- > looking like the `className` attribute.
274
-
275
- To **remove** specific items from the built-in defaults, use `exclude`:
276
-
277
- ```jsonc
278
- {
279
- "settings": {
280
- "tailwindcss": {
281
- "exclude": {
282
- // Stop scanning variables named "style" / "styles"
283
- "variablePatterns": ["^styles?$"],
284
- // Stop scanning a specific callee
285
- "callees": ["objstr"],
286
- },
287
- },
288
- },
289
- }
290
- ```
291
-
292
- For `variablePatterns`, exclusions match against the regex source (e.g. `"^styles?$"` removes the
293
- default `/^styles?$/` pattern).
294
-
295
- ## Supported patterns
296
-
297
- The plugin extracts Tailwind classes from:
298
-
299
- ```tsx
300
- // JSX attributes
301
- <div className="flex items-center" />
302
- <div class="flex items-center" />
303
-
304
- // Template literals
305
- <div className={`flex ${condition ? "hidden" : ""}`} />
306
-
307
- // Ternaries
308
- <div className={active ? "bg-blue-500" : "bg-gray-200"} />
309
-
310
- // Utility functions (cn, clsx, cx, cva, twMerge, twJoin, classnames, ctl, cc, clb, cnb, objstr)
311
- cn("flex items-center", condition && "hidden")
312
- clsx("flex", { "bg-red-500": isError })
313
- twMerge("p-4", "p-2")
314
-
315
- // cva() — full extraction: base, variants, compoundVariants
316
- cva("flex items-center", {
317
- variants: {
318
- size: { sm: "text-sm p-2", lg: "text-lg p-4" },
319
- },
320
- compoundVariants: [
321
- { size: "sm", class: "font-medium" },
322
- ],
323
- })
324
-
325
- // tv() — full extraction: base, slots, variants (with slot objects), compoundVariants, compoundSlots
326
- tv({
327
- base: "flex items-center",
328
- slots: { header: "p-4 font-bold", body: "p-2" },
329
- variants: {
330
- color: {
331
- primary: { header: "bg-blue-500", body: "text-blue-900" },
332
- },
333
- },
334
- compoundSlots: [
335
- { color: "primary", class: "border-blue-500" },
336
- ],
337
- })
338
-
339
- // classed() (tw-classed) — skips element type, extracts classes and cva-like config
340
- classed("button", "flex items-center", {
341
- variants: {
342
- color: { primary: "bg-blue-500", secondary: "bg-gray-500" },
343
- },
344
- })
345
-
346
- // Array values — the idiomatic multi-line form of cn()/cva()/tv()
347
- cn(["flex", "items-center"])
348
- tv({ base: ["flex", "items-center"], variants: { size: { sm: ["p-2", "text-sm"] } } })
349
-
350
- // Object-valued JSX attributes (e.g. Mantine classNames prop)
351
- <Input classNames={{ root: "flex items-center", input: "border-none" }} />
352
-
353
- // Tagged templates
354
- const styles = tw`flex items-center hover:bg-blue-500`
355
-
356
- // Variable declarations (matched by name: className, classNames, classes, style, styles)
357
- const className = "flex items-center"
358
- const classes = condition ? "bg-blue-500" : "bg-gray-200"
359
- ```
77
+ A missing or wrong entry point is reported once per file as `designSystemUnavailable`, with what to
78
+ fix; a misspelt setting as `invalidSetting`. [Setup](https://oxlint-tailwindcss.pages.dev/setup) has
79
+ the recommended set, and how to map each package of a monorepo to its own CSS.
360
80
 
361
81
  ## Rules
362
82
 
363
- ### Correctness
364
-
365
- #### `no-unknown-classes`
366
-
367
- Reports classes not recognized by Tailwind CSS. Includes typo suggestions.
368
-
369
- ```tsx
370
- // ❌ Bad
371
- <div className="flex itms-center bg-blu-500" />
372
- // ^^^^^^^^^^^
373
- // "itms-center" is not a valid Tailwind class. Did you mean "items-center"?
374
- // ^^^^^^^^^^
375
- // "bg-blu-500" is not a valid Tailwind class. Did you mean "bg-blue-500"?
376
- ```
377
-
378
- **Options:**
379
-
380
- | Option | Type | Description |
381
- | ---------------- | ---------- | ------------------------------------- |
382
- | `allowlist` | `string[]` | Custom classes to allow |
383
- | `ignorePrefixes` | `string[]` | Prefixes to ignore (e.g. `["data-"]`) |
384
-
385
- **Requires design system.** No autofix.
386
-
387
- ---
388
-
389
- #### `no-duplicate-classes`
390
-
391
- Detects repeated classes in the same string. `hover:flex` and `focus:flex` are **not** considered
392
- duplicates (different variants).
393
-
394
- ```tsx
395
- // ❌ Bad
396
- <div className="flex flex items-center" />
397
-
398
- // ✅ Fixed
399
- <div className="flex items-center" />
400
- ```
401
-
402
- **Autofix:** Removes the duplicate.
403
-
404
- ---
405
-
406
- #### `no-conflicting-classes`
407
-
408
- Detects classes whose CSS declarations clash, by comparing the CSS the design system actually emits
409
- — values included, not just property names. Reports which property clashes and which class wins,
410
- asked of the design system rather than inferred from the order you wrote the classes in.
411
-
412
- Two classes that declare the same property with the SAME value are reported separately, as
413
- `redundant`: not a conflict, but one of them is dead weight. Set `reportRedundant: false` to opt
414
- out.
415
-
416
- ```tsx
417
- // ❌ Bad
418
- <div className="text-red-500 text-blue-500" />
419
- // "text-red-500" overrides "text-blue-500" on "color".
420
-
421
- <div className="mt-2 mt-4" />
422
- // "mt-4" overrides "mt-2" on "margin-top".
423
- ```
424
-
425
- > **Note:** Shorthand vs longhand conflicts (e.g., `p-4` vs `px-2`) are not currently detected. See
426
- > [Known limitations](#known-limitations).
427
-
428
- **Requires design system.** No autofix.
429
-
430
- ---
431
-
432
- #### `no-deprecated-classes`
433
-
434
- Detects classes deprecated in Tailwind CSS v4.
435
-
436
- ```tsx
437
- // ❌ Bad
438
- <div className="flex-grow" />
439
- // "flex-grow" is deprecated in Tailwind v4. Use "grow" instead.
440
-
441
- // ✅ Fixed
442
- <div className="grow" />
443
- ```
444
-
445
- Deprecated class mappings:
446
-
447
- | Deprecated | Replacement |
448
- | ------------------- | ---------------------- |
449
- | `flex-grow` | `grow` |
450
- | `flex-grow-0` | `grow-0` |
451
- | `flex-shrink` | `shrink` |
452
- | `flex-shrink-0` | `shrink-0` |
453
- | `overflow-ellipsis` | `text-ellipsis` |
454
- | `decoration-slice` | `box-decoration-slice` |
455
- | `decoration-clone` | `box-decoration-clone` |
456
- | `bg-gradient-to-t` | `bg-linear-to-t` |
457
- | `bg-gradient-to-tr` | `bg-linear-to-tr` |
458
- | `bg-gradient-to-r` | `bg-linear-to-r` |
459
- | `bg-gradient-to-br` | `bg-linear-to-br` |
460
- | `bg-gradient-to-b` | `bg-linear-to-b` |
461
- | `bg-gradient-to-bl` | `bg-linear-to-bl` |
462
- | `bg-gradient-to-l` | `bg-linear-to-l` |
463
- | `bg-gradient-to-tl` | `bg-linear-to-tl` |
464
-
465
- **Autofix:** Replaces with the modern equivalent.
466
-
467
- ---
468
-
469
- #### `no-unnecessary-whitespace`
470
-
471
- Normalizes whitespace in class strings.
472
-
473
- ```tsx
474
- // ❌ Bad
475
- <div className=" flex items-center " />
476
-
477
- // ✅ Fixed
478
- <div className="flex items-center" />
479
- ```
480
-
481
- **Autofix:** Trims and collapses whitespace.
482
-
483
- ---
484
-
485
- #### `no-dark-without-light`
486
-
487
- Requires a base (light) utility when using the `dark:` variant on the same element.
488
-
489
- ```tsx
490
- // ❌ Bad — dark variant without base
491
- <div className="dark:bg-gray-900" />
492
- // "dark:bg-gray-900" uses the dark variant, but there is no base "bg-*" class.
493
-
494
- // ✅ OK — has matching base
495
- <div className="bg-white dark:bg-gray-900" />
496
- <div className="text-black dark:text-white" />
497
- ```
498
-
499
- Groups by utility prefix (`bg-`, `text-`, `border-`, etc.) — only checks that a base utility of the
500
- same type exists.
501
-
502
- **Scope (issue #117):** only inspects literal class lists on **native host elements** (`<div>`,
503
- `<input>`, …). Strings passed to `cn`/`twMerge`/`cva` or set on a custom component's `className` are
504
- override fragments whose light base commonly lives in another module, so they are skipped to avoid
505
- false positives.
506
-
507
- **Options:**
508
-
509
- | Option | Type | Default | Description |
510
- | ---------- | ---------- | ---------- | ------------------------------------ |
511
- | `variants` | `string[]` | `["dark"]` | Variant prefixes to check for a base |
512
-
513
- **No autofix.**
514
-
515
- ---
516
-
517
- #### `no-contradicting-variants`
518
-
519
- Detects variant-prefixed classes that are redundant because the base class already applies
520
- unconditionally.
521
-
522
- ```tsx
523
- // ❌ Bad — dark:flex is redundant because flex already applies always
524
- <div className="flex dark:flex" />
525
- <div className="hidden hover:hidden" />
526
-
527
- // ✅ OK — different values, both conditional, or different selector targets
528
- <div className="text-white dark:text-black" />
529
- <div className="hover:flex dark:flex" />
530
- <div className="absolute after:absolute" />
531
- <div className="shrink-0 [&>svg]:shrink-0" />
532
-
533
- // ✅ OK — responsive reset: lg:block restores display after md:hidden removed it
534
- <div className="block md:hidden lg:block" />
535
- ```
536
-
537
- Only flags when the exact same utility exists both as base and with a conditional variant. Variants
538
- that change the selector target (pseudo-elements, child/descendant selectors, arbitrary selectors)
539
- are not flagged.
540
-
541
- **Scope (issue #117):** only inspects literal class lists on **native host elements** (`<div>`,
542
- `<button>`, …). Strings passed to `cn`/`twMerge`/`cva` or set on a custom component's `className`
543
- are override fragments where the "redundant" variant is often load-bearing (it beats a same-group
544
- class the component merges in), so they are skipped to avoid false positives.
545
-
546
- **Responsive resets (issue #150):** the base only "applies unconditionally" if nothing else
547
- overrides its property. A variant that re-establishes a property an intermediate class took away
548
- (`lg:block` after `md:hidden`) is load-bearing and not flagged. With an `entryPoint` this uses the
549
- CSS properties the design system reports (any property); without one it falls back to the closed
550
- `display`/`visibility` groups.
551
-
552
- **Options:** `entryPoint` (per-rule override of `settings.tailwindcss.entryPoint`; optional — the
553
- rule is DS-optional and never reports a missing design system). **No autofix.**
554
-
555
- ---
556
-
557
- ### Style
558
-
559
- #### `enforce-canonical`
560
-
561
- Enforces canonical Tailwind CSS class names. Uses `canonicalizeCandidates()` from the Tailwind CSS
562
- engine dynamically — the same API that powers Tailwind CSS IntelliSense's `suggestCanonicalClasses`.
563
- It only rewrites when the canonical form emits **byte-identical CSS** (a value-preserving rename or
564
- syntax normalization), so `--fix` never changes how your design renders.
565
-
566
- ```tsx
567
- // ❌ Bad → ✅ Fixed
568
- "-m-0" → "m-0"
569
- "-mt-0" → "mt-0"
570
- "flex-grow-[2]" → "grow-2"
571
- "text-[var(--color-text)]/90" → "text-(--color-text)/90"
572
- ```
573
-
574
- It does **not** rewrite an arbitrary length into a spacing-scale step (`pl-[15px]` → `pl-3.75`),
575
- even though IntelliSense suggests it: `pl-3.75` compiles to `calc(var(--spacing) * 3.75)`, which is
576
- not byte-identical to `15px`, so the two can diverge under a `:root` override or a different root
577
- font size. Those value-changing suggestions live in [`prefer-scale-token`](#prefer-scale-token),
578
- report-only.
579
-
580
- **Requires design system.** **Autofix:** Replaces with canonical form.
581
-
582
- ---
583
-
584
- #### `enforce-sort-order`
585
-
586
- Sorts classes according to Tailwind's official class order — identical to
587
- [oxfmt](https://oxc.rs/docs/guide/usage/formatter) and
588
- [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss). Uses
589
- `ds.getClassOrder()` from the Tailwind CSS engine for exact results.
590
-
591
- ```tsx
592
- // ❌ Bad
593
- <div className="text-red-500 flex items-center p-4" />
594
-
595
- // ✅ Fixed
596
- <div className="flex items-center p-4 text-red-500" />
597
- ```
598
-
599
- In `strict` mode, classes are grouped by variant prefix, sorted within each group by DS sort order,
600
- and groups are ordered: no-variant first, then by variant priority.
601
-
602
- ```tsx
603
- // ❌ Bad (strict mode)
604
- <div className="hover:text-red-500 p-4 hover:bg-blue-500 m-2" />
605
-
606
- // ✅ Fixed
607
- <div className="m-2 p-4 hover:bg-blue-500 hover:text-red-500" />
608
- ```
609
-
610
- **Options:**
611
-
612
- | Option | Type | Default | Description |
613
- | ------ | ------------------------- | ----------- | ----------- |
614
- | `mode` | `"default"` \| `"strict"` | `"default"` | Sort mode |
615
-
616
- **Requires design system.** **Autofix:** Reorders classes.
617
-
618
- ---
619
-
620
- #### `enforce-shorthand`
621
-
622
- Suggests shorthand classes when all axes have the same value.
623
-
624
- ```tsx
625
- // ❌ Bad → ✅ Fixed
626
- "mt-2 mr-2 mb-2 ml-2" → "m-2"
627
- "mt-2 mb-2" → "my-2"
628
- "ml-2 mr-2" → "mx-2"
629
- "pt-4 pr-4 pb-4 pl-4" → "p-4"
630
- "pt-4 pb-4" → "py-4"
631
- "pl-4 pr-4" → "px-4"
632
- "px-4 py-4" → "p-4"
633
- "mx-2 my-2" → "m-2"
634
- "w-full h-full" → "size-full"
635
- "rounded-tl-lg rounded-tr-lg rounded-br-lg rounded-bl-lg" → "rounded-lg"
636
- ```
637
-
638
- **Autofix:** Replaces with shorthand.
639
-
640
- ---
641
-
642
- #### `enforce-logical`
643
-
644
- Converts physical properties to logical ones for LTR/RTL support.
645
-
646
- ```tsx
647
- // ❌ Bad → ✅ Fixed
648
- "ml-4" → "ms-4"
649
- "mr-4" → "me-4"
650
- "pl-4" → "ps-4"
651
- "pr-4" → "pe-4"
652
- "left-0" → "start-0"
653
- "right-0" → "end-0"
654
- ```
655
-
656
- Also converts `border-l/r`, `rounded-l/r/tl/tr/bl/br`, and `scroll-ml/mr/pl/pr` to their logical
657
- equivalents.
658
-
659
- **Options:**
660
-
661
- | Option | Type | Default | Description |
662
- | ----------- | ----------------------------------- | -------- | --------------------------------------------- |
663
- | `direction` | `"inline"` \| `"block"` \| `"both"` | `"both"` | Restrict conversion to one axis |
664
- | `allowlist` | `string[]` | `[]` | Regex patterns for classes to leave untouched |
665
-
666
- **Autofix:** Replaces with logical equivalent.
667
-
668
- ---
669
-
670
- #### `enforce-physical`
671
-
672
- The inverse of `enforce-logical`. Converts logical properties back to physical ones for consistency
673
- in LTR-only projects.
674
-
675
- ```tsx
676
- // ❌ Bad → ✅ Fixed
677
- "ms-4" → "ml-4"
678
- "me-4" → "mr-4"
679
- "ps-4" → "pl-4"
680
- "pe-4" → "pr-4"
681
- "start-0" → "left-0"
682
- "end-0" → "right-0"
683
- ```
684
-
685
- **Options:**
686
-
687
- | Option | Type | Default | Description |
688
- | ----------- | ----------------------------------- | -------- | --------------------------------------------- |
689
- | `direction` | `"inline"` \| `"block"` \| `"both"` | `"both"` | Restrict conversion to one axis |
690
- | `allowlist` | `string[]` | `[]` | Regex patterns for classes to leave untouched |
691
-
692
- **Autofix:** Replaces with physical equivalent.
693
-
694
- ---
695
-
696
- #### `enforce-consistent-important-position`
697
-
698
- Enforces a consistent position for the `!` (important) modifier — either prefix or suffix.
699
-
700
- ```tsx
701
- // ❌ Bad (default: suffix — Tailwind v4 canonical form)
702
- <div className="!font-bold" />
703
- <div className="hover:!text-red" />
704
-
705
- // ✅ Fixed
706
- <div className="font-bold!" />
707
- <div className="hover:text-red!" />
708
- ```
709
-
710
- Handles variants correctly — the `!` is placed on the utility, not the variant prefix.
711
-
712
- **Options:**
713
-
714
- | Option | Type | Default | Description |
715
- | ---------- | ------------------------ | ---------- | ------------------------------- |
716
- | `position` | `"prefix"` \| `"suffix"` | `"suffix"` | Where to place the `!` modifier |
717
-
718
- > **Note:** The default is `"suffix"` to match Tailwind CSS v4's canonical form. The prefix form
719
- > (`!flex`) is the v3 spelling. `enforce-canonical` preserves whatever `!` position you write (it
720
- > does not normalize it), so this rule is the single source of truth for `!` placement and the two
721
- > never conflict.
722
-
723
- **Autofix:** Moves `!` to the correct position.
724
-
725
- ---
726
-
727
- #### `enforce-negative-arbitrary-values`
728
-
729
- Moves the negative sign inside arbitrary value brackets for consistency.
730
-
731
- ```tsx
732
- // ❌ Bad
733
- <div className="-top-[5px]" />
734
- <div className="-translate-x-[10px]" />
735
- <div className="hover:-mt-[8px]" />
736
-
737
- // ✅ Fixed
738
- <div className="top-[-5px]" />
739
- <div className="translate-x-[-10px]" />
740
- <div className="hover:mt-[-8px]" />
741
- ```
742
-
743
- **No options.** **Autofix:** Moves the negative inside the brackets.
744
-
745
- ---
746
-
747
- #### `enforce-consistent-variable-syntax`
748
-
749
- Enforces consistent CSS variable syntax between Tailwind v4 shorthand `bg-(--var)` and explicit
750
- `bg-[var(--var)]`.
751
-
752
- ```tsx
753
- // ❌ Bad (default: shorthand)
754
- <div className="bg-[var(--primary)]" />
755
- <div className="text-[var(--text-color)]" />
756
-
757
- // ✅ Fixed
758
- <div className="bg-(--primary)" />
759
- <div className="text-(--text-color)" />
760
- ```
761
-
762
- Does NOT convert complex expressions — only simple `var(--name)` wrappers:
763
-
764
- ```tsx
765
- // ✅ Left as-is (complex expression)
766
- <div className="bg-[color-mix(in_srgb,var(--primary),transparent)]" />
767
- ```
768
-
769
- **Options:**
770
-
771
- | Option | Type | Default | Description |
772
- | -------- | ----------------------------- | ------------- | ----------------------- |
773
- | `syntax` | `"shorthand"` \| `"explicit"` | `"shorthand"` | Which syntax to enforce |
774
-
775
- **Autofix:** Converts between syntaxes.
776
-
777
- ---
778
-
779
- #### `consistent-variant-order`
780
-
781
- Enforces a consistent order for variant prefixes.
782
-
783
- Uses the design system's variant order when available, falls back to a sensible static default. Only
784
- checks classes with 2+ variants. Pseudo-element variants (`before:`, `after:`, `placeholder:`, etc.)
785
- are always kept innermost (closest to the utility) regardless of the ordering source — placing them
786
- before element-selecting variants like `[&>svg]:` or `has-[.active]:` produces broken CSS in
787
- Tailwind v4.
788
-
789
- **Options:**
790
-
791
- | Option | Type | Default | Description |
792
- | ------- | ---------- | --------------------------- | ---------------------------- |
793
- | `order` | `string[]` | (DS order or builtin order) | Custom variant priority list |
794
-
795
- **Optionally uses design system.** **Autofix:** Reorders variants.
796
-
797
- ---
798
-
799
- ### Complexity
800
-
801
- #### `max-class-count`
802
-
803
- Warns when an element has too many Tailwind classes, suggesting extraction into a component or
804
- utility.
805
-
806
- ```tsx
807
- // ❌ Bad (with default max: 20)
808
- <div
809
- className="flex items-center justify-between p-4 m-2 bg-white text-black
810
- rounded shadow border w-full h-10 gap-2 font-bold text-sm overflow-hidden
811
- cursor-pointer transition duration-200 opacity-50"
812
- />
813
- // Too many Tailwind classes (21). Maximum allowed is 20.
814
- ```
815
-
816
- **Options:**
817
-
818
- | Option | Type | Default | Description |
819
- | ------ | -------- | ------- | --------------------------- |
820
- | `max` | `number` | `20` | Maximum classes per element |
821
-
822
- **No autofix** — requires developer judgment on how to split.
823
-
824
- ---
825
-
826
- #### `enforce-consistent-line-wrapping`
827
-
828
- Warns when a class string exceeds the configured print width or classes-per-line limit.
829
-
830
- ```tsx
831
- // ❌ Bad (with default printWidth: 80)
832
- <div className="flex items-center justify-between p-4 m-2 bg-white text-black rounded shadow-lg border w-full" />
833
- // Class string is 97 characters long, exceeding the print width of 80.
834
-
835
- // ❌ Bad (with classesPerLine: 3)
836
- <div className="flex items-center justify-between p-4 m-2 bg-white" />
837
- // Too many classes on a single line (7). Maximum allowed per line is 3.
838
- ```
839
-
840
- **Options:**
841
-
842
- | Option | Type | Default | Description |
843
- | ---------------- | ------------------------------------- | ----------- | ------------------------------------------------------------------- |
844
- | `printWidth` | `number` | `80` | Max class string length |
845
- | `classesPerLine` | `number` | | Max classes per line |
846
- | `wrapLines` | `'overWidth' \| 'all'` | | Re-wrap lines: only over-width, or always into the canonical layout |
847
- | `group` | `'newLine' \| 'emptyLine' \| 'never'` | `'newLine'` | How the `wrapLines: 'all'` layout separates variant groups |
848
-
849
- **Autofix:** `classesPerLine` and `wrapLines` re-wrap template literals; `printWidth` is warn-only.
850
-
851
- ---
852
-
853
- ### Restrictions
854
-
855
- #### `no-restricted-classes`
856
-
857
- Blocks specific Tailwind classes by exact name or regex pattern with optional custom messages.
858
-
859
- ```tsx
860
- // With options: { classes: ["hidden"], patterns: [{ pattern: "^float-", message: "Use flexbox" }] }
861
-
862
- // ❌ Bad
863
- <div className="hidden" /> // "hidden" is restricted.
864
- <div className="float-left" /> // "float-left" is restricted: Use flexbox
865
- ```
866
-
867
- **Options (required — rule is a no-op without them):**
868
-
869
- | Option | Type | Default | Description |
870
- | ---------- | ---------------------------------------------- | ------- | -------------------------- |
871
- | `classes` | `string[]` | `[]` | Exact class names to block |
872
- | `patterns` | `Array<{ pattern: string, message?: string }>` | `[]` | Regex patterns to match |
873
-
874
- **No autofix.**
875
-
876
- ---
877
-
878
- #### `no-arbitrary-value`
879
-
880
- Prohibits arbitrary values (`[...]`) in Tailwind classes. Useful for teams that want to enforce
881
- strict design system adherence.
882
-
883
- ```tsx
884
- // ❌ Bad
885
- <div className="w-[200px]" />
886
- <div className="bg-[#ff0000]" />
887
- <div className="hover:w-[200px]" />
888
-
889
- // ✅ OK — arbitrary variants are NOT flagged
890
- <div className="[&>svg]:w-4" />
891
- ```
892
-
893
- **Options:**
894
-
895
- | Option | Type | Default | Description |
896
- | ------- | ---------- | ------- | --------------------------------------------------- |
897
- | `allow` | `string[]` | `[]` | Utility prefixes to allow (e.g. `["bg-", "text-"]`) |
898
-
899
- **No autofix.**
900
-
901
- ---
902
-
903
- #### `no-hardcoded-colors`
904
-
905
- Flags hardcoded color values in arbitrary brackets. Encourages use of design tokens.
906
-
907
- ```tsx
908
- // ❌ Bad
909
- <div className="bg-[#ff5733]" />
910
- <div className="text-[rgb(255,0,0)]" />
911
- <div className="border-[hsl(120,100%,50%)]" />
912
- <div className="hover:bg-[#ff5733]" />
913
-
914
- // ✅ OK — not a color utility
915
- <div className="w-[200px]" />
916
- <div className="tracking-[0.5em]" />
917
- ```
918
-
919
- Detects hex, rgb/rgba, hsl/hsla, oklch, oklab, and other color function values inside `[...]` on
920
- color-related utility prefixes (`bg-`, `text-`, `border-`, `ring-`, `shadow-`, `fill-`, `stroke-`,
921
- etc.).
922
-
923
- **Options:**
924
-
925
- | Option | Type | Default | Description |
926
- | ------- | ---------- | ------- | ------------------------- |
927
- | `allow` | `string[]` | `[]` | Full class names to allow |
928
-
929
- **No autofix.**
930
-
931
- ---
932
-
933
- #### `no-unnecessary-arbitrary-value`
934
-
935
- Detects arbitrary values that have a named Tailwind equivalent. The arbitrary form produces the
936
- exact same CSS, so the named class is preferred.
937
-
938
- ```tsx
939
- // ❌ Bad → ✅ Fixed
940
- "h-[auto]" → "h-auto"
941
- "hover:h-[auto]" → "hover:h-auto"
942
-
943
- // ✅ OK — no named equivalent
944
- "w-[200px]"
945
- "bg-[#custom]"
946
- ```
947
-
948
- **Requires design system.** **Autofix:** Replaces with named class.
949
-
950
- ---
951
-
952
- #### `prefer-theme-tokens`
953
-
954
- Suggests replacing raw CSS variable references like `border-(--border)` or `bg-[var(--primary)]`
955
- with the equivalent named theme-token utility (`border-border`, `bg-primary`) when one exists in
956
- your design system.
957
-
958
- Unlike `no-unnecessary-arbitrary-value`, this rule fires even when the named utility produces
959
- _different_ CSS — for example, in themes that wrap the raw variable in a color function
960
- (`--color-border: hsl(var(--border))`). Useful to match the official Tailwind VS Code extension's
961
- `suggestCanonicalClasses` behavior. **Off by default** because the replacement may change observable
962
- CSS in those setups. (When the theme exposes the variable directly with no wrapping function,
963
- `border-[var(--border)]` is CSS-equivalent to `border-border` and is owned by
964
- `no-unnecessary-arbitrary-value` instead.)
965
-
966
- ```tsx
967
- // ❌ Bad → ✅ Fixed (when border-border is a valid utility)
968
- "border-(--border)" → "border-border"
969
- "bg-[var(--primary)]" → "bg-primary"
970
- "hover:bg-(--primary)/80" → "hover:bg-primary/80"
971
- ```
972
-
973
- **Requires design system.** **Autofix:** Replaces with named class.
974
-
975
- ---
976
-
977
- #### `prefer-scale-token`
978
-
979
- Reports a hardcoded value that is **numerically equal** to a spacing-scale step or a named theme
980
- token, and suggests the token. This is the rule that matches Tailwind CSS IntelliSense's
981
- `suggestCanonicalClasses` suggestion for arbitrary lengths (e.g. `pl-[15px]` → `pl-3.75`) — the
982
- conversion `enforce-canonical` deliberately leaves alone because the CSS isn't byte-identical (see
983
- [#78](https://github.com/sergioazoc/oxlint-tailwindcss/issues/78)).
984
-
985
- **Report-only, on purpose.** There is no autofix: the token resolves through `var(--spacing)`, so a
986
- `:root` override or a different root font size can make the two diverge. It only ever suggests, so
987
- `oxlint --fix` skips it while `oxlint --fix-suggestions` applies it in bulk.
988
-
989
- ```tsx
990
- // ⚠️ Suggested (not auto-fixed)
991
- "p-[10px]" → "p-2.5"
992
- "rounded-[0.5rem]" → "rounded-lg"
993
- ```
994
-
995
- By default it reports values on the granularity Tailwind's own scale enumerates (multiples of
996
- `0.5`). To match IntelliSense exactly — including dynamic steps like `pl-3.75` — set a finer `step`:
997
-
998
- ```jsonc
999
- { "tailwindcss/prefer-scale-token": ["warn", { "step": 0.25 }] }
1000
- ```
1001
-
1002
- **Off by default.** **Requires design system.** **No autofix — suggestions only.**
1003
-
1004
- ---
1005
-
1006
- ## Edge cases
1007
-
1008
- The class parser correctly handles:
1009
-
1010
- - Nested brackets: `bg-[url('https://example.com/img.png')]`
1011
- - Nested calc: `h-[calc(100vh-var(--header-height))]`
1012
- - Arbitrary variants: `[&>svg]:w-4`, `[&_p]:mt-2`
1013
- - Quoted values: `content-['hello_world']`
1014
- - Important modifier: `!font-bold`
1015
- - Negative values: `-translate-x-1`
1016
- - Named groups/peers: `group/sidebar`, `peer/input`
1017
-
1018
- ## Known limitations
1019
-
1020
- - **`enforce-canonical`**: Named classes are canonicalized via the precomputed map (covers
1021
- everything in `getClassList()` plus a curated list of legacy v3 spellings like `break-words`,
1022
- `flex-grow`, `start-N`, `bg-gradient-to-*`, `bg-left-top` → `bg-top-left`). Arbitrary/CSS-var
1023
- forms (`bg-(--c)`, `text-[var(--x)]`) are canonicalized dynamically via the worker when the result
1024
- is byte-identical; a value-changing form like `p-[2px]` → `p-0.5` is left to `prefer-scale-token`.
1025
- Some valid v4 classes that don't appear in `getClassList()` and have no canonical rewrite (e.g.
1026
- `border-1` is valid as a dynamic numeric value but isn't enumerated) are left untouched.
1027
- - **`no-conflicting-classes`**: compares the emitted declarations (property, value, the custom
1028
- properties each value reads, and which box it applies to), so compositions are derived rather than
1029
- enumerated. Two exceptions cannot be derived and stay declared in the source: `prose` variants and
1030
- `prose` + `max-w-*` (the plugin intends the override, and the CSS looks identical to an accident),
1031
- and `mask-composite` modes. Use the `allow` option for a composition your own plugins produce.
1032
- Still not detected: shorthand vs longhand under different property names (`p-4` vs `px-2` —
1033
- `padding` vs `padding-left`/`padding-right`), and, for classes whose value you wrote (`w-[10px]`),
1034
- the stylesheet position is unknowable, so those diagnostics report the clash without naming a
1035
- winner.
1036
- - **`no-dark-without-light`**: Groups by utility prefix heuristic. May not perfectly match all
1037
- multi-part utility prefixes.
1038
- - **`no-unnecessary-arbitrary-value`**: Only detects equivalences for classes with a single CSS
1039
- property. Multi-property utilities may have arbitrary forms that aren't detected.
1040
- - **Component classes**: Only first-level `@import` relative paths are followed. Deeply nested
1041
- imports or absolute paths are not resolved.
1042
-
1043
- ## Supported plugins
1044
-
1045
- The plugin loads classes through `@tailwindcss/node`, so any plugin imported into your CSS entry
1046
- point — `@plugin '...'` or `@import '...'` — is recognized automatically by every rule. The
1047
- following are exercised by the test suite:
1048
-
1049
- - **[`@tailwindcss/typography`](https://github.com/tailwindlabs/tailwindcss-typography)** — `prose`,
1050
- `prose-sm/lg/xl`, `not-prose`. `prose` styles both itself and its descendants, and
1051
- `no-conflicting-classes` only compares what a class declares on its own box, so
1052
- `prose overflow-x-auto` is not a conflict.
1053
- - **[`tailwindcss-animate`](https://github.com/jamiebuilds/tailwindcss-animate)** — `animate-in`,
1054
- `animate-out`, `fade-{in,out}-*`, `zoom-{in,out}-*`, `spin-{in,out}-*`,
1055
- `slide-{in-from,out-to}-*`, `duration-*`, `delay-*`, `ease-*`, `direction-*`, `fill-mode-*`,
1056
- `repeat-*`, `running`, `paused`. `animate-in`/`animate-out` initialize all `--tw-enter-*` /
1057
- `--tw-exit-*` custom properties to `initial`, and modifiers (`fade-in`, `zoom-in`,
1058
- `slide-in-from-*`, etc.) each override one of them. `no-conflicting-classes` derives that from the
1059
- emitted CSS — a custom property reset to `initial` carries no information — so it holds for any
1060
- plugin built the same way, not just these two.
1061
- - **[`tw-animate-css`](https://github.com/Wombosvideo/tw-animate-css)** — v4-native rewrite of
1062
- `tailwindcss-animate`. Adds `blur-{in,out}-*`, logical (RTL-aware)
1063
- `slide-{in-from,out-to}-{start,end}-*`, `play-state-*`, `animation-duration-*`, and the
1064
- `animate-accordion-{up,down}` / `animate-collapsible-{up,down}` / `animate-caret-blink` keyframe
1065
- animations used by Radix-style headless component libraries.
1066
-
1067
- Other plugins that emit classes through standard `getClassList()` and CSS output should work out of
1068
- the box. If you find one that doesn't, open an issue.
83
+ <!-- generated:rule-table -->
84
+
85
+ | Rule | Category | Checks | Recommended | Fix | Design system |
86
+ | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ---------- | ------------- |
87
+ | [`no-conflicting-classes`](https://oxlint-tailwindcss.pages.dev/rules/no-conflicting-classes) | Correctness | Disallow Tailwind CSS classes that generate conflicting CSS properties | `error` | — | required |
88
+ | [`no-contradicting-variants`](https://oxlint-tailwindcss.pages.dev/rules/no-contradicting-variants) | Correctness | Disallow variant-prefixed classes that are redundant because the base class already applies unconditionally | `warn` | — | optional |
89
+ | [`no-dark-without-light`](https://oxlint-tailwindcss.pages.dev/rules/no-dark-without-light) | Correctness | Require a base (light) utility when using dark: (or other scheme) variant | `warn` | — | optional |
90
+ | [`no-duplicate-classes`](https://oxlint-tailwindcss.pages.dev/rules/no-duplicate-classes) | Correctness | Disallow duplicate Tailwind CSS classes | `warn` | autofix | not used |
91
+ | [`no-dynamic-classes`](https://oxlint-tailwindcss.pages.dev/rules/no-dynamic-classes) | Correctness | Disallow Tailwind CSS class names built at runtime, which Tailwind cannot see and generates no CSS for | `error` | — | optional |
92
+ | [`no-unknown-classes`](https://oxlint-tailwindcss.pages.dev/rules/no-unknown-classes) | Correctness | Disallow classes that are not defined in the Tailwind CSS design system | `error` | suggestion | required |
93
+ | [`enforce-canonical`](https://oxlint-tailwindcss.pages.dev/rules/enforce-canonical) | Modernization | Enforce canonical Tailwind CSS class names using canonicalizeCandidates() | `warn` | autofix | required |
94
+ | [`enforce-negative-arbitrary-values`](https://oxlint-tailwindcss.pages.dev/rules/enforce-negative-arbitrary-values) | Modernization | Enforce moving the negative sign inside arbitrary value brackets: -top-[5px] → top-[-5px] | `warn` | autofix | not used |
95
+ | [`no-deprecated-classes`](https://oxlint-tailwindcss.pages.dev/rules/no-deprecated-classes) | Modernization | Disallow deprecated Tailwind CSS v4 classes | `error` | autofix | optional |
96
+ | [`no-unnecessary-arbitrary-value`](https://oxlint-tailwindcss.pages.dev/rules/no-unnecessary-arbitrary-value) | Modernization | Disallow arbitrary values when a named Tailwind class produces the same CSS | `warn` | autofix | required |
97
+ | [`prefer-scale-token`](https://oxlint-tailwindcss.pages.dev/rules/prefer-scale-token) | Modernization | Prefer the scale step or theme token a hardcoded value is numerically equal to | off | suggestion | required |
98
+ | [`prefer-theme-tokens`](https://oxlint-tailwindcss.pages.dev/rules/prefer-theme-tokens) | Modernization | Prefer named theme-token utilities over raw CSS variable references when a matching utility exists | off | autofix | required |
99
+ | [`consistent-variant-order`](https://oxlint-tailwindcss.pages.dev/rules/consistent-variant-order) | Consistency | Enforce a consistent order for Tailwind CSS variant prefixes | `warn` | autofix | optional |
100
+ | [`enforce-consistent-important-position`](https://oxlint-tailwindcss.pages.dev/rules/enforce-consistent-important-position) | Consistency | Enforce consistent position of the important (!) modifier. Default: suffix (Tailwind v4 canonical form). This rule is the single source of truth for ! placement — enforce-canonical preserves the position you wrote, so the two never conflict. | `warn` | autofix | not used |
101
+ | [`enforce-consistent-line-wrapping`](https://oxlint-tailwindcss.pages.dev/rules/enforce-consistent-line-wrapping) | Consistency | Warn (and optionally autofix) when a class string exceeds the configured print width or classes-per-line budget | off | autofix | optional |
102
+ | [`enforce-consistent-variable-syntax`](https://oxlint-tailwindcss.pages.dev/rules/enforce-consistent-variable-syntax) | Consistency | Enforce consistent CSS variable syntax: bg-[var(--color)] ↔ bg-(--color) | `warn` | autofix | not used |
103
+ | [`enforce-logical`](https://oxlint-tailwindcss.pages.dev/rules/enforce-logical) | Consistency | Enforce logical (RTL-friendly) Tailwind CSS properties instead of physical ones | off | autofix | optional |
104
+ | [`enforce-physical`](https://oxlint-tailwindcss.pages.dev/rules/enforce-physical) | Consistency | Enforce physical Tailwind CSS properties instead of logical ones for consistency in LTR-only projects | off | autofix | optional |
105
+ | [`enforce-shorthand`](https://oxlint-tailwindcss.pages.dev/rules/enforce-shorthand) | Consistency | Enforce shorthand Tailwind CSS classes when all axes have the same value | `warn` | autofix | optional |
106
+ | [`enforce-sort-order`](https://oxlint-tailwindcss.pages.dev/rules/enforce-sort-order) | Consistency | Enforce consistent sort order of Tailwind CSS classes using the official class order | `warn` | autofix | required |
107
+ | [`no-unnecessary-whitespace`](https://oxlint-tailwindcss.pages.dev/rules/no-unnecessary-whitespace) | Consistency | Disallow unnecessary whitespace in Tailwind CSS class strings | `warn` | autofix | not used |
108
+ | [`max-class-count`](https://oxlint-tailwindcss.pages.dev/rules/max-class-count) | Design-system guardrails | Enforce a maximum number of Tailwind CSS classes per class string | off | — | not used |
109
+ | [`no-arbitrary-value`](https://oxlint-tailwindcss.pages.dev/rules/no-arbitrary-value) | Design-system guardrails | Disallow arbitrary values in Tailwind CSS classes | off | — | optional |
110
+ | [`no-borrowed-component-styles`](https://oxlint-tailwindcss.pages.dev/rules/no-borrowed-component-styles) | Design-system guardrails (experimental) | Disallow a plain element that rebuilds one of your design system's components from its classes | off | — | required |
111
+ | [`no-default-palette`](https://oxlint-tailwindcss.pages.dev/rules/no-default-palette) | Design-system guardrails | Disallow colors from Tailwind CSS's default palette in a project that defines its own theme colors | off | — | required |
112
+ | [`no-hardcoded-colors`](https://oxlint-tailwindcss.pages.dev/rules/no-hardcoded-colors) | Design-system guardrails | Disallow hardcoded color values in Tailwind CSS classes | `warn` | — | optional |
113
+ | [`no-restricted-classes`](https://oxlint-tailwindcss.pages.dev/rules/no-restricted-classes) | Design-system guardrails | Disallow specific Tailwind CSS classes | off | — | not used |
114
+
115
+ <!-- /generated:rule-table -->
116
+
117
+ ## Files and frameworks
118
+
119
+ Classes are read from `className` / `class` attributes, from `cn()`, `clsx()`, `cva()`, `tv()`,
120
+ `twMerge()` and the other common helpers, from `tw` tagged templates, and from variables named like
121
+ `className`, `classes` or `styles`; [settings](https://oxlint-tailwindcss.pages.dev/settings) add
122
+ your own. Any Tailwind plugin your entry point loads is part of the design system the rules read. In
123
+ `.vue`, `.svelte` and `.astro` files, oxlint passes plugins only the `<script>` (and Astro's
124
+ frontmatter), so classes in templates aren't linted:
125
+ [Vue, Svelte & Astro](https://oxlint-tailwindcss.pages.dev/frameworks).
1069
126
 
1070
127
  ## Requirements
1071
128
 
1072
- - Node.js >= 20
1073
- - Tailwind CSS v4.1 or newer (4.0.x is not supported — it predates a design-system API the plugin
1074
- needs, and is reported with a clear diagnostic)
1075
- - oxlint >= 1.43.0
129
+ - Node.js `^20.19.0 || >=22.12.0` (the same range oxlint itself requires)
130
+ - Tailwind CSS v4.1.15 or newer, loaded from your project, per entry point; an older engine is
131
+ reported with a clear diagnostic
132
+ - oxlint >= 1.43.0. With the editor extension, avoid oxlint 1.77.0: its language server crashes on
133
+ any JS plugin diagnostic ([oxc#25280](https://github.com/oxc-project/oxc/pull/25280), fixed in
134
+ 1.78.0).
135
+
136
+ Only 2 runtime dependencies: `@tailwindcss/node` and `tailwindcss`.
1076
137
 
1077
- > **Avoid oxlint 1.77.0 with the editor extension.** 1.77.0 panics the oxlint **language server** on
1078
- > any diagnostic from any JS plugin (`disable_fix.rs:52`, then SIGABRT and a restart loop). It's an
1079
- > oxlint bug, not a plugin one, and the CLI is unaffected (CI is fine). It's **fixed in oxlint
1080
- > 1.78.0** ([oxc#25280](https://github.com/oxc-project/oxc/pull/25280)) — upgrade to `oxlint@1.78.0`
1081
- > or newer (or stay on `1.76.0`) if you use the editor extension.
138
+ Upgrading from v0? See the
139
+ [migration guide](https://oxlint-tailwindcss.pages.dev/migration/v0-to-v1).
1082
140
 
1083
141
  ## License
1084
142