vue/prefer-v-model
eslint-plugin-vue
Suggestion
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/prefer-v-model": "error",
},
},
]; <my-component :modelValue="foo" @update:modelValue="foo = $event" />
<my-component :model-value="foo" @update:model-value="foo = $event" />
<my-component :foo="bar" @update:foo="bar = $event" />
<my-component v-bind:foo="bar" v-on:update:foo="bar = $event" />
<my-component :foo="bar" @update:foo="(val) => bar = val" />
</template><my-component v-model="foo" />
<my-component v-model:foo="bar" />
<my-component :foo="bar" @update:foo="baz = $event" />
<my-component :foo="bar" @update:foo="updateFoo($event)" />
<my-component :foo="bar" @update:foo="(val) => updateFoo(val)" />Examples from the ESLint documentation.
vue/prefer-v-model
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/prefer-v-model": "error",
},
},
];Oxlint does not have this rule.
nursery/useVueVModel
nursery · since 2.6.4
{
"linter": {
"rules": {
"nursery": {
"useVueVModel": "error"
}
}
}
}Enforce use of defineOptions instead of default export
Disallow unused emit declarations
Enforce or forbid the use of the scoped and module attributes in SFC top level style tags
Disallow importing Vue compiler macros