oxlint-tailwindcss 0.7.1 → 1.0.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,15 +1,19 @@
1
1
  # oxlint-tailwindcss
2
2
 
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.
3
+ 23 Tailwind CSS linting rules for [oxlint](https://oxc.rs/docs/guide/usage/linter). Built for Tailwind CSS v4 with deterministic config, typo suggestions, and autofixes.
4
+
5
+ > **v1.0.0** — Upgrading from v0.x? See the **[migration guide](https://oxlint-tailwindcss.pages.dev/migration/v0-to-v1)**. The headline change: `settings.tailwindcss.entryPoint` is now required.
4
6
 
5
7
  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
8
 
7
9
  ## Highlights
8
10
 
9
- - **Works out of the box** — Auto-detects your Tailwind CSS entry point. Fully configurable when needed.
10
- - **Monorepo-ready** — Each package resolves its own design system automatically. Run `oxlint` once from the workspace root.
11
- - **Fast** — Native oxlint plugin with per-entry-point caching and content-based disk cache for monorepo deduplication.
12
- - **Tailwind CSS v4** — Designed for v4 from day one.
11
+ - **Configure once, never fails** — `settings.tailwindcss.entryPoint` is explicit. Same input → same output on every machine.
12
+ - **Monorepo-ready** — Single root config with a glob → CSS mapping array, or one `.oxlintrc.json` per package. Both fully deterministic.
13
+ - **Coexists with oxfmt and Prettier** — Point all tools at the same CSS and they agree byte-for-byte. See the [interop guide](https://oxlint-tailwindcss.pages.dev/interop).
14
+ - **Tailwind CSS v4** — Designed for v4 from day one. Reads your `@theme { ... }` custom tokens, your shadcn variables, your typography plugin.
15
+ - **Fail loud** — Misconfiguration surfaces as a single `designSystemUnavailable` diagnostic with an actionable hint. Never silently skipped rules.
16
+ - **Fast** — Native oxlint plugin with per-entry-point caching and content-hash disk cache for monorepo deduplication.
13
17
  - **Typo suggestions** — `itms-center` → "Did you mean `items-center`?"
14
18
  - **Conflict detection** — Shows exactly which CSS properties conflict and which class wins.
15
19
  - **Lightweight** — Only 2 runtime dependencies: `@tailwindcss/node` and `tailwindcss`.
@@ -18,6 +22,8 @@ Read the story behind this plugin: [oxlint-tailwindcss: The Linting Plugin Tailw
18
22
  - **Customizable** — Extend class detection with custom attributes, callees, tags, and variable patterns.
19
23
  - **Component class support** — Recognizes `@layer components { .btn {} }` in your CSS.
20
24
 
25
+ Full documentation: **https://oxlint-tailwindcss.pages.dev** (English) · **https://oxlint-tailwindcss.pages.dev/es** (Español)
26
+
21
27
  ## Installation
22
28
 
23
29
  ```bash
@@ -63,30 +69,14 @@ Add the plugin to your `.oxlintrc.json`:
63
69
  }
64
70
  ```
65
71
 
66
- The plugin auto-detects your Tailwind CSS entry point. No configuration needed in most projects.
67
-
68
- ## Auto-detection
69
-
70
- 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:
71
-
72
- ```
73
- src/{name}.css {name}.css app/{name}.css
74
- styles/{name}.css style/{name}.css css/{name}.css
75
- assets/{name}.css assets/css/{name}.css resources/css/{name}.css
76
- ```
77
-
78
- Where `{name}` is one of: `app`, `globals`, `global`, `style`, `styles`, `index`, `main`, `tailwind`, `tailwindcss`.
79
-
80
- The search is monorepo-aware — it stops at `package.json` boundaries so each package resolves its own Tailwind config. Packages without a Tailwind CSS file are silently skipped (DS-dependent rules produce no diagnostics). If the signal isn't found directly in the CSS file, the auto-detector follows `@import` statements one level deep — supporting both relative paths and package imports (e.g. `@import '@company/theme/tailwind.config.css'`).
81
-
82
- If auto-detection doesn't find your CSS file, set `entryPoint` once in `settings`:
72
+ Declare your Tailwind CSS entry point in `settings.tailwindcss.entryPoint`:
83
73
 
84
74
  ```jsonc
85
75
  {
86
76
  "jsPlugins": ["oxlint-tailwindcss"],
87
77
  "settings": {
88
78
  "tailwindcss": {
89
- "entryPoint": "app/tailwind.css",
79
+ "entryPoint": "src/styles.css",
90
80
  },
91
81
  },
92
82
  "rules": {
@@ -96,27 +86,31 @@ If auto-detection doesn't find your CSS file, set `entryPoint` once in `settings
96
86
  }
97
87
  ```
98
88
 
99
- The design system is loaded once per entry point and shared across all rules. In monorepos, each package resolves its own entry point automatically via `package.json` boundaries.
89
+ That's the only required setting. The plugin loads your design system from that file once and shares it across every rule.
90
+
91
+ ### Monorepos
100
92
 
101
- ### Multiple entry points (monorepos)
93
+ Two patterns, both fully deterministic:
102
94
 
103
- For monorepos where auto-detection isn't enough, `entryPoint` accepts an array. The plugin picks the closest entry point for each file based on directory proximity:
95
+ **Pattern A — single root config with a glob → CSS mapping.** First match wins, evaluation in array order:
104
96
 
105
97
  ```jsonc
106
98
  {
107
99
  "settings": {
108
100
  "tailwindcss": {
109
101
  "entryPoint": [
110
- "packages/web/src/globals.css",
111
- "packages/admin/src/styles.css",
112
- "packages/marketing/src/tailwind.css",
102
+ { "files": "packages/ui/**", "use": "packages/ui/src/styles.css" },
103
+ { "files": "packages/admin/**", "use": "packages/admin/src/admin.css" },
104
+ { "files": "**", "use": "src/global.css" },
113
105
  ],
114
106
  },
115
107
  },
116
108
  }
117
109
  ```
118
110
 
119
- For example, `packages/web/src/App.tsx` resolves to `packages/web/src/globals.css` and `packages/admin/src/Dashboard.tsx` resolves to `packages/admin/src/styles.css`.
111
+ **Pattern B — one `.oxlintrc.json` per package**, each with its own string `entryPoint`. oxlint resolves the closest config to the file being linted.
112
+
113
+ See the full [monorepo guide](https://oxlint-tailwindcss.pages.dev/monorepo) for examples of both.
120
114
 
121
115
  ### Per-rule override
122
116
 
@@ -130,7 +124,7 @@ You can also override per rule if needed:
130
124
  }
131
125
  ```
132
126
 
133
- Resolution order: rule option > `settings.tailwindcss.entryPoint` > auto-detect.
127
+ Resolution order: rule option > `settings.tailwindcss.entryPoint`. If neither resolves a CSS file, DS-dependent rules emit a single `designSystemUnavailable` diagnostic per file (with the migration hint inline). v1.0.0 removed the filesystem auto-detect — explicit `entryPoint` is mandatory.
134
128
 
135
129
  ### Timeout
136
130
 
@@ -140,7 +134,7 @@ For slow environments (large monorepos, CI), you can increase the design system
140
134
  {
141
135
  "settings": {
142
136
  "tailwindcss": {
143
- "timeout": 60000, // milliseconds (default: 30000)
137
+ "timeout": 120000, // milliseconds (default: 60000)
144
138
  },
145
139
  },
146
140
  }
@@ -188,7 +182,7 @@ Output:
188
182
  [oxlint-tailwindcss] packages/admin/src/Dashboard.tsx → packages/admin/src/styles.css
189
183
  ```
190
184
 
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.
185
+ If no entry point is configured, the DS-dependent rules (`no-unknown-classes`, `no-conflicting-classes`, `no-deprecated-classes`, `enforce-canonical`, `enforce-sort-order`, `no-unnecessary-arbitrary-value`, `prefer-theme-tokens`) emit a single `designSystemUnavailable` diagnostic per file with an actionable hint — no more silent skips. `consistent-variant-order` is the lone exception: its static fallback is itself deterministic, so a missing entryPoint is tolerated there. All non-DS rules work without an entry point.
192
186
 
193
187
  ## Custom class detection
194
188
 
@@ -290,6 +284,10 @@ classed("button", "flex items-center", {
290
284
  },
291
285
  })
292
286
 
287
+ // Array values — the idiomatic multi-line form of cn()/cva()/tv()
288
+ cn(["flex", "items-center"])
289
+ tv({ base: ["flex", "items-center"], variants: { size: { sm: ["p-2", "text-sm"] } } })
290
+
293
291
  // Object-valued JSX attributes (e.g. Mantine classNames prop)
294
292
  <Input classNames={{ root: "flex items-center", input: "border-none" }} />
295
293
 
@@ -815,7 +813,7 @@ Detects arbitrary values that have a named Tailwind equivalent. The arbitrary fo
815
813
 
816
814
  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
815
 
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.
816
+ Unlike `no-unnecessary-arbitrary-value`, this rule fires even when the named utility produces _different_ CSS — for example, in themes that wrap the raw variable in a color function (`--color-border: hsl(var(--border))`). 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. (When the theme exposes the variable directly with no wrapping function, `border-[var(--border)]` is CSS-equivalent to `border-border` and is owned by `no-unnecessary-arbitrary-value` instead.)
819
817
 
820
818
  ```tsx
821
819
  // ❌ Bad → ✅ Fixed (when border-border is a valid utility)
@@ -843,11 +841,21 @@ The class parser correctly handles:
843
841
  ## Known limitations
844
842
 
845
843
  - **`enforce-canonical`**: Named classes are canonicalized via the precomputed map (covers everything in `getClassList()` plus a curated list of legacy v3 spellings like `break-words`, `flex-grow`, `start-N`, `bg-gradient-to-*`). Arbitrary/CSS-var forms (`p-[2px]`, `bg-(--c)`) are canonicalized dynamically via the worker. Some valid v4 classes that don't appear in `getClassList()` and have no canonical rewrite (e.g. `border-1` is valid as a dynamic numeric value but isn't enumerated) are left untouched.
846
- - **`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.
844
+ - **`no-conflicting-classes`**: Uses exact CSS property name matching plus composition heuristics: CSS-var composition (`shadow` + `ring`), narrowing-override (later class is a strict subset of earlier — handles `size-4 h-6`, `rounded-t-lg rounded-tl-sm`, `truncate text-clip`), complementary groups (gradient stops, transition family, transform axes, mask gradient family across edges/axes/`linear`/`radial`/`conic`), and composition pairs (e.g. `mask-add` + any mask gradient). Shorthand vs longhand cases where Tailwind emits the shorthand and Tailwind's longhand has a different CSS property name (e.g., `p-4` vs `px-2`: `padding` vs `padding-left`/`padding-right`) are still not detected.
847
845
  - **`no-dark-without-light`**: Groups by utility prefix heuristic. May not perfectly match all multi-part utility prefixes.
848
846
  - **`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.
849
847
  - **Component classes**: Only first-level `@import` relative paths are followed. Deeply nested imports or absolute paths are not resolved.
850
848
 
849
+ ## Supported plugins
850
+
851
+ The plugin loads classes through `@tailwindcss/node`, so any plugin imported into your CSS entry point — `@plugin '...'` or `@import '...'` — is recognized automatically by every rule. The following are exercised by the test suite:
852
+
853
+ - **[`@tailwindcss/typography`](https://github.com/tailwindlabs/tailwindcss-typography)** — `prose`, `prose-sm/lg/xl`, `not-prose`. `no-conflicting-classes` extracts only root-level CSS properties from `prose`, so utilities like `prose overflow-x-auto` aren't reported as conflicts.
854
+ - **[`tailwindcss-animate`](https://github.com/jamiebuilds/tailwindcss-animate)** — `animate-in`, `animate-out`, `fade-{in,out}-*`, `zoom-{in,out}-*`, `spin-{in,out}-*`, `slide-{in-from,out-to}-*`, `duration-*`, `delay-*`, `ease-*`, `direction-*`, `fill-mode-*`, `repeat-*`, `running`, `paused`. `animate-in`/`animate-out` initialize all `--tw-enter-*` / `--tw-exit-*` custom properties to `initial`, and modifiers (`fade-in`, `zoom-in`, `slide-in-from-*`, etc.) each override one of them; this composition is recognized by `no-conflicting-classes`.
855
+ - **[`tw-animate-css`](https://github.com/Wombosvideo/tw-animate-css)** — v4-native rewrite of `tailwindcss-animate`. Adds `blur-{in,out}-*`, logical (RTL-aware) `slide-{in-from,out-to}-{start,end}-*`, `play-state-*`, `animation-duration-*`, and the `animate-accordion-{up,down}` / `animate-collapsible-{up,down}` / `animate-caret-blink` keyframe animations used by Radix-style headless component libraries.
856
+
857
+ Other plugins that emit classes through standard `getClassList()` and CSS output should work out of the box. If you find one that doesn't, open an issue.
858
+
851
859
  ## Requirements
852
860
 
853
861
  - Node.js >= 20