oxlint-tailwindcss 0.6.2 → 0.7.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,6 +1,6 @@
1
1
  # oxlint-tailwindcss
2
2
 
3
- 22 Tailwind CSS linting rules for [oxlint](https://oxc.rs/docs/guide/usage/linter). Built for Tailwind CSS v4 with auto-detection, typo suggestions, and autofixes.
3
+ 23 Tailwind CSS linting rules for [oxlint](https://oxc.rs/docs/guide/usage/linter). Built for Tailwind CSS v4 with auto-detection, typo suggestions, and autofixes.
4
4
 
5
5
  Read the story behind this plugin: [oxlint-tailwindcss: The Linting Plugin Tailwind v4 Needed](https://sergioazocar.com/en/blog/oxlint-tailwindcss-the-linting-plugin-tailwind-v4-needed)
6
6
 
@@ -13,7 +13,7 @@ Read the story behind this plugin: [oxlint-tailwindcss: The Linting Plugin Tailw
13
13
  - **Typo suggestions** — `itms-center` → "Did you mean `items-center`?"
14
14
  - **Conflict detection** — Shows exactly which CSS properties conflict and which class wins.
15
15
  - **Lightweight** — Only 2 runtime dependencies: `@tailwindcss/node` and `tailwindcss`.
16
- - **22 rules** — Correctness, style, complexity, and restriction rules with autofixes where possible.
16
+ - **23 rules** — Correctness, style, complexity, and restriction rules with autofixes where possible.
17
17
  - **Variable detection** — Lints variables named `className`, `classes`, `style` automatically.
18
18
  - **Customizable** — Extend class detection with custom attributes, callees, tags, and variable patterns.
19
19
  - **Component class support** — Recognizes `@layer components { .btn {} }` in your CSS.
@@ -58,6 +58,7 @@ Add the plugin to your `.oxlintrc.json`:
58
58
  "tailwindcss/no-arbitrary-value": "off",
59
59
  "tailwindcss/no-hardcoded-colors": "warn",
60
60
  "tailwindcss/no-unnecessary-arbitrary-value": "warn",
61
+ "tailwindcss/prefer-theme-tokens": "off",
61
62
  },
62
63
  }
63
64
  ```
@@ -187,7 +188,7 @@ Output:
187
188
  [oxlint-tailwindcss] packages/admin/src/Dashboard.tsx → packages/admin/src/styles.css
188
189
  ```
189
190
 
190
- If no entry point is found (neither configured nor auto-detected), rules that require the design system (`no-unknown-classes`, `no-conflicting-classes`, `no-deprecated-classes`, `enforce-canonical`, `enforce-sort-order`, `no-unnecessary-arbitrary-value`, `consistent-variant-order`) are silently disabled. All other rules work without it.
191
+ If no entry point is found (neither configured nor auto-detected), rules that require the design system (`no-unknown-classes`, `no-conflicting-classes`, `no-deprecated-classes`, `enforce-canonical`, `enforce-sort-order`, `no-unnecessary-arbitrary-value`, `prefer-theme-tokens`, `consistent-variant-order`) are silently disabled. All other rules work without it.
191
192
 
192
193
  ## Custom class detection
193
194
 
@@ -217,7 +218,7 @@ You can extend these defaults via `settings.tailwindcss`. All values are **addit
217
218
  }
218
219
  ```
219
220
 
220
- This applies to all 22 rules at once. For example, adding `"classNames"` to `attributes` makes every rule lint `<Input classNames={{ root: "..." }} />`.
221
+ This applies to all 23 rules at once. For example, adding `"classNames"` to `attributes` makes every rule lint `<Input classNames={{ root: "..." }} />`.
221
222
 
222
223
  To **remove** specific items from the built-in defaults, use `exclude`:
223
224
 
@@ -810,6 +811,23 @@ Detects arbitrary values that have a named Tailwind equivalent. The arbitrary fo
810
811
 
811
812
  ---
812
813
 
814
+ #### `prefer-theme-tokens`
815
+
816
+ Suggests replacing raw CSS variable references like `border-(--border)` or `bg-[var(--primary)]` with the equivalent named theme-token utility (`border-border`, `bg-primary`) when one exists in your design system.
817
+
818
+ Unlike `no-unnecessary-arbitrary-value`, this rule fires even when the named utility produces _different_ CSS — for example, in shadcn-style themes where `--color-border: hsl(var(--border))` wraps the raw variable. Useful to match the official Tailwind VS Code extension's `suggestCanonicalClasses` behavior. **Off by default** because the replacement may change observable CSS in those setups.
819
+
820
+ ```tsx
821
+ // ❌ Bad → ✅ Fixed (when border-border is a valid utility)
822
+ "border-(--border)" → "border-border"
823
+ "bg-[var(--primary)]" → "bg-primary"
824
+ "hover:bg-(--primary)/80" → "hover:bg-primary/80"
825
+ ```
826
+
827
+ **Requires design system.** **Autofix:** Replaces with named class.
828
+
829
+ ---
830
+
813
831
  ## Edge cases
814
832
 
815
833
  The class parser correctly handles: