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