JS.VUE.REQUIRE.EMIT.VALIDATOR

emits statement should contain type definition

  • Some problems reported by this rule are manually fixable by editor suggestions (https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).

Rule Details

This rule enforces that a emits statement contains type definition.

Declaring emits with types can bring better maintenance. Even if using with TypeScript, this can provide better type inference when annotating parameters with types.

{'vue/require-emit-validator': ['error']}

Copy
<script>
/* GOOD */
Vue.component('foo', {
  emits: {
    // Emit with arguments
    foo: (payload) => { /* validate payload */ },
    // Emit without parameters
    bar: () => true,
  }
})

/* BAD */
Vue.component('bar', {
  emits: ['foo']
})

Vue.component('baz', {
  emits: {
    foo: null,
  }
})
</script>

Options

Nothing.

Further Reading

  • API Reference (https://v3.vuejs.org/api/options-data.html#emits)

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/