@nuxtjs/stylelint-module

@nuxtjs/stylelint-module
用於 Nuxt 的 Stylelint 模組。一個強大、現代的 linter,可協助您避免錯誤並在樣式中強制執行慣例。
@nuxtjs/stylelint-module
用於 Nuxt.js 的 Stylelint 模組
注意: 此分支適用於Nuxt 3或Nuxt Bridge相容的模組。請查看nuxt2
分支以取得 Nuxt 2 的支援。
需求
您需要確保已安裝 stylelint
使用 pnpm
pnpm add -D stylelint
或,使用 yarn
yarn add -D stylelint
或,使用 npm
npm install -D stylelint
注意: 目前,此模組僅在使用 vite 時與最新版本的 16 stylelint
相容,尚未實作對 webpack 的支援(請參閱 https://github.com/webpack-contrib/stylelint-webpack-plugin/issues/342)。
設定
- 將
@nuxtjs/stylelint-module
依賴項新增至您的專案
使用 pnpm
pnpm add -D @nuxtjs/stylelint-module
或,使用 yarn
yarn add -D @nuxtjs/stylelint-module
或,使用 npm
npm install -D @nuxtjs/stylelint-module
- 將
@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
。
cache
- 類型:
Boolean
- 預設值:
true
注意:預設會啟用快取以減少執行時間。
include
- 類型:
String|Array[String]
- 預設值:
[nuxt.options.srcDir.'/**/*.{css,scss,sass,less,styl,vue}']
指定目錄、檔案或 glob。
exclude
- 類型:
Array[String]
- 預設值:
['**/node_modules/**', 'virtual:', nuxt.options.buildDir]
指定要排除的檔案和/或目錄。
stylelintPath
- 類型:
String
- 預設值:
stylelint
將用於 linting 的 stylelint
實例的路徑。
formatter
- 類型:
Function
- 預設值:
'string'
指定您想要用來格式化結果的格式器。
lintOnStart
- 類型:
Boolean
- 預設值:
true
也在專案啟動時檢查所有相符的檔案,速度太慢,請謹慎開啟。
lintDirtyOnly
- 類型:
Boolean
- 預設值:
true
除了 buildStart hook 之外,只在執行 Stylelint 時檢查變更的檔案,當停用時,將會檢查來自 include
選項的所有指定檔案。
emitWarning
- 類型:
Boolean
- 預設值:
true
將會印出找到的警告。
emitError
- 類型:
Boolean
- 預設值:
true
將會印出找到的錯誤。
failOnWarning
- 類型:
Boolean
- 預設值:
false
如果存在任何警告,根據 emitWarning
,將會導致模組建置失敗。
failOnError
- 類型:
Boolean
- 預設值:
true
如果存在任何錯誤,根據 emitError
,將會導致模組建置失敗。
貢獻
您可以使用 CodeSandBox 線上為此模組做出貢獻
或在本地端
- 複製此儲存庫
- 使用
pnpm install
安裝依賴項 - 使用
pnpm dev:prepare
準備開發伺服器 - 使用
pnpm build
建置模組 - 使用
pnpm dev
啟動 playground
授權
Copyright (c) Nuxt Modules