eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

Rule proposal: no-computed-after-await

Open cjpearson opened this issue 10 months ago • 0 comments

Please describe what the rule should do:

Disallow asynchronously registered watch

What category should the rule belong to?

[ ] Enforces code style (layout) [X] Warns about a potential error (problem) [ ] Suggests an alternate way of doing something (suggestion) [ ] Other (please specify:)

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

    await doSomething()

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

Additional context

This rule is based on no-watch-after-await. According to the documentation, watch and computed must be called synchronously in order for them to be properly cleaned up. There is currently the no-watch-after-await rule to catch asynchronous calls of watch, but no comparable rule for computed.

cjpearson avatar Apr 15 '24 16:04 cjpearson