JS.VUE.NO.DEPRECATED.EVENTS.API

Disallow using deprecated events api (in Vue.js 3.0.0+)

Rule Details

This rule reports use of deprecated $on, $off $once api. (in Vue.js 3.0.0+).

See Migration Guide - Events API (https://v3-migration.vuejs.org/breaking-changes/events-api.html) for more details.

{'vue/no-deprecated-events-api': ['error']}

Copy
<script>
/* BAD */
export default {
  mounted () {
    this.$on('start', function(args) {
      console.log('start')
    })
    this.$emit('start')
  }
}
</script>

{'vue/no-deprecated-events-api': ['error']}

Copy
<script>
/* GOOD */
import mitt from 'mitt'
const emitter = mitt()
export default {
  mounted () {
    emitter.on('start', function(args) {
      console.log('start')
    })
    emitter.emit('start')
  }
}
</script>

Options

Nothing.

Further Reading

  • Migration Guide - Events API (https://v3-migration.vuejs.org/breaking-changes/events-api.html)
  • Vue RFCs - 0020-events-api-change (https://github.com/vuejs/rfcs/blob/master/active-rfcs/0020-events-api-change.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/