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