valid-v-model
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: warnhtml/eslint-plugin-vue-recommended
What it does
Section titled “What it does”Reports a v-model that has no expression, and a v-model on a file input.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”<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>...<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>...Configuration
Section titled “Configuration”angular: lint: rules: valid-v-model: warn # off, warn (default), errorhtml: lint: rules: valid-v-model: warn # off, warn (default), errorsvelte: lint: rules: valid-v-model: warn # off, warn (default), errorvue: lint: rules: valid-v-model: warn # off, warn (default), errorEnabled 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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint-plugin-vue | valid-v-model |
full |