🚀 Socket Launch Week 🚀 Day 3: Socket Acquires Coana.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-readable-tailwind

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-readable-tailwind

auto-wraps tailwind classes after a certain print width or class count into multiple lines to improve readability.

2.1.0
latest
Source
npm
Version published
Weekly downloads
6.5K
-31.9%
Maintainers
1
Weekly downloads
 
Created
Source
eslint-plugin-readable-tailwind logo

readable-tailwind



eslint-plugin-readable-tailwind logo eslint-plugin-readable-tailwind logo eslint-plugin-readable-tailwind logo eslint-plugin-readable-tailwind logo eslint-plugin-readable-tailwind logo eslint-plugin-readable-tailwind logo


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.



eslint-plugin-readable-tailwind example


eslint-plugin-readable-tailwind logo

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.



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.

  • 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.



Parsers

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



Rules

Two predefined configurations are available that contain the recommended rules:

  • error - will throw an error if the rule is violated
  • warning - will throw a warning if the rule is violated

The following table shows the available rules and if they are enabled by default in the different configurations:

NameDescriptionerrorwarningautofix
multilineEnforce consistent line wrapping for tailwind classes.
no-unnecessary-whitespaceDisallow unnecessary whitespace in tailwind classes.
sort-classesEnforce a consistent order for tailwind classes.
no-duplicate-classesRemove duplicate classes.


Utilities

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.



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"
  }
}


Keywords

eslint

FAQs

Package last updated on 15 Apr 2025

Did you know?

Socket

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.

Install

Related posts