Skip to content

kalimahapps/eslint-plugin-tailwind

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

KalimahApps Eslint Tailwind Plugin

Provide eslint rules for tailwindcss





✨ Rules

  • @kalimahapps/tailwind/tailwind-sort: Sort tailwind classes in alphabetical order in groups
  • @kalimahapps/tailwind/tailwind-multiline: Break tailwind classes into multiple lines if they exceed the max line length (default: 80)


πŸ’½ Installation

PNPM

pnpm add eslint @kalimahapps/eslint-plugin-tailwind -D

NPM

npm install eslint @kalimahapps/eslint-plugin-tailwind -D


πŸ”§ Usage

Add this to your .eslintrc.js file

module.exports = {
 "plugins": ["@kalimahapps/eslint-plugin-tailwind"],
 "rules": {
	"@kalimahapps/tailwind/sort": "warn",
	"@kalimahapps/tailwind/multiline": "warn"
	}
}

The following options can be set to the mutiline rule:

  • maxLen: break classes as soon as the line length is longer than this (and join if the line is smaller)
  • quotesOnNewLine: put the quotes on different lines to the first and last class
module.exports = {
 "plugins": ["@kalimahapps/eslint-plugin-tailwind"],
 "rules": {
	"@kalimahapps/tailwind/sort": "warn",
	"@kalimahapps/tailwind/multiline": [
		"warn",
		{
			"maxLen": 100,
			"quotesOnNewLine": true
		}
	]
 }
}

To enable automatic formatting add this to your .vscode/settings.json file

{
 	"prettier.enable": false,
  	"editor.formatOnSave": false,
	"eslint.codeAction.showDocumentation": {
		"enable": true
	},
	"editor.codeActionsOnSave": {
		"source.fixAll.eslint": true
	},
	"eslint.validate": [
		"javascript",
		"javascriptreact",
		"typescript",
		"typescriptreact"
	],
}

You need to install ESLint extension in VSCode. You can find it here



Please note that the indentation of for the classes in multiline rule will follow the indentation of the parent. i.e. spaces will be used if the parent is using spaces and tabs will be used if the parent is using tabs

Other projects

KalimahApps Eslint Config

Comprehensive eslint rules for vue projects with typescript

Vue Icons

60,000+ SVG icons from popular icon sets that you can add seamlessly to your vue projects

Vue Popper

A tooltip component for Vue 3 based on popper.js

Vite inherit attrs

A vite plugin that adds support for inheritAttrs in vue-setup



License

MIT License

About

ESLint plugin to sort tailwind classes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published