vue/require-valid-default-prop
eslint-plugin-vue
No autofixRecommended
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/require-valid-default-prop": "error",
},
},
];<script>
export default {
props: {
count: {
type: Number,
default: "zero",
},
},
};
</script><script>
export default {
props: {
items: {
type: Array,
default: [],
},
},
};
</script><script setup lang="ts">
withDefaults(defineProps<{ label?: string }>(), {
label: () => 42,
});
</script><script setup>
const { tags = [] } = defineProps({
count: { type: Number, default: 0 },
items: { type: Array, default: () => [] },
options: {
type: Object,
default() {
return { size: "small" };
},
},
format: { type: Function, default: (value) => String(value) },
tags: Array,
});
defineModel({ type: Object, default: () => ({ size: "small" }) });
</script>Examples from the Biome documentation.
vue/require-valid-default-prop
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/require-valid-default-prop": "error",
},
},
];Oxlint does not have this rule.
nursery/useVueValidDefaultProp
nursery · since 2.6.5
{
"linter": {
"rules": {
"nursery": {
"useVueValidDefaultProp": "error"
}
}
}
}Require control the display of the content inside <transition>
Require v-bind:is of <component> elements