script/no-deprecated-model-definition
Disallow the Vue 2 model option, which was removed in Vue 3.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
essential, happy-path, ecosystem, nuxt, opinionated |
No | None |
Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form.
Bad
The component still declares the Vue 2 model option with prop and event.
<script lang="ts">
export default {
model: {
prop: 'value',
event: 'input'
}
}
</script>
Good
The component declares the modelValue prop and the update:modelValue event instead.
<script lang="ts">
export default {
props: ['modelValue'],
emits: ['update:modelValue']
}
</script>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"script/no-deprecated-model-definition": "error"
}
},
});
Then run vp run lint.