vue/no-use-v-if-with-v-for
eslint-plugin-vue
No autofixRecommended
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-use-v-if-with-v-for": "error",
},
},
]; <TodoItem
v-if="complete"
v-for="todo in todos"
:todo="todo"
/><!-- ↑ In this case, the `v-if` should be written on the wrapper element. -->
<TodoItem
v-for="todo in todos"
v-if="todo.shown"
:todo="todo"
/><!-- ↑ In this case, the `v-for` list variable should be replace with a computed property that returns your filtered list. -->
</template> <TodoItem
v-for="todo in todos"
v-if="shown"
:todo="todo"
/>
</template><ul v-if="complete">
<TodoItem
v-for="todo in todos"
:todo="todo"
/>
</ul>
<TodoItem
v-for="todo in shownTodos"
:todo="todo"
/><TodoItem
v-for="todo in todos"
v-if="todo.shown"
:todo="todo"
/>Examples from the ESLint documentation.
vue/no-use-v-if-with-v-for
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-use-v-if-with-v-for": "error",
},
},
];Oxlint does not have this rule.
correctness/noVueVIfWithVFor
correctness · since 2.3.6
{
"linter": {
"rules": {
"correctness": {
"noVueVIfWithVFor": "error"
}
}
}
}Disallow useless attribute on <template>
Disallow key of <template v-for> placed on child elements
Disallow use of value wrapped by ref() (Composition API) as an operand
Disallow v-text / v-html on component