Skip to content

valid-v-for

Reports a v-for whose value is not item in items (or of), or that has an argument or a modifier. A missing :key is v-for-key.

A v-for that does not parse is a compile error, or it loops over nothing.

To fix, write v-for="item in items".

Reported
<template>
...
<b v-for="xs" :key="1" :a="" :a.x="1" #a.m v-if:a="1" @click />
...
<p v-if="ok" :a>
...
After the fix
<template>
...
<b v-for="xs" :key="1" :a="" :a.x="1" #a.m v-if:a="1" @click />
...
<p v-if="ok" :a>
...
angular:
lint:
rules:
valid-v-for: warn # off, warn (default), error
html:
lint:
rules:
valid-v-for: warn # off, warn (default), error
svelte:
lint:
rules:
valid-v-for: warn # off, warn (default), error
vue:
lint:
rules:
valid-v-for: warn # off, warn (default), error

Enabled by the presets: html/eslint-plugin-vue-recommended.

Suppress one line with sudsy-disable-next-line valid-v-for in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint-plugin-vue valid-v-for full