vapor/no-vue-lifecycle-events
Disallow @vue:xxx per-element lifecycle events (not supported in Vapor).
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
happy-path, nuxt, ecosystem, opinionated |
No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The input uses the @vue:mounted template lifecycle event.
<template>
<input @vue:mounted="focusInput" />
</template>
Good
onMounted accesses the named template reference and focuses the input through the supported script lifecycle hook.
<script setup lang="ts" vapor>
const input = useTemplateRef<HTMLInputElement>("input");
onMounted(() => {
input.value?.focus();
});
</script>
<template>
<input ref="input" />
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vapor/no-vue-lifecycle-events": "error"
}
},
});
Then run vp run lint.