Performant Tailwind CSS linting rules for OxLint. 5 rules ported from eslint-plugin-tailwindcss with pre-computed class matching — 425x faster.
Zero runtime Tailwind compilation. Works out of the box with default Tailwind v3/v4.
Running eslint-plugin-tailwindcss through OxLint's JS plugin API takes 39 minutes on a 37K file monorepo because it compiles the entire Tailwind class registry at runtime for every file.
This plugin uses pre-computed regex matching against Tailwind's class taxonomy instead. Same rules, same detections, 5 seconds instead of 39 minutes.
| Approach | 37K files | Per file |
|---|---|---|
| eslint-plugin-tailwindcss via OxLint jsPlugin | 39 min | 63ms |
| oxlint-plugin-tailwindcss | 5s | 0.13ms |
| Rule | What it catches | Auto-fix |
|---|---|---|
enforces-shorthand |
mx-3 my-3 → m-3 |
Yes |
enforces-negative-arbitrary-values |
Invalid -top-[400px] syntax |
No |
migration-from-tailwind-2 |
Deprecated TW2 classes (filter, flex-grow, overflow-clip) |
Partial |
no-contradicting-classname |
w-3 w-5, text-red-500 text-blue-500 |
No |
no-custom-classname |
Non-Tailwind classes | No |
npm install -D oxlint-plugin-tailwindcss
# or
pnpm add -D oxlint-plugin-tailwindcssAdd to your .oxlintrc.json:
{
"jsPlugins": [
{ "name": "tailwindcss", "specifier": "oxlint-plugin-tailwindcss" }
],
"rules": {
"tailwindcss/enforces-shorthand": "warn",
"tailwindcss/enforces-negative-arbitrary-values": "warn",
"tailwindcss/migration-from-tailwind-2": "warn",
"tailwindcss/no-contradicting-classname": "warn",
"tailwindcss/no-custom-classname": "warn"
}
}By default, the plugin checks className attributes and calls to classnames, clsx, ctl, and twClassNames. To add your own:
{
"settings": {
"tailwindcss": {
"callees": ["twClassNames", "cx", "myClassHelper"]
}
}
}The original eslint-plugin-tailwindcss calls tailwindcss.createContext() to generate all possible Tailwind classes at runtime. This is thorough but extremely slow.
This plugin takes a different approach:
-
Static class taxonomy — a 1,400+ line regex pattern map covering every Tailwind utility class (layout, spacing, typography, colors, etc.). Sourced from eslint-plugin-tailwindcss's
groups.js(MIT, by François Massart). -
Compact color regex — instead of listing every color shade (
slate-50|slate-100|...|rose-950), uses a pattern matching Tailwind's naming convention:[a-z]+-<shade>with optional/<opacity>. This keeps V8's regex engine happy while covering all color classes. -
Cached config resolution — Tailwind config is resolved once and cached for the entire lint run. No per-file compilation.
-
Standard ESLint plugin API — works with OxLint's JS plugin system. Same
context.report(), visitor pattern, and fixer API.
// Before
<div className="mx-3 my-3" /> // → "m-3"
<div className="pt-2 pr-2 pb-2 pl-2" /> // → "p-2"
// Detects shorthand opportunities for:
// padding, margin, gap, overflow, border-radius,
// border-width, border-color, border-spacing, scale// Caught
<div className="w-3 w-5" /> // width conflict
<div className="text-red-500 text-blue-500" /> // color conflict
<div className="p-4 p-8" /> // padding conflict// Deprecated in Tailwind v3
<div className="filter" /> // removed — no longer needed
<div className="flex-grow" /> // → "grow"
<div className="overflow-clip" /> // → "text-clip"
<div className="decoration-clone" /> // → "box-decoration-clone"// Caught — not a Tailwind class
<div className="my-bogus-class" />
<div className="custom-padding" />
// OK — valid Tailwind
<div className="p-4 text-red-500 hover:bg-blue-200" />// Caught — invalid syntax
<div className="-top-[400px]" /> // should use negative modifier differently
<div className="-scale-[1.5]" />- Color regex approximation — uses
[a-z]+-<shade>pattern instead of listing every Tailwind color name. May match non-standard names likefoo-500. In practice, false positives are rare. - No
tailwind.config.jscustom theme — custom colors/spacing added viaextend.themeare not detected byno-custom-classname. Add them to the whitelist setting. - No
classnames-orderrule — class ordering is better handled by formatters like OxFmt (sortTailwindcss) or Prettier (prettier-plugin-tailwindcss).
- Class taxonomy (
util/groups.js) from eslint-plugin-tailwindcss by François Massart (MIT License). - Ported for OxLint by Kaustubh Saxena.
MIT