亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

ESLint Vue 多字組件
P粉349222772
P粉349222772 2024-03-25 17:26:59
0
2
753

有沒有辦法阻止 Vue3 中的單字 view 名稱從 ESLint 取得錯(cuò)誤?

每次執(zhí)行 ESLint 時(shí),我都會(huì)收到以下訊息:

  1:1  error  Component name "About" should always be multi-word  vue/multi-word-component-names

我目前有這樣的設(shè)定:

檔案結(jié)構(gòu):

├── 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": {}
}

package.json

{
...
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc --noEmit && vite build",
    "preview": "vite preview",
    "lint": "eslint --ext .ts,vue --ignore-path .gitignore ."
  },
...
}

P粉349222772
P粉349222772

全部回覆(2)
P粉465287592

對(duì)於仍遇到此問題的用戶,請(qǐng)?jiān)?.eslintrc.js 檔案中的規(guī)則下新增以下內(nèi)容

rules: {
  ...
  'vue/multi-word-component-names': 0,
}
P粉850680329

選項(xiàng) 1:全域停用

要停用所有檔案中的規(guī)則(甚至是 src/components 中的檔案):

// /.eslintrc.js
module.exports = {
  ?
  rules: {
    'vue/multi-word-component-names': 0,
  },
}

選項(xiàng) 2:src/views/ 的 ESLint 配置中覆寫

要只對(duì)src/views/**/*.vue 停用規(guī)則,請(qǐng)指定 overrides 設(shè)定

// /.eslintrc.js
module.exports = {
  ?
  overrides: [
    {
      files: ['src/views/**/*.vue'],
      rules: {
        'vue/multi-word-component-names': 0,
      },
    },
  ],
}

注意:如果將VS Code 與ESLint 擴(kuò)展,重新啟動(dòng)ESLint 伺服器(透過命令面板 a> 的>ESLint:重新啟動(dòng)ESLint Server 指令)或重新啟動(dòng)IDE 可能需要重新載入設(shè)定。

選項(xiàng) 3:src/views/ 的目錄級(jí)配置

也可以使用 src/views/**/*.vue 的規(guī)則設(shè)定檔" rel="noreferrer">.eslintrc.js 檔案在該目錄

// /src/views/.eslintrc.js
module.exports = {
  rules: {
    'vue/multi-word-component-names': 0,
  },
}
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板