[eslint-plugin-vue] After configuration, naming such as index.vue is not allowed.

Currently installed eslint versions and plug-ins:

    "eslint": "^8.46.0",
    "eslint-config-standard-with-typescript": "^37.0.0",
    "eslint-plugin-import": "^2.28.0",
    "eslint-plugin-n": "^16.0.1",
    "eslint-plugin-promise": "^6.1.1",
    "eslint-plugin-vue": "^9.16.1",

The current configuration of .eslintrc.cjs is as follows:

module.exports = {
  env: {
    browser: true,
    es2021: true
  },
  extends: ['plugin:vue/vue3-strongly-recommended', 'standard'],
  parserOptions: {
    ecmaVersion: 12,
    parser: '@typescript-eslint/parser',
    sourceType: 'module'
  },
  plugins: ['vue', '@typescript-eslint'],
  rules: {
    'vue/no-mutating-props': 'off'
  },
  overrides: [
    {
      files: ['src/api/**/*.ts'],
      rules: {
        camelcase: 'off'
      }
    }
  ]
}

I use vite+vue3 and have the eslint-plugin-vue plug-in installed.

question:

When I create a component, I habitually write index.vue
Insert image description here
eslint-plugin-vue prompt:
https://eslint.vuejs.org/rules/multi-word-component-names.html
Insert image description here

Rule Details
This rule require component names to be always multi-word, except for root App components, and built-in components provided by Vue, such as <transition> or <component>. This prevents conflicts with existing and future HTML elements, since all HTML elements are single words.

Rule details
This rule requires that component names are always multiple words , except for the root component App and built-in components provided by Vue, such as or. This avoids conflicts with existing and future HTML elements because all HTML elements are single words.


solution:

1. Turn off this rule:

You need to add the following to the rule in .eslintrc.cjs:

'vue/multi-word-component-names': 'off'

Insert image description here

2. Follow the configured rules:

Change index.vue under the home file to HomeIndex.vue or home-index.vue

Guess you like

Origin blog.csdn.net/weixin_40887836/article/details/132131068