@dreamsicle.io/stylelint-config-tailwindcss

中文文档
1.3.2发布于 2026/11/06MITES Module零依赖构建来源已验证近 30 天下载 4.7万

A stylelint configuration for Tailwind CSS projects.

原始使用文档
文档目录12 节
  1. Getting started
  2. Install the package
  3. Include in your Stylelint config
  4. Exports
  5. Accessing specific keys
  6. Compatibility
  7. Development
  8. Start
  9. Build
  10. Test
  11. Fix
  12. Clean

Stylelint Config: Tailwind CSS

Awesome Stylelint NPM Downloads

A Stylelint configuration for Tailwind CSS projects. Developed specifically for Tailwind CSS v4+ and Stylelint v16.17+ utilizing the new syntax languageOptions, this configuration was created because most of the other popular Stylelint configurations for Tailwind CSS simply ignore directives and functions. Instead, this config implements all Tailwind CSS directives and functions as syntax for Stylelint's language options; so not only can you use them without Stylelint complaining, but Stylelint will actually help to ensure you are using them correctly.

Getting started

Install the package

npm install --save-dev @dreamsicle.io/stylelint-config-tailwindcss

Include in your Stylelint config

/**
 * @type {import("stylelint").Config}
 */
const stylelintConfig = {
    extends: [
        "stylelint-config-standard",
        "@dreamsicle.io/stylelint-config-tailwindcss",
    ],
};

export default stylelintConfig;

Exports

This package exports both an ESM module and a Common JS module. The default export is the ESM module.

  • dist/stylelint.config.mjs - ESM
  • dist/stylelint.config.cjs - Common JS

Accessing specific keys

You can also decide to spread the imported config onto your stylelint object to extend languageOptions, languageOptions.syntax, languageOptions.syntax.types, languageOptions.syntax.properties, or languageOptions.syntax.atRules. Below is an example of how to fully spread everything provided by this config.

import configTailwindcss from "@dreamsicle.io/stylelint-config-tailwindcss/dist/stylelint.config.mjs";

/**
 * @type {import("stylelint").Config}
 */
const stylelintConfig = {
    extends: [
        "stylelint-config-standard",
    ],
    languageOptions: {
        ...configTailwindcss.languageOptions,
        syntax: {
            ...configTailwindcss.languageOptions.syntax,
            types: {
                ...configTailwindcss.languageOptions.syntax.types,
            },
            properties: {
                ...configTailwindcss.languageOptions.syntax.properties,
            },
            atRules: {
                ...configTailwindcss.languageOptions.syntax.atRules,
            },
        }
    },
    rules: {
        ...configTailwindcss.rules,
    }
};

export default stylelintConfig;

Note: All types, properties, at-rules and Stylelint rules are required for this configuration to function properly. There are no stylistic rules provided by it, as it inly includes what is needed to make Stylelint play well with Tailwind CSS.

Compatibility

This configuration is intended for use with Tailwind CSS v4+. However, Tailwind's documentation states that some old directives may still be used for compatibility. While this is out of the scope of this configuration, you can continue to use legacy directives like @config and @plugin by including them in languageOptions.syntax manually.

/**
 * @type {import("stylelint").Config}
 */
const stylelintConfig = {
    extends: [
        "stylelint-config-standard",
        "@dreamsicle.io/stylelint-config-tailwindcss",
    ],
    languageOptions: {
        syntax: {
            atRules: {
                /**
                 * @see https://tailwindcss.com/docs/functions-and-directives#config-directive
                 */
                config: {
                    prelude: "<string>",
                },
                /**
                 * @see https://tailwindcss.com/docs/functions-and-directives#plugin-directive
                 */
                plugin: {
                    prelude: "<string>",
                },
            },
        },
    },
};

Note: The theme() function is deprecated and should not be used. Use CSS theme variables instead.

Development

This package has a build script that will generate only the syntax needed to override Stylelint's language options to suport Tailwind CSS functions and directives. This works by upgrading syntax from CSS Tree including the latest patches provided by @csstools/css-syntax-patches-for-csstree, which are the same packages Stylelint uses under the hood.

This is accomplished using our SyntaxGenerator class, used through a Rollup plugin. The contents of these files are built to the syntax directory, then imported and built through rollup into an ESM module and a Common JS module located in the dist directory.

The contents of these files are passed to Stylelint's languageOptions.syntax through the config template found at src/stylelint.config.mjs. The generation of types, properties, and at-rules allows for automatic upgrading of CSS syntax to accept Tailwind CSS properties where they are accepted in the least destructive and most maintainable way possible.

Start

npm start

Note: This script will run rollup in watch mode, so that changes to the config template automatically rebuild.

Build

npm run build

Note: This script will run rollup to create a build, exiting on completion.

Test

npm test

Note: This will run stylelint against any CSS files found in the tests directory.

Fix

npm run fix

Note: This will run stylelint in fix mode against any CSS files found in the tests directory.

Clean

npm run clean

Note: This will clean all built files and dependencies.

版本与发布记录

@dreamsicle.io/stylelint-config-tailwindcss 共发布 21 个版本,首次发布于 2025/10/28;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.3.2latest2026/11/067 天前
1.3.12026/11/067 天前
1.3.02026/11/067 天前
1.2.22026/01/269 个月前
1.2.12026/01/259 个月前
1.2.02026/01/259 个月前

关于 @dreamsicle.io/stylelint-config-tailwindcss 的常见问题

@dreamsicle.io/stylelint-config-tailwindcss 是什么?

A stylelint configuration for Tailwind CSS projects.

如何安装 @dreamsicle.io/stylelint-config-tailwindcss?

在项目目录运行 npm install @dreamsicle.io/stylelint-config-tailwindcss,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:stylelint(^16.17.0 || ^17.0.0 || ^18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dreamsicle.io/stylelint-config-tailwindcss 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dreamsicle.io__stylelint-config-tailwindcss 是否存在。

@dreamsicle.io/stylelint-config-tailwindcss 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dreamsicle.io/stylelint-config-tailwindcss 可以商用吗?

@dreamsicle.io/stylelint-config-tailwindcss 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dreamsicle.io/stylelint-config-tailwindcss 的下载量有多少?

根据 npm 官方下载统计,@dreamsicle.io/stylelint-config-tailwindcss 在 2026/10/13 – 2026/11/11 这 30 天内被下载 46,570 次,日均约 1,552 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dreamsicle.io/stylelint-config-tailwindcss 还在维护吗?

最新版本 1.3.2 发布于 2026/11/06(7 天前);至今共发布 21 个版本,其中过去 12 个月发布了 6 个;首次发布于 2025/10/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。