v-if directive should not have the same implementation
- Code Quality
- cwe, vue
This rule applies when the content of an element having
v-else-if directive is identical to the
This might imply the condition is unnecessary, but at worst this is a programmer's mistake. For example, a programmer copies code from a branch into another and forgets to modify it.
Therefore, a programmer needs to check the same content is really needed for both branches.
Noncompliant Code ExampleView with compliant examples side by side
<template> <div v-if="cond"> Hi there! </div> <div v-else> Hi there! </div> </template>
Compliant Code ExampleView with noncompliant examples side by side
<template> <div v-if="cond"> Hi there! </div> <div v-else> Goodbye! </div> </template>
This rule was introduced in DeepScan 1.40.0.