有沒有辦法停止從 ESLint 獲取 Vue3 中單個單詞視圖名稱的錯誤?
每次運行 ESLint 時,都會收到以下訊息:
1:1 error Component name "About" should always be multi-word vue/multi-word-component-names
我目前有這個設定:
檔案結構:
├── index.html
├── node_modules
├── npm
├── package.json
├── package-lock.json
├── public
│ └── favicon.ico
├── README.md
├── src
│ ├── App.vue
│ ├── assets
│ │ └── logo.svg
│ ├── components
│ │ └── Menu.vue
│ ├── env.d.ts
│ ├── main.ts
│ ├── router
│ │ └── index.ts
│ └── views
│ ├── About.vue
│ └── Home.vue
├── tsconfig.json
└── vite.config.ts
.eslintrc:
{
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/typescript/recommended"
],
"parserOptions": {
"ecmaVersion": 2021
},
"rules": {}
}
包.json
{
...
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"lint": "eslint --ext .ts,vue --ignore-path .gitignore ."
},
...
}
uj5u.com熱心網友回復:
ESLint 支持按目錄配置,因此您可以僅針對src/views具有自己的目錄的目錄禁用該特定規則.eslintrc.js:
// src/views/.eslintrc.js
module.exports = {
rules: {
'vue/multi-word-component-names': 0, // disable this rule just for views
},
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/381422.html
標籤:Vue.js Vue路由器 eslint Vuejs3 维特
上一篇:Vuex引數傳遞
