Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule proposal: vue/no-deprecated-model-definition #2236

Closed
FloEdelmann opened this issue Jul 17, 2023 · 0 comments · Fixed by #2238
Closed

Rule proposal: vue/no-deprecated-model-definition #2236

FloEdelmann opened this issue Jul 17, 2023 · 0 comments · Fixed by #2238

Comments

@FloEdelmann
Copy link
Member

FloEdelmann commented Jul 17, 2023

Please describe what the rule should do:

In Vue 3, v-model is always a shortcut for :modelValue="…" @update:modelValue="…". In Vue 2, those prop and event names could be customized with the model definition. A new ESLint rule would help with finding those deprecated model definitions in the codebase while upgrading to Vue 3. See also https://v3-migration.vuejs.org/breaking-changes/v-model.html

What category should the rule belong to?
[ ] Enforces code style (layout)
[x] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

export default {
  model: {
    prop: 'list',
  }
}
export default defineComponent({
  model: {
    prop: 'list',
    event: 'update'
  }
})
export default Vue.extend({
  model: {
    event: 'update'
  }
})

Additional context
An additional allowVue3Compat boolean option (false by default) could help with transitioning to Vue 3:

When enabled, the rule would not report model definitions that match the Vue 3 usage:

export default defineComponent({
  model: {
    prop: 'foo-bar',
    event: 'update:foo-bar'
  }
})

After the Vue 3 migration, the option could be disabled again, the model definition could be deleted, and the v-model:foo="…" shorthand syntax could then be used without further changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant