oxlint-tailwindcss 0.1.9 → 0.2.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 +43 -0
- package/dist/index.cjs +226 -322
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +226 -322
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
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.
|
|
4
4
|
|
|
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
|
+
|
|
5
7
|
## Highlights
|
|
6
8
|
|
|
7
9
|
- **Zero config** — Auto-detects your Tailwind CSS entry point. Works out of the box.
|
|
@@ -12,6 +14,7 @@
|
|
|
12
14
|
- **Lightweight** — Only 2 runtime dependencies: `@tailwindcss/node` and `tailwindcss`.
|
|
13
15
|
- **22 rules** — Correctness, style, complexity, and restriction rules with autofixes where possible.
|
|
14
16
|
- **Variable detection** — Lints variables named `className`, `classes`, `style` automatically.
|
|
17
|
+
- **Customizable** — Extend class detection with custom attributes, callees, tags, and variable patterns.
|
|
15
18
|
- **Component class support** — Recognizes `@layer components { .btn {} }` in your CSS.
|
|
16
19
|
|
|
17
20
|
## Installation
|
|
@@ -107,6 +110,36 @@ Resolution order: rule option > `settings.tailwindcss.entryPoint` > auto-detect.
|
|
|
107
110
|
|
|
108
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.
|
|
109
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
|
+
|
|
110
143
|
## Supported patterns
|
|
111
144
|
|
|
112
145
|
The plugin extracts Tailwind classes from:
|
|
@@ -151,6 +184,16 @@ tv({
|
|
|
151
184
|
],
|
|
152
185
|
})
|
|
153
186
|
|
|
187
|
+
// classed() (tw-classed) — skips element type, extracts classes and cva-like config
|
|
188
|
+
classed("button", "flex items-center", {
|
|
189
|
+
variants: {
|
|
190
|
+
color: { primary: "bg-blue-500", secondary: "bg-gray-500" },
|
|
191
|
+
},
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
// Object-valued JSX attributes (e.g. Mantine classNames prop)
|
|
195
|
+
<Input classNames={{ root: "flex items-center", input: "border-none" }} />
|
|
196
|
+
|
|
154
197
|
// Tagged templates
|
|
155
198
|
const styles = tw`flex items-center hover:bg-blue-500`
|
|
156
199
|
|