Skip to content

Files

Latest commit

 

History

History
51 lines (40 loc) · 1.07 KB

no-deprecated-events-api.md

File metadata and controls

51 lines (40 loc) · 1.07 KB

Pattern: Use of deprecated events API

Issue: -

Description

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

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

Further Reading