useVueToggleInsideTransition (HTML)
Language HTML
Summary
Section titled “Summary”- Rule available since:
v2.6.3 - Diagnostic Category:
lint/nursery/useVueToggleInsideTransition - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useVueToggleInsideTransition": "error" } } }}Description
Section titled “Description”Require the element inside a Vue <Transition> to be shown and hidden with v-if or v-show.
A <Transition> plays its animation when the element inside it is added,
removed, shown, or hidden. An element that is always shown never changes,
so the animation never plays.
The rule checks the first element inside each <Transition>. That element
is accepted when one of the following is true:
- it has a
v-iforv-showdirective; - it has a
keybound with:keyorv-bind:key, because Vue replaces the element when the key changes; - it is a component, a
<component>, a<slot>, or an element with anisattribute, because the rule can’t see what they render; - the
<Transition>has theappearattribute, which plays the animation when the element is first shown.:appear="false"doesn’t count.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<template> <Transition> <div>Content</div> </Transition></template>code-block.vue:3:5 lint/nursery/useVueToggleInsideTransition ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This element inside <Transition> is never shown or hidden.
1 │ <template>
2 │ <Transition>
> 3 │ <div>Content</div>
│ ^^^^^
4 │ </Transition>
5 │ </template>
ℹ A transition only plays when the element inside it appears or disappears. This element is always present, so the transition never plays.
ℹ Add v-if or v-show to the element, or bind a :key that changes when the content does.
ℹ 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.
<template> <Transition> <div v-if="visible">Content</div> </Transition> <Transition> <div v-show="visible">Content</div> </Transition> <Transition> <div :key="step">Content</div> </Transition> <Transition> <MyComponent /> </Transition> <Transition appear> <div>Content</div> </Transition></template>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.