@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'
指定您想要用來格式化結果的 formatter。
lintOnStart
- 類型:
Boolean
- 預設值:
true
也在專案啟動時檢查所有相符的檔案,速度太慢,請謹慎開啟。
lintDirtyOnly
- 類型:
Boolean
- 預設值:
true
僅在執行 Stylelint 時檢查變更的檔案,但從 buildStart hook 除外,停用時將檢查 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
授權條款
版權所有 (c) Nuxt Modules