vuejs / eslint-plugin-vue

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

Feature Request: make `vue/no-undef-components` works in Vue class component #2546

Closed ylc395 closed 2 months ago

ylc395 commented 2 months ago

What rule do you want to change? vue/no-undef-components

Does this change cause the rule to produce more or fewer warnings? fewer warning

How will the change be implemented? (New option, new default behavior, etc.)? New default behavior

Please provide some example code that this change will affect:

<template>
<div>
  <Foo /> <!-- This will trigger a vue/no-undef-components warning, which is incorrect-->
</div>
</template>
<script>
@Component({
  components: {
    Foo
  }
})
export default class Bar extends Vue {}
</script>

What does the rule currently do for this code? trigger a vue/no-undef-components warning, which is incorrect

What will the rule do after it's changed? do nothing

ylc395 commented 2 months ago

If this feature request is acceptable, I can submit a PR.

FloEdelmann commented 2 months ago

If this is possible without much code, then yes, please submit a PR! Make sure to also include test cases (valid and invalid ones) to verify the implementation.

ylc395 commented 2 months ago

I almost finish the PR, but I notice that just use comment like this:

<template>
  <Bar />
</template>
<script>
// @vue/component
@Component({
  components: { Bar } 
})
export default class Foo {}
</script>

will solve this problem.

So I think we do not need support Vue class component on purpose in this case. All we should do is to add an example about Vue class component in doc

FloEdelmann commented 2 months ago

Feel free to open a PR to improve the docs!

ylc395 commented 2 months ago

OK, please check #2561