百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

eslint-plugin-tailwindcss

> 前端框架
开源

用于 Tailwind CSS 使用的 ESLint 插件

2.1K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于 Tailwind CSS 使用的 ESLint 插件

# `eslint-plugin-tailwindcss` - Best practices & consistency since 2021 - [Made for Tailwind CSS v4](./CHANGELOG.md#made-for-tailwind-css-v4) - [9 rules available](#rules) and more on the way - What's new? [Changelog](./CHANGELOG.md) | [Release notes](https://github.com/francoismassart/eslint-plugin-tailwindcss/releases) | [Roadmap](./ROADMAP.md) - [Upgrade guide](./UPGRADE.md) from `v3` to `v4` ## This project needs your help

I spent countless days working on this plugin, and it is available to everyone for free.
If you benefit from my work and if you want to help me keep the project alive, consider becoming a sponsor.

| Premium sponsors | Current sponsors | | :--------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | | |

GitHub Sponsors | thanks.dev Sponsors

## Rules Configurations enabled in.\ ⚠️ Configurations set to warn in.\ ✅ Set in the `recommended` configuration.\ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\ Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). | Name                               | Description | | ⚠️ | | | | :------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------- | :-- | :-- | :-- | :-- | | [classnames-order](docs/rules/classnames-order.md) | Enforces a consistent order for the Tailwind CSS classnames, based on the compiler. | | ✅ | | | | [enforces-canonical-classname](docs/rules/enforces-canonical-classname.md) | Enforces the canonical spelling of a classname, as resolved by the Tailwind CSS compiler. | | ✅ | | | | [enforces-negative-arbitrary-values](docs/rules/enforces-negative-arbitrary-values.md) | Warns about `-` prefixed classnames using arbitrary values. | | ✅ | | | | [enforces-shorthand](docs/rules/enforces-shorthand.md) | Avoid using multiple Tailwind CSS classnames when not required. | | ✅ | | | | [important-modifier-suffix](docs/rules/important-modifier-suffix.md) | In v4 you should place the `!` at the very end of the class name. | | ✅ | | | | [no-arbitrary-value](docs/rules/no-arbitrary-value.md) | Forbid using arbitrary values in classnames. | | | | | | [no-contradicting-classname](docs/rules/no-contradicting-classname.md) | Avoid contradicting Tailwind CSS classnames. | ✅ | | | | | [no-custom-classname](docs/rules/no-custom-classname.md) | Detects classnames which do not belong to Tailwind CSS. | | ✅ | | | | [no-unnecessary-arbitrary-value](docs/rules/no-unnecessary-arbitrary-value.md) | Avoid unjustified arbitrary classnames. | | ✅ | | | ## Getting started ### 1. Install the plugin `npm i -D eslint-plugin-tailwindcss` - As it is a dev dependency, it will not affect your final bundle size - It can be installed with other package managers such as `pnpm` - We support ESLint v10 > If you are still using Tailwind CSS v3 and/or older ESLint versions, you can use `[email protected]` ### 2. Edit your `eslint.config` file Here is a very basic example: ``` … ``` > `cssConfigPath` can be an absolute or a relative path. If you provide a relative path, the plugin will attempt to convert it into an absolute path. #### Typesafe settings The plugin also exports the type `PluginSettings` which you can use to benefit from autocomplete and validation directly inside your `eslint.config` file. 1. You may need to add `// @ts-check` to force type checking 2. Add the magic JSDoc comment `/** @type {import('eslint-plugin-tailwindcss').PluginSettings} */` Here is a snippet, notice the object is surrounded by parentheses `({...})`: ```js settings: { tailwindcss: /** @type {import('eslint-plugin-tailwindcss').PluginSettings} */ ({ cssConfigPath: './styles/tailwind.css', }), }, ``` ### 3. Going further You can also: - Run the linting process inside a pipeline of your hosted repository. I recommend running it on your merge/pull requests, rather than on every single (pre-)commit. - Auto-format on save in your favorite IDE. ## Settings Most of the rules solely use the shared settings (shared across all the plugin rules). [Learn about eslint shared settings](https://eslint.org/docs/latest/use/configure/configuration-files#configuring-shared-settings) from the official documentation. Here is a fully detailed example of shared settings: ``` … ``` The default settings are exported via the [`DEFAULT_SETTINGS`](src/utils/parse-plugin-settings.ts). ## Contributing The project is open to all developers, you can [contribute to `eslint-plugin-tailwindcss`](CONTRIBUTING.md). However, make sure to discuss the issue or the feature you wish to implement prior to getting to work unless you feel adventurous.

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •Best practices & consistency since 2021
  • •Made for Tailwind CSS v4
  • •9 rules available and more on the way
  • •What's new? Changelog | Release notes | Roadmap
  • •Upgrade guide from v3 to v4
  • •As it is a dev dependency, it will not affect your final bundle size
  • •It can be installed with other package managers such as pnpm
  • •We support ESLint v10
  • •Run the linting process inside a pipeline of your hosted repository. I recommend running it on your merge/pull requests, rather than on every single (pre-)commit.
  • •Auto-format on save in your favorite IDE.

> 标签

TypeScripteslint-pluginrulestailwindtailwindcss

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架