vuejs / eslint-plugin-vue

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

Add support for props destructure to `vue/require-valid-default-prop` rule #2551

Closed ota-meshi closed 2 months ago

ota-meshi commented 2 months ago

This PR modifies the vue/require-valid-default-prop rule to add support for props destructure.

related to #2121

aethr commented 1 month ago

I think default values for arrays and objects are handled slightly differently when using props destructuring. I don't believe it's necessary to use a function to construct them, as shown in the example in https://vuejs.org/api/sfc-script-setup.html#reactive-props-destructure:

interface Props {
  msg?: string
  labels?: string[]
}

const { msg = 'hello', labels = ['one', 'two'] } = defineProps<Props>()

I've opened an issue: https://github.com/vuejs/eslint-plugin-vue/issues/2578