vue/require-toggle-inside-transition
Require a toggle on the element wrapped by <transition>.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
essential, happy-path, nuxt, ecosystem, opinionated |
No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The static child inside <Transition> has no conditional visibility or dynamic selection to trigger an enter/leave change.
<template>
<transition>
<div>content</div>
</transition>
</template>
Good
v-if="show" changes whether the child exists, giving the transition an enter/leave boundary.
<template>
<transition>
<div v-if="show">content</div>
</transition>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/require-toggle-inside-transition": "error"
}
},
});
Then run vp run lint.