vuejs / eslint-plugin-vue

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

vue/require-explicit-emits - defineModel not supported #2544

Open Pentadome opened 2 months ago

Pentadome commented 2 months ago

What did you do?

<script setup lang="ts">
defineModel<string>();
</script>

<template>
  <input @input="$emit('update:modelValue', $event.target.value)" />
</template>

This causes warning/error: The "update:modelValue" event has been triggered but not declared ondefineEmits.

FloEdelmann commented 2 months ago

Is this the recommended usage? I'd rather do this with defineModel:

<script setup lang="ts">
const modelValue = defineModel<string>();
</script>

<template>
  <input @input="modelValue = $event.target.value" />

  <!-- or even better: -->
  <input v-model="modelValue" />
</template>