oxlint-tailwindcss 0.1.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 ADDED
@@ -0,0 +1,701 @@
1
+ # oxlint-plugin-tailwindcss
2
+
3
+ 21 Tailwind CSS linting rules for [oxlint](https://oxc.rs/docs/guide/usage/linter). Built for Tailwind CSS v4 with zero-config auto-detection, typo suggestions, and autofixes.
4
+
5
+ ## Highlights
6
+
7
+ - **Zero config** — Auto-detects your Tailwind CSS entry point. Works out of the box.
8
+ - **Fast** — Native oxlint plugin with a shared design system cache. Loads once, used by all rules.
9
+ - **Tailwind CSS v4** — Designed for v4 from day one.
10
+ - **Typo suggestions** — `itms-center` → "Did you mean `items-center`?"
11
+ - **Conflict detection** — Shows exactly which CSS properties conflict and which class wins.
12
+ - **Lightweight** — Only 2 runtime dependencies: `@tailwindcss/node` and `tailwindcss`.
13
+ - **21 rules** — Correctness, style, complexity, and restriction rules with autofixes where possible.
14
+ - **Variable detection** — Lints variables named `className`, `classes`, `style` automatically.
15
+ - **Component class support** — Recognizes `@layer components { .btn {} }` in your CSS.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pnpm add -D oxlint-plugin-tailwindcss
21
+ ```
22
+
23
+ ## Setup
24
+
25
+ Add the plugin to your `.oxlintrc.json`:
26
+
27
+ ```jsonc
28
+ {
29
+ "jsPlugins": ["oxlint-plugin-tailwindcss"],
30
+ "rules": {
31
+ // Correctness
32
+ "tailwindcss/no-unknown-classes": "error",
33
+ "tailwindcss/no-duplicate-classes": "error",
34
+ "tailwindcss/no-conflicting-classes": "error",
35
+ "tailwindcss/no-deprecated-classes": "error",
36
+ "tailwindcss/no-unnecessary-whitespace": "error",
37
+ "tailwindcss/no-dark-without-light": "warn",
38
+ "tailwindcss/no-contradicting-variants": "warn",
39
+ // Style
40
+ "tailwindcss/enforce-canonical": "warn",
41
+ "tailwindcss/enforce-sort-order": "warn",
42
+ "tailwindcss/enforce-shorthand": "warn",
43
+ "tailwindcss/enforce-logical": "off",
44
+ "tailwindcss/enforce-consistent-important-position": "warn",
45
+ "tailwindcss/enforce-negative-arbitrary-values": "warn",
46
+ "tailwindcss/enforce-consistent-variable-syntax": "warn",
47
+ "tailwindcss/consistent-variant-order": "warn",
48
+ // Complexity
49
+ "tailwindcss/max-class-count": "warn",
50
+ "tailwindcss/enforce-consistent-line-wrapping": "warn",
51
+ // Restrictions
52
+ "tailwindcss/no-restricted-classes": "off",
53
+ "tailwindcss/no-arbitrary-value": "off",
54
+ "tailwindcss/no-hardcoded-colors": "warn",
55
+ "tailwindcss/no-unnecessary-arbitrary-value": "warn",
56
+ },
57
+ }
58
+ ```
59
+
60
+ The plugin auto-detects your Tailwind CSS entry point. No configuration needed in most projects.
61
+
62
+ ## Auto-detection
63
+
64
+ The plugin searches for a CSS file containing a Tailwind import signal (`@import "tailwindcss"`, `@import 'tailwindcss'`, `@import tailwindcss`, `@tailwind base`) in these locations, walking upward from the linted file:
65
+
66
+ ```
67
+ src/app.css src/globals.css src/global.css
68
+ src/style.css src/styles.css src/index.css
69
+ app.css main.css globals.css
70
+ style.css styles/globals.css app/globals.css
71
+ assets/css/tailwind.css
72
+ ```
73
+
74
+ The search is monorepo-aware — it stops at `package.json` boundaries so each package resolves its own Tailwind config.
75
+
76
+ To override auto-detection, pass `entryPoint` as an option:
77
+
78
+ ```jsonc
79
+ {
80
+ "rules": {
81
+ "tailwindcss/no-unknown-classes": ["error", { "entryPoint": "src/app.css" }],
82
+ },
83
+ }
84
+ ```
85
+
86
+ ## Supported patterns
87
+
88
+ The plugin extracts Tailwind classes from:
89
+
90
+ ```tsx
91
+ // JSX attributes
92
+ <div className="flex items-center" />
93
+ <div class="flex items-center" />
94
+
95
+ // Template literals
96
+ <div className={`flex ${condition ? "hidden" : ""}`} />
97
+
98
+ // Ternaries
99
+ <div className={active ? "bg-blue-500" : "bg-gray-200"} />
100
+
101
+ // Utility functions
102
+ cn("flex items-center", condition && "hidden")
103
+ clsx("flex", { "bg-red-500": isError })
104
+ twMerge("p-4", "p-2")
105
+ cx("flex", "items-center")
106
+ classnames("flex", "items-center")
107
+ ctl("flex items-center")
108
+ twJoin("flex", "items-center")
109
+ cc("flex", "items-center")
110
+ clb("flex", "items-center")
111
+ cnb("flex", "items-center")
112
+ objstr({ "flex": true, "items-center": true })
113
+
114
+ // cva() — full extraction: base, variants, compoundVariants
115
+ cva("flex items-center", {
116
+ variants: {
117
+ size: { sm: "text-sm p-2", lg: "text-lg p-4" },
118
+ },
119
+ compoundVariants: [
120
+ { size: "sm", class: "font-medium" },
121
+ ],
122
+ })
123
+
124
+ // tv() — full extraction: base, slots, variants (with slot objects), compoundVariants, compoundSlots
125
+ tv({
126
+ base: "flex items-center",
127
+ slots: { header: "p-4 font-bold", body: "p-2" },
128
+ variants: {
129
+ color: {
130
+ primary: { header: "bg-blue-500", body: "text-blue-900" },
131
+ },
132
+ },
133
+ compoundSlots: [
134
+ { color: "primary", class: "border-blue-500" },
135
+ ],
136
+ })
137
+
138
+ // Tagged templates
139
+ const styles = tw`flex items-center hover:bg-blue-500`
140
+
141
+ // Variable declarations (matched by name: className, classNames, classes, style, styles)
142
+ const className = "flex items-center"
143
+ const classes = condition ? "bg-blue-500" : "bg-gray-200"
144
+ ```
145
+
146
+ ## Rules
147
+
148
+ ### Correctness
149
+
150
+ #### `no-unknown-classes`
151
+
152
+ Reports classes not recognized by Tailwind CSS. Includes typo suggestions.
153
+
154
+ ```tsx
155
+ // ❌ Bad
156
+ <div className="flex itms-center bg-blu-500" />
157
+ // ^^^^^^^^^^^
158
+ // "itms-center" is not a valid Tailwind class. Did you mean "items-center"?
159
+ // ^^^^^^^^^^
160
+ // "bg-blu-500" is not a valid Tailwind class. Did you mean "bg-blue-500"?
161
+ ```
162
+
163
+ **Options:**
164
+
165
+ | Option | Type | Description |
166
+ | ---------------- | ---------- | ------------------------------------- |
167
+ | `entryPoint` | `string` | Path to Tailwind CSS entry file |
168
+ | `allowlist` | `string[]` | Custom classes to allow |
169
+ | `ignorePrefixes` | `string[]` | Prefixes to ignore (e.g. `["data-"]`) |
170
+
171
+ **Requires design system.** No autofix.
172
+
173
+ ---
174
+
175
+ #### `no-duplicate-classes`
176
+
177
+ Detects repeated classes in the same string. `hover:flex` and `focus:flex` are **not** considered duplicates (different variants).
178
+
179
+ ```tsx
180
+ // ❌ Bad
181
+ <div className="flex flex items-center" />
182
+
183
+ // ✅ Fixed
184
+ <div className="flex items-center" />
185
+ ```
186
+
187
+ **Autofix:** Removes the duplicate.
188
+
189
+ ---
190
+
191
+ #### `no-conflicting-classes`
192
+
193
+ Detects classes that set the same CSS property. Reports which property conflicts and which class wins.
194
+
195
+ ```tsx
196
+ // ❌ Bad
197
+ <div className="text-red-500 text-blue-500" />
198
+ // "text-red-500" and "text-blue-500" affect "color".
199
+ // "text-blue-500" takes precedence (appears later).
200
+
201
+ <div className="mt-2 mt-4" />
202
+ // "mt-2" and "mt-4" affect "margin-top".
203
+ ```
204
+
205
+ > **Note:** Shorthand vs longhand conflicts (e.g., `p-4` vs `px-2`) are not currently detected. See [Known limitations](#known-limitations).
206
+
207
+ **Options:**
208
+
209
+ | Option | Type | Description |
210
+ | ------------ | -------- | ------------------------------- |
211
+ | `entryPoint` | `string` | Path to Tailwind CSS entry file |
212
+
213
+ **Requires design system.** No autofix.
214
+
215
+ ---
216
+
217
+ #### `no-deprecated-classes`
218
+
219
+ Detects classes deprecated in Tailwind CSS v4.
220
+
221
+ ```tsx
222
+ // ❌ Bad
223
+ <div className="flex-grow" />
224
+ // "flex-grow" is deprecated in Tailwind v4. Use "grow" instead.
225
+
226
+ // ✅ Fixed
227
+ <div className="grow" />
228
+ ```
229
+
230
+ Deprecated class mappings:
231
+
232
+ | Deprecated | Replacement |
233
+ | ------------------- | ---------------------- |
234
+ | `flex-grow` | `grow` |
235
+ | `flex-grow-0` | `grow-0` |
236
+ | `flex-shrink` | `shrink` |
237
+ | `flex-shrink-0` | `shrink-0` |
238
+ | `overflow-ellipsis` | `text-ellipsis` |
239
+ | `decoration-slice` | `box-decoration-slice` |
240
+ | `decoration-clone` | `box-decoration-clone` |
241
+
242
+ **Autofix:** Replaces with the modern equivalent.
243
+
244
+ ---
245
+
246
+ #### `no-unnecessary-whitespace`
247
+
248
+ Normalizes whitespace in class strings.
249
+
250
+ ```tsx
251
+ // ❌ Bad
252
+ <div className=" flex items-center " />
253
+
254
+ // ✅ Fixed
255
+ <div className="flex items-center" />
256
+ ```
257
+
258
+ **Autofix:** Trims and collapses whitespace.
259
+
260
+ ---
261
+
262
+ #### `no-dark-without-light`
263
+
264
+ Requires a base (light) utility when using the `dark:` variant on the same element.
265
+
266
+ ```tsx
267
+ // ❌ Bad — dark variant without base
268
+ <div className="dark:bg-gray-900" />
269
+ // "dark:bg-gray-900" uses the dark variant, but there is no base "bg-*" class.
270
+
271
+ // ✅ OK — has matching base
272
+ <div className="bg-white dark:bg-gray-900" />
273
+ <div className="text-black dark:text-white" />
274
+ ```
275
+
276
+ Groups by utility prefix (`bg-`, `text-`, `border-`, etc.) — only checks that a base utility of the same type exists.
277
+
278
+ **Options:**
279
+
280
+ | Option | Type | Default | Description |
281
+ | ---------- | ---------- | ---------- | ------------------------------------ |
282
+ | `variants` | `string[]` | `["dark"]` | Variant prefixes to check for a base |
283
+
284
+ **No autofix.**
285
+
286
+ ---
287
+
288
+ #### `no-contradicting-variants`
289
+
290
+ Detects variant-prefixed classes that are redundant because the base class already applies unconditionally.
291
+
292
+ ```tsx
293
+ // ❌ Bad — dark:flex is redundant because flex already applies always
294
+ <div className="flex dark:flex" />
295
+ <div className="hidden hover:hidden" />
296
+
297
+ // ✅ OK — different values, not contradicting
298
+ <div className="text-white dark:text-black" />
299
+ <div className="bg-white hover:bg-blue-500" />
300
+
301
+ // ✅ OK — no base class, both are conditional
302
+ <div className="hover:flex dark:flex" />
303
+ ```
304
+
305
+ Only reports when the **exact same utility** exists both as base and with a variant.
306
+
307
+ **No options.** **No autofix.**
308
+
309
+ ---
310
+
311
+ ### Style
312
+
313
+ #### `enforce-canonical`
314
+
315
+ Suggests the canonical form of a class when a shorter equivalent exists. Only known classes are checked — arbitrary values are left as-is.
316
+
317
+ ```tsx
318
+ // ❌ Bad → ✅ Fixed
319
+ "-m-0" → "m-0"
320
+ "-mt-0" → "mt-0"
321
+ "-p-0" → "p-0"
322
+ ```
323
+
324
+ **Options:**
325
+
326
+ | Option | Type | Description |
327
+ | ------------ | -------- | ------------------------------- |
328
+ | `entryPoint` | `string` | Path to Tailwind CSS entry file |
329
+
330
+ **Requires design system.** **Autofix:** Replaces with canonical form.
331
+
332
+ ---
333
+
334
+ #### `enforce-sort-order`
335
+
336
+ Sorts classes according to Tailwind's official class order.
337
+
338
+ ```tsx
339
+ // ❌ Bad
340
+ <div className="text-red-500 flex items-center p-4" />
341
+
342
+ // ✅ Fixed
343
+ <div className="flex items-center p-4 text-red-500" />
344
+ ```
345
+
346
+ In `strict` mode, classes are grouped by variant prefix, sorted within each group by DS sort order, and groups are ordered: no-variant first, then by variant priority.
347
+
348
+ ```tsx
349
+ // ❌ Bad (strict mode)
350
+ <div className="hover:text-red-500 p-4 hover:bg-blue-500 m-2" />
351
+
352
+ // ✅ Fixed
353
+ <div className="m-2 p-4 hover:bg-blue-500 hover:text-red-500" />
354
+ ```
355
+
356
+ **Options:**
357
+
358
+ | Option | Type | Default | Description |
359
+ | ------------ | ------------------------- | ----------- | ------------------------------- |
360
+ | `entryPoint` | `string` | | Path to Tailwind CSS entry file |
361
+ | `mode` | `"default"` \| `"strict"` | `"default"` | Sort mode |
362
+
363
+ **Requires design system.** **Autofix:** Reorders classes.
364
+
365
+ ---
366
+
367
+ #### `enforce-shorthand`
368
+
369
+ Suggests shorthand classes when all axes have the same value.
370
+
371
+ ```tsx
372
+ // ❌ Bad → ✅ Fixed
373
+ "mt-2 mr-2 mb-2 ml-2" → "m-2"
374
+ "mt-2 mb-2" → "my-2"
375
+ "ml-2 mr-2" → "mx-2"
376
+ "pt-4 pr-4 pb-4 pl-4" → "p-4"
377
+ "pt-4 pb-4" → "py-4"
378
+ "pl-4 pr-4" → "px-4"
379
+ "w-full h-full" → "size-full"
380
+ "rounded-tl-lg rounded-tr-lg rounded-br-lg rounded-bl-lg" → "rounded-lg"
381
+ ```
382
+
383
+ **Autofix:** Replaces with shorthand.
384
+
385
+ ---
386
+
387
+ #### `enforce-logical`
388
+
389
+ Converts physical properties to logical ones for LTR/RTL support.
390
+
391
+ ```tsx
392
+ // ❌ Bad → ✅ Fixed
393
+ "ml-4" → "ms-4"
394
+ "mr-4" → "me-4"
395
+ "pl-4" → "ps-4"
396
+ "pr-4" → "pe-4"
397
+ "left-0" → "start-0"
398
+ "right-0" → "end-0"
399
+ ```
400
+
401
+ Full mapping:
402
+
403
+ | Physical | Logical |
404
+ | --------------------------- | --------------------------- |
405
+ | `ml` | `ms` |
406
+ | `mr` | `me` |
407
+ | `pl` | `ps` |
408
+ | `pr` | `pe` |
409
+ | `left` | `start` |
410
+ | `right` | `end` |
411
+ | `border-l` / `border-r` | `border-s` / `border-e` |
412
+ | `rounded-l` / `rounded-r` | `rounded-s` / `rounded-e` |
413
+ | `rounded-tl` / `rounded-tr` | `rounded-ss` / `rounded-se` |
414
+ | `rounded-bl` / `rounded-br` | `rounded-es` / `rounded-ee` |
415
+ | `scroll-ml` / `scroll-mr` | `scroll-ms` / `scroll-me` |
416
+ | `scroll-pl` / `scroll-pr` | `scroll-ps` / `scroll-pe` |
417
+
418
+ **Autofix:** Replaces with logical equivalent.
419
+
420
+ ---
421
+
422
+ #### `enforce-consistent-important-position`
423
+
424
+ Enforces a consistent position for the `!` (important) modifier — either prefix or suffix.
425
+
426
+ ```tsx
427
+ // ❌ Bad (default: prefix)
428
+ <div className="font-bold!" />
429
+ <div className="hover:text-red!" />
430
+
431
+ // ✅ Fixed
432
+ <div className="!font-bold" />
433
+ <div className="hover:!text-red" />
434
+ ```
435
+
436
+ Handles variants correctly — the `!` is placed on the utility, not the variant prefix.
437
+
438
+ **Options:**
439
+
440
+ | Option | Type | Default | Description |
441
+ | ---------- | ------------------------ | ---------- | ------------------------------- |
442
+ | `position` | `"prefix"` \| `"suffix"` | `"prefix"` | Where to place the `!` modifier |
443
+
444
+ **Autofix:** Moves `!` to the correct position.
445
+
446
+ ---
447
+
448
+ #### `enforce-negative-arbitrary-values`
449
+
450
+ Moves the negative sign inside arbitrary value brackets for consistency.
451
+
452
+ ```tsx
453
+ // ❌ Bad
454
+ <div className="-top-[5px]" />
455
+ <div className="-translate-x-[10px]" />
456
+ <div className="hover:-mt-[8px]" />
457
+
458
+ // ✅ Fixed
459
+ <div className="top-[-5px]" />
460
+ <div className="translate-x-[-10px]" />
461
+ <div className="hover:mt-[-8px]" />
462
+ ```
463
+
464
+ **No options.** **Autofix:** Moves the negative inside the brackets.
465
+
466
+ ---
467
+
468
+ #### `enforce-consistent-variable-syntax`
469
+
470
+ Enforces consistent CSS variable syntax between Tailwind v4 shorthand `bg-(--var)` and explicit `bg-[var(--var)]`.
471
+
472
+ ```tsx
473
+ // ❌ Bad (default: shorthand)
474
+ <div className="bg-[var(--primary)]" />
475
+ <div className="text-[var(--text-color)]" />
476
+
477
+ // ✅ Fixed
478
+ <div className="bg-(--primary)" />
479
+ <div className="text-(--text-color)" />
480
+ ```
481
+
482
+ Does NOT convert complex expressions — only simple `var(--name)` wrappers:
483
+
484
+ ```tsx
485
+ // ✅ Left as-is (complex expression)
486
+ <div className="bg-[color-mix(in_srgb,var(--primary),transparent)]" />
487
+ ```
488
+
489
+ **Options:**
490
+
491
+ | Option | Type | Default | Description |
492
+ | -------- | ----------------------------- | ------------- | ----------------------- |
493
+ | `syntax` | `"shorthand"` \| `"explicit"` | `"shorthand"` | Which syntax to enforce |
494
+
495
+ **Autofix:** Converts between syntaxes.
496
+
497
+ ---
498
+
499
+ #### `consistent-variant-order`
500
+
501
+ Enforces a consistent order for variant prefixes.
502
+
503
+ When a Tailwind CSS design system is available, the variant order is automatically derived from the design system (via `getVariants()`). Without a design system, a sensible static default is used: responsive → feature queries → color scheme → container queries → group/peer → interactive states → form states → structural → pseudo elements → direction.
504
+
505
+ A user-specified `order` option always takes the highest priority, overriding both the design system and the static default.
506
+
507
+ Only checks classes with 2+ variants. Single-variant classes are always valid.
508
+
509
+ **Options:**
510
+
511
+ | Option | Type | Default | Description |
512
+ | ------------ | ---------- | --------------------------- | ------------------------------- |
513
+ | `entryPoint` | `string` | (auto-detected) | Path to Tailwind CSS entry file |
514
+ | `order` | `string[]` | (DS order or builtin order) | Custom variant priority list |
515
+
516
+ **Optionally uses design system.** **Autofix:** Reorders variants.
517
+
518
+ ---
519
+
520
+ ### Complexity
521
+
522
+ #### `max-class-count`
523
+
524
+ Warns when an element has too many Tailwind classes, suggesting extraction into a component or utility.
525
+
526
+ ```tsx
527
+ // ❌ Bad (with default max: 20)
528
+ <div
529
+ className="flex items-center justify-between p-4 m-2 bg-white text-black
530
+ rounded shadow border w-full h-10 gap-2 font-bold text-sm overflow-hidden
531
+ cursor-pointer transition duration-200 opacity-50"
532
+ />
533
+ // Too many Tailwind classes (21). Maximum allowed is 20.
534
+ ```
535
+
536
+ **Options:**
537
+
538
+ | Option | Type | Default | Description |
539
+ | ------ | -------- | ------- | --------------------------- |
540
+ | `max` | `number` | `20` | Maximum classes per element |
541
+
542
+ **No autofix** — requires developer judgment on how to split.
543
+
544
+ ---
545
+
546
+ #### `enforce-consistent-line-wrapping`
547
+
548
+ Warns when a class string exceeds the configured print width or classes-per-line limit.
549
+
550
+ ```tsx
551
+ // ❌ Bad (with default printWidth: 80)
552
+ <div className="flex items-center justify-between p-4 m-2 bg-white text-black rounded shadow-lg border w-full" />
553
+ // Class string is 97 characters long, exceeding the print width of 80.
554
+
555
+ // ❌ Bad (with classesPerLine: 3)
556
+ <div className="flex items-center justify-between p-4 m-2 bg-white" />
557
+ // Too many classes on a single line (7). Maximum allowed per line is 3.
558
+ ```
559
+
560
+ **Options:**
561
+
562
+ | Option | Type | Default | Description |
563
+ | ---------------- | -------- | ------- | ----------------------- |
564
+ | `printWidth` | `number` | `80` | Max class string length |
565
+ | `classesPerLine` | `number` | | Max classes per line |
566
+
567
+ **Partial autofix:** When `classesPerLine` is set and the class string is inside a template literal, autofixes by splitting into lines. String literals report without autofix.
568
+
569
+ ---
570
+
571
+ ### Restrictions
572
+
573
+ #### `no-restricted-classes`
574
+
575
+ Blocks specific Tailwind classes by exact name or regex pattern with optional custom messages.
576
+
577
+ ```tsx
578
+ // With options: { classes: ["hidden"], patterns: [{ pattern: "^float-", message: "Use flexbox" }] }
579
+
580
+ // ❌ Bad
581
+ <div className="hidden" /> // "hidden" is restricted.
582
+ <div className="float-left" /> // "float-left" is restricted: Use flexbox
583
+ ```
584
+
585
+ **Options (required — rule is a no-op without them):**
586
+
587
+ | Option | Type | Default | Description |
588
+ | ---------- | ---------------------------------------------- | ------- | -------------------------- |
589
+ | `classes` | `string[]` | `[]` | Exact class names to block |
590
+ | `patterns` | `Array<{ pattern: string, message?: string }>` | `[]` | Regex patterns to match |
591
+
592
+ **No autofix.**
593
+
594
+ ---
595
+
596
+ #### `no-arbitrary-value`
597
+
598
+ Prohibits arbitrary values (`[...]`) in Tailwind classes. Useful for teams that want to enforce strict design system adherence.
599
+
600
+ ```tsx
601
+ // ❌ Bad
602
+ <div className="w-[200px]" />
603
+ <div className="bg-[#ff0000]" />
604
+ <div className="hover:w-[200px]" />
605
+
606
+ // ✅ OK — arbitrary variants are NOT flagged
607
+ <div className="[&>svg]:w-4" />
608
+ ```
609
+
610
+ **Options:**
611
+
612
+ | Option | Type | Default | Description |
613
+ | ------- | ---------- | ------- | --------------------------------------------------- |
614
+ | `allow` | `string[]` | `[]` | Utility prefixes to allow (e.g. `["bg-", "text-"]`) |
615
+
616
+ **No autofix.**
617
+
618
+ ---
619
+
620
+ #### `no-hardcoded-colors`
621
+
622
+ Flags hardcoded color values in arbitrary brackets. Encourages use of design tokens.
623
+
624
+ ```tsx
625
+ // ❌ Bad
626
+ <div className="bg-[#ff5733]" />
627
+ <div className="text-[rgb(255,0,0)]" />
628
+ <div className="border-[hsl(120,100%,50%)]" />
629
+ <div className="hover:bg-[#ff5733]" />
630
+
631
+ // ✅ OK — not a color utility
632
+ <div className="w-[200px]" />
633
+ <div className="tracking-[0.5em]" />
634
+ ```
635
+
636
+ Detects hex, rgb/rgba, hsl/hsla, oklch, oklab, lch, lab, hwb, and `color()` values inside `[...]` on these utility prefixes: `bg-`, `text-`, `border-` (including directional: `-t`, `-b`, `-l`, `-r`, `-s`, `-e`, `-x`, `-y`), `outline-`, `ring-`, `ring-offset-`, `shadow-`, `accent-`, `caret-`, `fill-`, `stroke-`, `decoration-`, `divide-`, `placeholder-`, `from-`, `via-`, `to-`.
637
+
638
+ **Options:**
639
+
640
+ | Option | Type | Default | Description |
641
+ | ------- | ---------- | ------- | ------------------------- |
642
+ | `allow` | `string[]` | `[]` | Full class names to allow |
643
+
644
+ **No autofix.**
645
+
646
+ ---
647
+
648
+ #### `no-unnecessary-arbitrary-value`
649
+
650
+ Detects arbitrary values that have a named Tailwind equivalent. The arbitrary form produces the exact same CSS, so the named class is preferred.
651
+
652
+ ```tsx
653
+ // ❌ Bad → ✅ Fixed
654
+ "h-[auto]" → "h-auto"
655
+ "hover:h-[auto]" → "hover:h-auto"
656
+
657
+ // ✅ OK — no named equivalent
658
+ "w-[200px]"
659
+ "bg-[#custom]"
660
+ ```
661
+
662
+ **Options:**
663
+
664
+ | Option | Type | Description |
665
+ | ------------ | -------- | ------------------------------- |
666
+ | `entryPoint` | `string` | Path to Tailwind CSS entry file |
667
+
668
+ **Requires design system.** **Autofix:** Replaces with named class.
669
+
670
+ ---
671
+
672
+ ## Edge cases
673
+
674
+ The class parser correctly handles:
675
+
676
+ - Nested brackets: `bg-[url('https://example.com/img.png')]`
677
+ - Nested calc: `h-[calc(100vh-var(--header-height))]`
678
+ - Arbitrary variants: `[&>svg]:w-4`, `[&_p]:mt-2`
679
+ - Quoted values: `content-['hello_world']`
680
+ - Important modifier: `!font-bold`
681
+ - Negative values: `-translate-x-1`
682
+ - Named groups/peers: `group/sidebar`, `peer/input`
683
+
684
+ ## Known limitations
685
+
686
+ - **`enforce-canonical`**: Only classes in Tailwind's class list can be canonicalized. Some valid classes (e.g., `grow-1`, `border-1`) are not in the list and won't be converted. Arbitrary values are also not canonicalized.
687
+ - **`no-conflicting-classes`**: Uses exact CSS property name matching. Shorthand vs longhand conflicts (e.g., `p-4` vs `px-2` where `padding` conflicts with `padding-left`) are not detected.
688
+ - **`enforce-sort-order`**: Variant-prefixed classes use the base utility's sort order as a fallback, which may not be 100% accurate for complex variant combinations.
689
+ - **`no-dark-without-light`**: Groups by utility prefix heuristic. May not perfectly match all multi-part utility prefixes.
690
+ - **`no-unnecessary-arbitrary-value`**: Only detects equivalences for classes with a single CSS property. Multi-property utilities may have arbitrary forms that aren't detected.
691
+ - **Component classes**: Only first-level `@import` relative paths are followed. Deeply nested imports or absolute paths are not resolved.
692
+
693
+ ## Requirements
694
+
695
+ - Node.js >= 20
696
+ - Tailwind CSS v4
697
+ - oxlint >= 1.43.0
698
+
699
+ ## License
700
+
701
+ MIT