vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.47k stars 666 forks source link

Rule `no-setup-props-reactivity-loss` in Vue 3.5 should no longer trigger a warning when destructuring defineProps. #2543

Closed heggria closed 2 months ago

heggria commented 2 months ago

What rule do you want to change?

no-setup-props-reactivity-loss

Does this change cause the rule to produce more or fewer warnings?

fewer

How will the change be implemented? (New option, new default behavior, etc.)?

In vue 3.5, variables destructured from props will retain reactivity, so this warning is incorrect in this context.

Please provide some example code that this change will affect:

Playground

// before: warning "Destructuring the `props` will cause the value to lose reactivity."
const { name, className = '', height = '14', width = '14' } = defineProps<{
    name: string
    className?: string
    height?: string | number
    width?: string | number
}>()

// after: no warning in vue 3.5 
const { name, className = '', height = '14', width = '14' } = defineProps<{
    name: string
    className?: string
    height?: string | number
    width?: string | number
}>()
n0099 commented 2 months ago

https://github.com/vuejs/eslint-plugin-vue/issues/2121

FloEdelmann commented 2 months ago

Thanks for linking that issue! I'll close this as a duplicate then.