oxlint-tailwindcss 0.1.10 → 0.3.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,12 +1,12 @@
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 zero-config auto-detection, typo suggestions, and autofixes.
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.
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
 
7
7
  ## Highlights
8
8
 
9
- - **Zero config** — Auto-detects your Tailwind CSS entry point. Works out of the box.
9
+ - **Works out of the box** — Auto-detects your Tailwind CSS entry point. Fully configurable when needed.
10
10
  - **Fast** — Native oxlint plugin with a shared design system cache. Loads once, used by all rules.
11
11
  - **Tailwind CSS v4** — Designed for v4 from day one.
12
12
  - **Typo suggestions** — `itms-center` → "Did you mean `items-center`?"
@@ -14,6 +14,7 @@ Read the story behind this plugin: [oxlint-tailwindcss: The Linting Plugin Tailw
14
14
  - **Lightweight** — Only 2 runtime dependencies: `@tailwindcss/node` and `tailwindcss`.
15
15
  - **22 rules** — Correctness, style, complexity, and restriction rules with autofixes where possible.
16
16
  - **Variable detection** — Lints variables named `className`, `classes`, `style` automatically.
17
+ - **Customizable** — Extend class detection with custom attributes, callees, tags, and variable patterns.
17
18
  - **Component class support** — Recognizes `@layer components { .btn {} }` in your CSS.
18
19
 
19
20
  ## Installation
@@ -74,7 +75,7 @@ assets/{name}.css assets/css/{name}.css resources/css/{name}.css
74
75
 
75
76
  Where `{name}` is one of: `app`, `globals`, `global`, `style`, `styles`, `index`, `main`, `tailwind`, `tailwindcss`.
76
77
 
77
- The search is monorepo-aware — it stops at `package.json` boundaries so each package resolves its own Tailwind config.
78
+ The search is monorepo-aware — it stops at `package.json` boundaries so each package resolves its own Tailwind config. 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'`).
78
79
 
79
80
  If auto-detection doesn't find your CSS file, set `entryPoint` once in `settings`:
80
81
 
@@ -109,6 +110,55 @@ Resolution order: rule option > `settings.tailwindcss.entryPoint` > auto-detect.
109
110
 
110
111
  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.
111
112
 
113
+ ## Custom class detection
114
+
115
+ By default the plugin detects Tailwind classes in `className`/`class` attributes, 14 utility functions (`cn`, `clsx`, `cva`, `tv`, `classed`, etc.), `tw` tagged templates, and variables named `className`/`classes`/`style`.
116
+
117
+ You can extend these defaults via `settings.tailwindcss`. All values are **additive** — your custom entries are appended to the built-in defaults:
118
+
119
+ ```jsonc
120
+ {
121
+ "jsPlugins": ["oxlint-tailwindcss"],
122
+ "settings": {
123
+ "tailwindcss": {
124
+ // Additional JSX attribute names to scan
125
+ "attributes": ["xyzClassName", "classNames", "overlayClassName"],
126
+ // Additional function names to scan
127
+ "callees": ["myHelper"],
128
+ // Additional tagged template tags to scan
129
+ "tags": ["css"],
130
+ // Additional regex patterns for variable names (as strings)
131
+ "variablePatterns": ["^tw"],
132
+ },
133
+ },
134
+ "rules": {
135
+ "tailwindcss/no-unknown-classes": "error",
136
+ // ...
137
+ },
138
+ }
139
+ ```
140
+
141
+ This applies to all 22 rules at once. For example, adding `"classNames"` to `attributes` makes every rule lint `<Input classNames={{ root: "..." }} />`.
142
+
143
+ To **remove** specific items from the built-in defaults, use `exclude`:
144
+
145
+ ```jsonc
146
+ {
147
+ "settings": {
148
+ "tailwindcss": {
149
+ "exclude": {
150
+ // Stop scanning variables named "style" / "styles"
151
+ "variablePatterns": ["^styles?$"],
152
+ // Stop scanning a specific callee
153
+ "callees": ["objstr"],
154
+ },
155
+ },
156
+ },
157
+ }
158
+ ```
159
+
160
+ For `variablePatterns`, exclusions match against the regex source (e.g. `"^styles?$"` removes the default `/^styles?$/` pattern).
161
+
112
162
  ## Supported patterns
113
163
 
114
164
  The plugin extracts Tailwind classes from:
@@ -153,6 +203,16 @@ tv({
153
203
  ],
154
204
  })
155
205
 
206
+ // classed() (tw-classed) — skips element type, extracts classes and cva-like config
207
+ classed("button", "flex items-center", {
208
+ variants: {
209
+ color: { primary: "bg-blue-500", secondary: "bg-gray-500" },
210
+ },
211
+ })
212
+
213
+ // Object-valued JSX attributes (e.g. Mantine classNames prop)
214
+ <Input classNames={{ root: "flex items-center", input: "border-none" }} />
215
+
156
216
  // Tagged templates
157
217
  const styles = tw`flex items-center hover:bg-blue-500`
158
218