Skip to content

valid-v-model

Reports a v-model that has no expression, and a v-model on a file input.

A file input has no value that Vue can set, so the binding fails; a v-model with no expression binds nothing.

To fix, write v-model="name", and listen to @change on a file input.

Reported
<template>
<div v-if v-bind v-model v-html v-text v-show v-once="x" v-pre="x" v-cloak="x" v-memo v-is />
...
<input type="file" v-model="f" /><div v-if="a" #item></div>
<p v-if="ok" :a>
<template #default="p"><C #item="{ a }" /></template>
</p>
...
After the fix
<template>
<div v-if v-bind v-model v-html v-text v-show v-once="x" v-pre="x" v-cloak="x" v-memo v-is />
...
<input type="file" v-model="f" /><div v-if="a" #item></div>
<p v-if="ok" :a>
<template #default="p"><C #item="{ a }" /></template>
</p>
...
angular:
lint:
rules:
valid-v-model: warn # off, warn (default), error
html:
lint:
rules:
valid-v-model: warn # off, warn (default), error
svelte:
lint:
rules:
valid-v-model: warn # off, warn (default), error
vue:
lint:
rules:
valid-v-model: warn # off, warn (default), error

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

Suppress one line with sudsy-disable-next-line valid-v-model 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-model full