eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

Add support for props destructure

Open ota-meshi opened this issue 1 year ago • 1 comments

Tell us about your environment

  • ESLint version: v8.36.0
  • eslint-plugin-vue version: v9.10.0
  • Node version: v18.12.1

The problem you want to solve.

Add support for props destructure. It will be introduced in Vue 3.3.

<script setup lang="ts">
const { foo = 1, bar = 'ok' } = defineProps<{ foo?: number, bar?: string }>()
</script>

Your take on the correct solution to problem.

I think we should at least change the rules in the following list.

  • [ ] Change vue/no-setup-props-destructure rule. Destructuring assignment immediately after defineProps() is allowed. However, Vue2 doesn't allow to use props destructure, so we may need to split rules.
  • [ ] Change vue/require-valid-default-prop rule.
  • [ ] Change vue/require-default-prop rule.
  • [ ] Change vue/no-boolean-default rule. We need to support a new way to specify defaults.

Additional context

https://github.com/vuejs/core/pull/7986

ota-meshi avatar Apr 03 '23 00:04 ota-meshi

Since it's still an experimental feature, eslint-plugin-vue won't support it yet until it's GA.

https://blog.vuejs.org/posts/vue-3-3#experimental-features

ota-meshi avatar May 13 '23 02:05 ota-meshi