JS.VUE.NO.LIFECYCLE.AFTER.AWAIT

Disallow asynchronously registered lifecycle hooks

Rule Details

This rule reports the lifecycle hooks after await expression.
In setup() function, onXXX lifecycle hooks should be registered synchronously.

{'vue/no-lifecycle-after-await': ['error']}

Copy
<script>
import { onMounted } from 'vue'
export default {
  async setup() {
    /* GOOD */
    onMounted(() => { /* ... */ })

    await doSomething()

    /* BAD */
    onMounted(() => { /* ... */ })
  }
}
</script>

Options

Nothing.

Further Reading

  • Guide - Composition API - Lifecycle Hooks (https://v3.vuejs.org/guide/composition-api-lifecycle-hooks.html)
  • Vue RFCs - 0013-composition-api (https://github.com/vuejs/rfcs/blob/master/active-rfcs/0013-composition-api.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/