Skip to content

noVueDeprecatedDestroyedLifecycle (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"noVueDeprecatedDestroyedLifecycle": "error"
}
}
}
}

Disallow the deprecated destroyed and beforeDestroy lifecycle hooks in Vue components.

Vue 3 renamed the beforeDestroy hook to beforeUnmount, and the destroyed hook to unmounted. Vue 3 doesn’t call hooks that use the old names, so the code inside them never runs.

See the Vue 3 migration guide for more information.

<script>
export default {
beforeDestroy() {},
};
</script>
code-block.vue:3:3 lint/nursery/noVueDeprecatedDestroyedLifecycle  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━

✖ The beforeDestroy hook was renamed to beforeUnmount in Vue 3.

1 │ <script>
2 │ export default {
> 3 │ beforeDestroy() {},
│ ^^^^^^^^^^^^^
4 │ };
5 │ </script>

ℹ Vue 3 doesn't call the beforeDestroy hook, so the code inside it never runs.

ℹ Rename the hook to beforeUnmount.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Unsafe fix: Rename the hook to beforeUnmount.

1 1 │ <script>
2 2 │ export default {
3 │ - ··beforeDestroy()·{},
3 │ + ··beforeUnmount()·{},
4 4 │ };
5 5 │ </script>

<script>
export default {
destroyed() {},
};
</script>
code-block.vue:3:3 lint/nursery/noVueDeprecatedDestroyedLifecycle  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━

✖ The destroyed hook was renamed to unmounted in Vue 3.

1 │ <script>
2 │ export default {
> 3 │ destroyed() {},
│ ^^^^^^^^^
4 │ };
5 │ </script>

ℹ Vue 3 doesn't call the destroyed hook, so the code inside it never runs.

ℹ Rename the hook to unmounted.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

ℹ Unsafe fix: Rename the hook to unmounted.

1 1 │ <script>
2 2 │ export default {
3 │ - ··destroyed()·{},
3 │ + ··unmounted()·{},
4 4 │ };
5 5 │ </script>

<script>
export default {
beforeMount() {},
mounted() {},
beforeUnmount() {},
unmounted() {},
};
</script>