stylelint
@nuxtjs/stylelint-module

用于 Nuxt 的 Stylelint 模块。一个强大、现代的 Linter,可帮助您避免错误并强制执行样式规范。

@nuxtjs/stylelint-module

npm versionnpm downloadsGithub Actions CICodecovLicense

用于 Nuxt.js 的 Stylelint 模块

📖 发布说明


注意:此分支适用于兼容 Nuxt 3Nuxt Bridge 的模块。如需 Nuxt 2 支持,请查看 nuxt2 分支


要求

您需要确保已安装 stylelint

使用 pnpm

pnpm add -D stylelint

或者,使用 yarn

yarn add -D stylelint

或者,使用 npm

npm install -D stylelint

设置

  1. @nuxtjs/stylelint-module 依赖项添加到您的项目中
npx nuxi@latest module add stylelint
  1. @nuxtjs/stylelint-module 添加到 nuxt.config.jsmodules 部分
export default {
  modules: [
    // Simple usage
    "@nuxtjs/stylelint-module",

    // With options
    [
      "@nuxtjs/stylelint-module",
      {
        /* module options */
      },
    ],
  ],
};

使用顶级选项

export default {
  modules: ["@nuxtjs/stylelint-module"],
  stylelint: {
    /* module options */
  },
};

选项

请参阅 stylelint 的选项 以获取可用选项的完整列表。这些选项将直接传递给 stylelint

缓存

  • 类型:Boolean
  • 默认值: true

注意:默认启用缓存以减少执行时间。

包含

  • 类型: String|Array[String]
  • 默认: [nuxt.options.srcDir.'/**/*.{css,scss,sass,less,styl,vue}']

指定目录、文件或 glob 模式。

exclude

  • 类型: Array[String]
  • 默认: ['**/node_modules/**', 'virtual:', nuxt.options.buildDir]

指定要排除的文件和/或目录。

stylelintPath

  • 类型: String
  • 默认: stylelint

用于 linting 的 stylelint 实例的路径。

formatter

  • 类型: Function
  • 默认: 'string'

指定您希望用于格式化结果的格式化程序。

lintOnStart

  • 类型:Boolean
  • 默认值: true

在项目启动时也检查所有匹配的文件,速度较慢,请谨慎开启。

lintDirtyOnly

  • 类型:Boolean
  • 默认值: true

Stylelint 运行时仅对更改的文件进行 lint,除了 buildStart 钩子外,禁用时将对 include 选项中指定的所有文件进行 lint。

emitWarning

  • 类型:Boolean
  • 默认值: true

将打印发现的警告。

emitError

  • 类型:Boolean
  • 默认值: true

将打印发现的错误。

failOnWarning

  • 构建器: webpack // 仅适用于 webpack 构建器
  • 类型:Boolean
  • 默认值:false

如果存在任何警告,将导致模块构建失败,基于 emitWarning

遇到错误时失败

  • 构建器: webpack // 仅适用于 webpack 构建器
  • 类型:Boolean
  • 默认值: true

如果存在任何错误,将导致模块构建失败,基于 emitError

贡献

您可以通过 CodeSandBox 在线为该模块贡献代码

Edit @nuxtjs/robots

或在本地

  1. 克隆此仓库
  2. 使用 pnpm install 安装依赖
  3. 使用 pnpm dev:prepare 准备开发服务器
  4. 使用 pnpm build 构建模块
  5. 使用 pnpm dev 启动游乐场

许可证

麻省理工学院许可证

版权所有 (c) Nuxt Modules