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

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

包含

  • 类型:字符串|字符串数组
  • 默认值:[nuxt.options.srcDir.'/**/*.{css,scss,sass,less,styl,vue}']

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

exclude

  • 类型:字符串数组
  • 默认值:['**/node_modules/**', 'virtual:', nuxt.options.buildDir]

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

stylelint路径

  • 类型:字符串
  • 默认值:stylelint

stylelint 实例的路径,将用于 linting。

格式化器

  • 类型:函数
  • 默认值:'string'

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

启动时 lint

  • 类型:Boolean
  • 默认值: true

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

仅检查脏文件

  • 类型:Boolean
  • 默认值: true

仅在运行 Stylelint 时检查已更改的文件,buildStart 钩子除外,禁用时将检查 include 选项中指定的所有文件。

发出警告

  • 类型:Boolean
  • 默认值: true

找到的警告将被打印。

发出错误

  • 类型:Boolean
  • 默认值: true

找到的错误将被打印。

遇到警告时失败

  • 构建器: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