vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.4k stars 657 forks source link

`new Vue` is checked by component-related rules #2077

Open ntnyq opened 1 year ago

ntnyq commented 1 year ago

Checklist

Tell us about your environment

Please show your full configuration:

module.exports = {
  root: true,
  extends: ['plugin:vue/vue3-recommended', 'eslint:recommended'],
  rules: {
    'vue/require-name-property': ['error'],
    'vue/padding-lines-in-component-definition': ['error', {
      betweenOptions: `always`,
      groupSingleLineProperties: false,
    }]
  },
  parserOptions: {
    ecmaVersion: 'latest',
  },
}

What did you do?

import Vue from 'vue'
import App from './App.vue'
import { createPinia } from 'pinia'

const pinia = createPinia()

new Vue({
  pinia,
  ...App
}).$mount('#app')

What did you expect to happen?

Everything works fine and no error reported since new Vue is not listed in docs - eslint-detect-components.

What actually happened?

ESLint reported 2 errors:

  7:9  error  Required name property is not set           vue/require-name-property
  9:3  error  Expected blank line before this definition  vue/padding-lines-in-component-definition

Repository to reproduce this issue

https://github.com/ntnyq-dev/repro-eslint-plugin-vue

Related rules

Additional

If it is expected, how can I exclude it from being checked?

ota-meshi commented 1 year ago

Thank you for this issue. It seems to be missing documentation. new Vue() has been the target of linting since eslint-plugin-vue v3.

If you want to exclude new Vue(), we'll need to add an option to each rule or fix it.

ntnyq commented 1 year ago

Thank you for this issue. It seems to be missing documentation. new Vue() has been the target of linting since eslint-plugin-vue v3.

If you want to exclude new Vue(), we'll need to add an option to each rule or fix it.

Can this option be added tovue-eslint-parser's parserOptions.vueFeatures so it can be easy configured?

ota-meshi commented 1 year ago

Can this option be added tovue-eslint-parser's parserOptions.vueFeatures so it can be easy configured?

Can not do that. parserOptions.vueFeatures has nothing to do with linting target detection.