 @nuxtjs/stylelint-module
@nuxtjs/stylelint-module

@nuxtjs/stylelint-module
适用于 Nuxt 的 Stylelint 模块。一个强大、现代的 Linter,可帮助您避免错误并在样式中强制执行约定。
@nuxtjs/stylelint-module
适用于 Nuxt.js 的 Stylelint 模块
注意:此分支适用于兼容 Nuxt 3 或 Nuxt Bridge 的模块。如需 Nuxt 2 支持,请查看 nuxt2 分支。
要求
您需要确保已安装 stylelint
使用 pnpm
pnpm add -D stylelint
或者,使用 yarn
yarn add -D stylelint
或者,使用 npm
npm install -D stylelint
设置
- 将 @nuxtjs/stylelint-module依赖项添加到您的项目中
npx nuxi@latest module add stylelint
- 将 @nuxtjs/stylelint-module添加到nuxt.config.js的modules部分
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 在线为该模块贡献代码
或在本地
- 克隆此仓库
- 使用 pnpm install安装依赖
- 使用 pnpm dev:prepare准备开发服务器
- 使用 pnpm build构建模块
- 使用 pnpm dev启动游乐场
许可证
版权所有 (c) Nuxt Modules