ESLint plugin to automatically break up long tailwind class strings into multiple lines based on a specified print width or class count. This improves readability and eliminates horizontal scrolling.
In addition it sorts the classes logically, removes unnecessary whitespaces and duplicate classes and groups the classes by their variants. It works in jsx, svelte, vue, and html files.
This project is financed by the community.
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-readable-tailwind
Quick start
Follow the Parsers section below to learn how to configure the plugin for your specific requirements.
Read the Rules section to learn about the available rules and how to configure them.
In case an utility is not supported or you have built your own, you can change which literals will get linted for each rule.
Read the API documentation to learn how to override or extend the default config.
Editor configuration
VSCode
Auto-fix on save
All rules are intended to automatically fix the tailwind classes. If you have installed the VSCode ESLint plugin, you can configure it to automatically fix the classes on save by adding the following options to your .vscode/settings.json:
{
// enable ESLint to fix tailwind classes on save
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
v2.0.0
Adds tailwindcss v4 support while keeping support for tailwindcss v3. (#78)
This version contains breaking changes. Most notably support for Node.js < 20 had to be dropped. The other breaking changes are mostly just changes of the default config, that may cause linting errors.
Migration
If you use tailwindcss v4, you should specify the entryPoint of the css based tailwind configuration file for the sort-classes rule or in the settings.
If you have customized the classAttributes option for any of the rules or via the settings, rename the option to attributes
If you have customized attributes, callees, variables, or tags, escape any reserved characters for regular expressions in the name as the name is now evaluated as a regular expression.
"Names" can now be regular expressions. This is a breaking change, if you have names configured that contain reserved characters in regular expressions like $.
auto-wraps tailwind classes after a certain print width or class count into multiple lines to improve readability.
The npm package eslint-plugin-readable-tailwind receives a total of 10,310 weekly downloads. As such, eslint-plugin-readable-tailwind popularity was classified as popular.
We found that eslint-plugin-readable-tailwind demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.
Package last updated on 08 Mar 2025
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.
The Socket Research Team investigates a malicious Python typosquat of a popular password library that forces Windows shutdowns when input is incorrect.