← Back

vue/require-default-prop warning

This rule requires default value to be set for each props that are not marked as required.

Examples

❌  Incorrect

<script>
    export default {
        props: {
            a: Number,
            b: [Number, String],
            c: {
                type: Number,
            },
            d: {
                type: Number,
                required: false,
            },
        },
    }
</script>

✅  Correct

<script>
    export default {
        props: {
            a: {
                type: Number,
                required: true,
            },
            b: {
                type: Number,
                default: 0,
            },
            c: {
                type: Number,
                default: 0,
                required: false,
            },
        },
    }
</script>