Vue · VUE0031
Do not give required props a default
Flags props declared as required that also define a default value.
vue/props/no-required-prop-with-defaultsrc/rule-packs/vue/rules/vue/no-required-prop-with-default.ts Upstream docs Run this rule
pnpm vite-doctor . --framework vue --rules vue/props/no-required-prop-with-default
Why it matters
Parents that omit a required prop get a type error with type-based props and Vue's "Missing required prop" warning in development, yet the default still fills the value at runtime, so the declared contract and the actual behavior disagree.
Recommended fix
Make the prop optional when the default is the intended fallback, or remove the default when every parent must pass the prop.
Useful links
Example
Make defaulted props optional
Before
<script setup lang="ts">
const props = withDefaults(defineProps<{ size: string }>(), {
size: 'md',
})
</script>
After
<script setup lang="ts">
const props = withDefaults(defineProps<{ size?: string }>(), {
size: 'md',
})
</script>