vue/define-props-destructuring
eslint-plugin-vue
No autofix
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/define-props-destructuring": "error",
},
},
];const props = defineProps(['foo'])
const propsWithDefaults = withDefaults(defineProps(['foo']), { foo: 'default' })
withDefaults(defineProps(['foo']), { foo: 'default' }) const { baz } = withDefaults(defineProps(['baz']), { baz: 'default' })
</script> const props = defineProps<{ foo?: string }>()
const propsWithDefaults = withDefaults(defineProps<{ foo?: string }>(), { foo: 'default' })
withDefaults(defineProps<{ foo?: string }>(), { foo: 'default' })
</script>const { foo } = defineProps(['foo'])
const { bar = 'default' } = defineProps(['bar'])
defineProps(['bar'])const { foo } = defineProps<{ foo?: string }>()
const { bar = 'default' } = defineProps<{ bar?: string }>()
defineProps<{ bar?: string }>()const { foo } = defineProps(['foo'])
const { bar = 'default' } = defineProps(['bar'])Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
vue/define-props-destructuring
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/define-props-destructuring": "error",
},
},
];vue/define-props-destructuring
vue plugin · style
{
"plugins": [
"vue"
],
"rules": {
"vue/define-props-destructuring": "error"
}
}nursery/useVueDefinePropsDestructuring
nursery · since 2.6.4
{
"linter": {
"rules": {
"nursery": {
"useVueDefinePropsDestructuring": "error"
}
}
}
}Enforce declaration style of defineProps and defineModel
Enforce declaration style of defineEmits
Disallow this usage in a beforeRouteEnter method
Require components to be the default export
Require ref and shallowRef functions to be strongly typed