Vue · Lifecycle
vite-doctor/vuelifecyclewarnSuggestion
Why it happens
Effects that outlive their component create leaks and stale updates. Register cleanup where Vue or VueUse can dispose it automatically.
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>
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --framework vue --rules vue/lifecycle/require-cleanup