Vue · VUE0004
Clean up lifecycle resources
Checks that Vue lifecycle code includes the cleanup needed for predictable behavior.
vue/lifecycle/require-cleanupsrc/rule-packs/vue/rules/vue/require-lifecycle-cleanup.tsRun this rule
pnpm vite-doctor . --framework vue --rules vue/lifecycle/require-cleanup
Why it matters
Effects that outlive their component create leaks and stale updates. Register cleanup where Vue or VueUse can dispose it automatically.
Recommended fix
Add cleanup where Vue expects it, close to the code that depends on it.
Example
Clean up lifecycle side effects
Before
<script setup lang="ts">
onMounted(() => {
window.addEventListener('resize', onResize)
})
</script>
After
<script setup lang="ts">
onMounted(() => {
window.addEventListener('resize', onResize)
})
onBeforeUnmount(() => {
window.removeEventListener('resize', onResize)
})
</script>