ESLint Vue multi-word component
P粉349222772
P粉349222772 2024-03-25 17:26:59
0
2
492

Is there a way to prevent single word view names in Vue3 from getting errors from ESLint?

Every time I run ESLint, I get the following message:

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

I currently have this setup:

File structure:

├── 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

reply all(2)
P粉465287592

For those who are still experiencing this issue, please add the following under the rules in the .eslintrc.js file

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

Option 1: Disable globally

To disable rules in all files (even files in src/components):

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

Option 2: Override in the ESLint configuration in src/views/

To only configure the rule configuration file of src/views/**/*.vue Disable rules, please specify overrides Configuration :

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

Note: If you are using VS Code with the ESLint extension, restart the ESLint server (via the Command Panel a>'s >ESLint: Restarting the ESLint Server command) or restarting the IDE may require reloading the configuration.

Option 3: Directory-level configuration of src/views/

You can also use src/views/**/*.vue" rel="noreferrer">.eslintrc.js file in this Table of contents:

// /src/views/.eslintrc.js
module.exports = {
  rules: {
    'vue/multi-word-component-names': 0,
  },
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template