透過 100 多個訣竅學習 Nuxt!

eslint-module
@nuxtjs/eslint-module

用於 Nuxt 的 ESLint 模組

@nuxtjs/eslint-module

npm versionnpm downloadsGithub Actions CICodecovLicense

用於 Nuxt 的 ESLint 模組

📖 發行說明


注意: 此分支適用於Nuxt 3Nuxt Bridge 相容模組。請查看 nuxt2 分支 以取得 Nuxt 2 支援。


需求

您需要確保已安裝 eslint >= 7

使用 pnpm

pnpm add -D eslint

或,使用 yarn

yarn add -D eslint

或,使用 npm

npm install -D eslint

設定

  1. @nuxtjs/eslint-module 依賴項加入您的專案

使用 pnpm

pnpm add -D @nuxtjs/eslint-module

或,使用 yarn

yarn add -D @nuxtjs/eslint-module

或,使用 npm

npm install -D @nuxtjs/eslint-module
  1. @nuxtjs/eslint-module 加入 nuxt.config.tsmodules 區段
export default defineNuxtConfig({
  modules: [
    // Simple usage
    '@nuxtjs/eslint-module',

    // With options
    ['@nuxtjs/eslint-module', { /* module options */ }]
  ]
})

使用頂層選項

export default defineNuxtConfig({
  modules: [
    '@nuxtjs/eslint-module'
  ],
  eslint: {
    /* module options */
  }
})

選項

您可以傳遞 eslint 選項

請注意,您提供的 config 選項將會傳遞至 ESLint 類別。這與您在 package.json.eslintrc 中指定的選項不同。請參閱 eslint 文件 以取得更多詳細資訊。

cache

  • 類型:Boolean
  • 預設值:true

注意:預設啟用快取以減少執行時間。

include

  • 類型:String|Array[String]
  • 預設值:[nuxt.options.srcDir.'/**/*.{js,jsx,ts,tsx,vue}']

指定目錄、檔案或 glob 模式。

exclude

  • 類型:Array[String]
  • 預設值:['**/node_modules/**', nuxt.options.buildDir]

指定要排除的檔案和/或目錄。

eslintPath

  • 類型:String
  • 預設值:eslint

將用於 lint 的 eslint 執行個體的路徑。

formatter

  • 類型:String|Function
  • 預設值:'stylish'

接受一個函式,該函式將有一個引數:eslint 訊息 (物件) 的陣列。此函式必須以字串形式傳回輸出。您可以使用官方的 eslint 格式化工具

lintOnStart

  • 類型:Boolean
  • 預設值:true

在專案啟動時檢查所有符合的檔案,速度太慢,請謹慎開啟。

emitWarning

  • 類型:Boolean
  • 預設值:true

將會印出發現的警告。

emitError

  • 類型:Boolean
  • 預設值:true

將會印出發現的錯誤。

failOnWarning

  • 類型:Boolean
  • 預設值:false

如果根據 emitWarning 有任何警告,將導致模組建置失敗。

failOnError

  • 類型:Boolean
  • 預設值:false

如果根據 emitError 有任何錯誤,將導致模組建置失敗。

貢獻

您可以使用 CodeSandBox 線上為此模組做出貢獻

Edit @nuxtjs/robots

或在本地端

  1. 複製此儲存庫
  2. 使用 pnpm install 安裝依賴項
  3. 使用 pnpm dev:prepare 準備開發伺服器
  4. 使用 pnpm build 建置模組
  5. 使用 pnpm dev 啟動遊樂場

授權許可

MIT 授權許可

版權所有 (c) Nuxt Community