
Product
Introducing Module Reachability: Focus on the Vulnerabilities That Matter
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
eslint-plugin-readable-tailwind
Advanced tools
auto-wraps tailwind classes after a certain print width or class count into multiple lines to improve readability.
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 React, Solid.js, Qwik, Svelte, Vue, Angular, HTML, JavaScript and TypeScript projects.
Buy me a coffee | GitHub Sponsors
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.
npm i -D eslint-plugin-readable-tailwind
Follow the parsers section below to learn how to configure the plugin for your specific requirements.
Configure the plugin to be able to read your tailwind configuration via settings or for each rule separately.
// eslint.config.js
{
//...
"settings": {
"readable-tailwind": {
// tailwindcss 4: the path to the entry file of the css based tailwind config (eg: `src/global.css`)
"entryPoint": "src/global.css",
// tailwindcss 3: the path to the tailwind config file (eg: `tailwind.config.js`)
"tailwindConfig": "tailwind.config.js"
}
}
}
Configure your editor to conveniently auto-fix on save.
Depending on the flavor you are using, you may need to install and configure the corresponding parser:
Two predefined configurations are available that contain the recommended rules:
error
- will throw an error if the rule is violatedwarning
- will throw a warning if the rule is violatedThe following table shows the available rules and if they are enabled by default in the different configurations:
Name | Description | error | warning | autofix |
---|---|---|---|---|
multiline | Enforce consistent line wrapping for tailwind classes. | ✔ | ✔ | ✔ |
no-unnecessary-whitespace | Disallow unnecessary whitespace in tailwind classes. | ✔ | ✔ | ✔ |
sort-classes | Enforce a consistent order for tailwind classes. | ✔ | ✔ | ✔ |
no-duplicate-classes | Remove duplicate classes. | ✔ | ✔ | ✔ |
This plugin works out of the box with most popular tailwind utilities:
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.
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"
}
}
FAQs
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 5,403 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.
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.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Company News
Socket is bringing best-in-class reachability analysis into the platform — cutting false positives, accelerating triage, and cementing our place as the leader in software supply chain security.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.