Skip to content

Enforce defineComponent for options API components with Typescript #2661

Open
@GeoffreyParrier

Description

@GeoffreyParrier

Please describe what the rule should do:

When we use Option API (in typescript and javascript) it is better to use defineComponent to enable props type inference (1).
A rule should be available to enforce it.

What category should the rule belong to?

  • Enforces code style (layout)
  • 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:

Should error on:

<script lang="ts">
export default {
 // ...
}
</script>
<script>
export default {
  // ...
}
</script>

Should not error on:

<script lang="ts">
export default defineComponent({
  // ...
})
</script>
<script setup>
// ...
</script>
<script lang="ts" setup>
// ...
</script>

Additional context

(1) source : https://vuejs.org/guide/typescript/composition-api#without-script-setup

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