eslint-plugin-vue
eslint-plugin-vue copied to clipboard
Rule proposal: no-computed-after-await
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
.