Enforces canonical Tailwind CSS class spellings with --fix support. Same suggestions as the Tailwind language server, applied repo-wide via oxlint --fix.
| Before | After |
|---|---|
mt-[16px] | mt-4 |
[color:red]/50 | text-[red]/50 |
[@media_print]:flex | print:flex |
Only rewrites the spelling of individual classes. Does not reorder, dedupe, or collapse utilities (use oxfmt sortTailwindcss for that).
npm install --save-dev oxlint oxlint-plugin-tailwind-canonical tailwindcss
Requires Tailwind CSS v4 and Node 22+.
In oxlint.config.ts:
import { defineConfig } from 'oxlint';
export default defineConfig({
jsPlugins: [
{
name: 'tailwind-canonical',
specifier: 'oxlint-plugin-tailwind-canonical',
},
],
rules: {
'tailwind-canonical/canonical-class-names': [
'warn',
{ cssPath: './src/styles.css' },
],
},
});
Then run oxlint --fix.
Options:
cssPath (required) — Tailwind v4 entry CSS, absolute or relative to cwd.rootFontSize — px value for rem normalization. Default 16.attributes — JSX attributes treated as class lists. Default ["class", "className"].calleeFunctions — helpers whose string args are treated as class lists. Default ["cn", "clsx", "cva", "twMerge", "tw", "classNames", "cx"].Strings with ${} interpolations are skipped.
MIT
2 commits
JavaScript
100.0%
Enforces canonical Tailwind CSS class spellings with --fix support. Same suggestions as the Tailwind language server, applied repo-wide via oxlint --fix.
| Before | After |
|---|---|
mt-[16px] | mt-4 |
[color:red]/50 | text-[red]/50 |
[@media_print]:flex | print:flex |
Only rewrites the spelling of individual classes. Does not reorder, dedupe, or collapse utilities (use oxfmt sortTailwindcss for that).
npm install --save-dev oxlint oxlint-plugin-tailwind-canonical tailwindcss
Requires Tailwind CSS v4 and Node 22+.
In oxlint.config.ts:
import { defineConfig } from 'oxlint';
export default defineConfig({
jsPlugins: [
{
name: 'tailwind-canonical',
specifier: 'oxlint-plugin-tailwind-canonical',
},
],
rules: {
'tailwind-canonical/canonical-class-names': [
'warn',
{ cssPath: './src/styles.css' },
],
},
});
Then run oxlint --fix.
Options:
cssPath (required) — Tailwind v4 entry CSS, absolute or relative to cwd.rootFontSize — px value for rem normalization. Default 16.attributes — JSX attributes treated as class lists. Default ["class", "className"].calleeFunctions — helpers whose string args are treated as class lists. Default ["cn", "clsx", "cva", "twMerge", "tw", "classNames", "cx"].Strings with ${} interpolations are skipped.
MIT
2 commits
JavaScript
100.0%