eslint-plugin-better-tailwindcss

auto-wraps tailwind classes after a certain print width or class count into multiple lines to improve readability.
25,410,791 851
Install
npm install eslint-plugin-better-tailwindcss
Latest Version:4.10.0
Vue:3
License:MIT
Last Updated:Oct 20, 2026
Links: GitHub  ·  npm
Maintainer: schoero
eslint-plugin-better-tailwindcss logo

eslint-plugin-better-tailwindcss



GitHub license npm version GitHub issues npm total downloads GitHub repo stars GitHub sponsors


ESLint/Oxlint plugin with formatting and linting rules to help you write cleaner, more maintainable Tailwind CSS.

The formatting rules focus on improving readability by automatically breaking up long Tailwind class strings into multiple lines and sorting/grouping them in a logical order. The linting rules enforce best practices and catch potential issues, ensuring that you're writing valid Tailwind CSS.

This plugin supports a wide range of projects, including React, Solid.js, Qwik, Svelte, Vue, Astro, Angular, HTML or plain JavaScript or TypeScript.



eslint-plugin-better-tailwindcss example


eslint-plugin-better-tailwindcss logo

Buy me a coffee | GitHub Sponsors

Help support this project.
If you or your company benefit from this project, please consider becoming a sponsor or making a one-time donation.
Your contribution will help me to maintain and develop the project.



Installation

npm i -D eslint-plugin-better-tailwindcss

Quick start

Depending on the flavor you are using, you need to install and configure the corresponding parser:



Rules

The rules are categorized into two types: stylistic and correctness.

Configs

The plugin offers three recommended configurations to help you get started quickly:

  • stylistic: Enforces stylistic rules for tailwind classes.
  • correctness: Enforces correctness rules for tailwind classes.
  • recommended: Enforces both stylistic and correctness rules.

By default:

  • stylistic rules are reported as warnings
  • correctness rules are reported as errors

You can change the severity by adding a suffix to the config name:

  • Use -error to report all rules as errors
  • Use -warn to report all rules as warnings

For example, recommended-warn will report every rule as a warning and stylistic-error will report the formatting rules as errors.

If you still use the old .eslintrc configuration format, you can prefix the config names with legacy-.

For example, legacy-recommended or legacy-correctness-warn.

The table below lists all available rules, the Tailwind CSS versions they support, and whether they are enabled by default in each recommended configuration:



Stylistic rules
Name Description tw3 tw4 recommended autofix
enforce-consistent-line-wrapping Enforce consistent line wrapping for tailwind classes. ✔ ✔ ✔ ✔
enforce-consistent-class-order Enforce a consistent order for tailwind classes. ✔ ✔ ✔ ✔
enforce-consistent-variant-order Enforce a consistent variant order for tailwind classes. ✔ ✔
enforce-consistent-variable-syntax Enforce consistent variable syntax. ✔ ✔ ✔
enforce-consistent-important-position Enforce consistent position of the important modifier. ✔ ✔ ✔
enforce-shorthand-classes Enforce shorthand class names. ✔ ✔ ✔
enforce-logical-properties Enforce logical property class names. ✔ ✔ ✔
enforce-canonical-classes Enforce canonical class names. ✔ ✔ ✔
no-duplicate-classes Remove duplicate classes. ✔ ✔ ✔ ✔
no-deprecated-classes Remove deprecated classes. ✔ ✔ ✔
no-unnecessary-whitespace Disallow unnecessary whitespace in tailwind classes. ✔ ✔ ✔ ✔
Correctness rules
Name Description tw3 tw4 recommended autofix
no-concatenated-classes Disallow concatenated classes in Tailwind CSS class strings. ✔ ✔ ✔
no-unknown-classes Report classes not registered with Tailwind CSS. ✔ ✔ ✔
no-conflicting-classes Report classes that produce conflicting styles. ✔ ✔
no-restricted-classes Disallow restricted classes. ✔ ✔ ✔


Utilities

This plugin is pre-configured to lint tailwind classes for the most popular utilities:



Advanced configuration

If an utility is not supported by default, or you want to customize the configuration, you can define which attributes, callees, variables, and tags should get linted.
See the Advanced configuration guide to learn how to override or extend the default settings.



Monorepo setup

In monorepos, linting is often started from the repository root while each package has its own Tailwind setup. You can configure settings["better-tailwindcss"].cwd per file group so the plugin resolves tailwindcss and config files from the correct project directory.

// eslint.config.js
export default [
  {
    files: ["packages/website/**/*.{js,jsx,cjs,mjs,ts,tsx}"],
    settings: {
      "better-tailwindcss": {
        cwd: "./packages/website"
      }
    }
  },
  {
    files: ["packages/app/**/*.{js,jsx,cjs,mjs,ts,tsx}"],
    settings: {
      "better-tailwindcss": {
        cwd: "./packages/app"
      }
    }
  }
];

See Settings for more details.



Editor configuration

VSCode
Auto-fix on save

Most rules are intended to automatically fix the tailwind classes using VSCode extensions.

ESLint

For ESLint, you can install the VSCode ESLint plugin and configure it to automatically fix the classes on save by adding the following options to your .vscode/settings.json:

{
  // enable VSCode to fix tailwind classes on save
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  }
}
Oxlint

For Oxlint, you can install the VSCode Oxc plugin and configure it to automatically fix the classes on save by adding the following options to your .vscode/settings.json:

{
  // enable VSCode to fix tailwind classes on save
  "editor.codeActionsOnSave": {
    "source.fixAll.oxc": "explicit"
  }
}


Related Packages

@dhzh/eslint-plugin-better-tailwindcss

auto-wraps tailwind classes after a certain print width or class count into mult...

339 1
eslint-plugin-inline-utilities

ESLint rules that keep utility classes on the element they style, for Tailwind C...

502 0
eslint-plugin-tailwind-canonical-classes

ESLint plugin to enforce canonical Tailwind CSS class names using Tailwind CSS v...

1,275,346 27
eslint-plugin-template-security

ESLint security rules for template bindings, written once for JSX, Astro, Vue, S...

743 1
create-precast-app

CLI tool to scaffold modern web applications with your chosen stack

2,096 2

Version History

Version Released License
4.10.0 MIT
4.9.1 MIT
4.9.0 MIT
4.8.0 MIT
4.7.0 MIT
Pre-releases (11)
Version Released License
4.0.0-rc.0 MIT
4.0.0-beta.6 MIT
4.0.0-beta.5 MIT
4.0.0-beta.4 MIT
4.0.0-beta.3 MIT