Skip to content

Files

Latest commit

 

History

History
43 lines (32 loc) · 864 Bytes

require-emit-validator.md

File metadata and controls

43 lines (32 loc) · 864 Bytes

Pattern: Missing type definition for emits

Issue: -

Description

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.

<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>

Further Reading