Skip to content

Rule Proposal: no undef component in template when using <script setup> #1693

Closed
@niaodan2b

Description

@niaodan2b

Please describe what the rule should do:
Warn against components that appear in the template but not defined/imported in script-setup

What category should the rule belong to?
[ ] Enforces code style (layout)
[X] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

// Bad: OtherComponent not defined
<template>
  <div>
    <SomeComponent />
    <OtherComponent />
  </div>
</template>

<script setup>
import SomeComponent from '@/components/SomeComponent.vue'
</script>

//Good:
<template>
  <div>
    <SomeComponent />
    <OtherComponent />
  </div>
</template>

<script setup>
import SomeComponent from '@/components/SomeComponent.vue'
import OtherComponent from '@/components/OtherComponent.vue' // or: const OtherComponent = xxx.
</script>

//Also Good:
<template>
  <div>
    <some-component />
    <other-component />
  </div>
</template>

<script setup>
import SomeComponent from '@/components/SomeComponent.vue'
import OtherComponent from '@/components/OtherComponent.vue' // or: const OtherComponent = xxx.
</script>

Additional context
This is like the script-setup version of "no-unregistered components" rule

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions