JS.VUE.RETURN.IN.EMITS.VALIDATOR

Enforce that a return statement is present in emits validator

Rule Details

This rule enforces that a return statement is present in emits validators.

{'vue/return-in-emits-validator': ['error']}

Copy
<script>
export default {
  emits: {
    /* GOOD */
    foo (evt) {
      if (evt) {
        return true
      } else {
        return false
      }
    },
    bar: function () {
      return true
    },
    baz (evt) {
      if (evt) {
        return true
      }
    },
    /* BAD */
    qux: function () {},
    quux (evt) {
      if (!evt) {
        return false
      }
    }
  }
}
</script>

Options

Nothing.

Further Reading

  • Guide - Custom Events / Validate Emitted Events (https://v3.vuejs.org/guide/component-custom-events.html#validate-emitted-events)
  • Vue RFCs - 0030-emits-option (https://github.com/vuejs/rfcs/blob/master/active-rfcs/0030-emits-option.md)

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/