eslint-module
@nuxtjs/eslint-module

Nuxt 的 ESLint 模組

@nuxtjs/eslint-module

npm versionnpm downloadsGithub Actions CICodecovLicense

Nuxt 的 ESLint 模組

📖 釋出說明


注意: 此分支是用於相容 Nuxt 3Nuxt Bridge 的模組。如需 Nuxt 2 支援,請檢視 nuxt2 分支


要求

您需要確保已安裝 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 選項

請注意,您提供的配置選項將傳遞給 ESLint 類。這與您在 package.json.eslintrc 中指定的選項集不同。更多詳情請參閱 eslint 文件

快取

  • 型別:Boolean
  • 預設值: true

注意:預設啟用快取以縮短執行時間。

包含

  • 型別: 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 導致模組構建失敗。

遇到錯誤時失敗

  • 型別:Boolean
  • 預設值:false

如果存在任何錯誤,將根據 emitError 導致模組構建失敗。

貢獻

您可以透過 CodeSandBox 線上為該模組貢獻程式碼

Edit @nuxtjs/robots

或在本地

  1. 克隆此倉庫
  2. 使用 pnpm install 安裝依賴
  3. 使用 pnpm dev:prepare 準備開發伺服器
  4. 使用 pnpm build 構建模組
  5. 使用 pnpm dev 啟動遊樂場

許可證

麻省理工學院許可證

版權所有 (c) Nuxt Community