vue/require-default-prop
require default value for props
- ⚙️ This rule is included in
"plugin:vue/strongly-recommended"
and"plugin:vue/recommended"
.
📖 Rule Details
This rule requires default value to be set for each props that are not marked as required
(except Boolean
props).
<script>
export default {
props: {
/* ✓ GOOD */
a: {
type: Number,
required: true
},
b: {
type: Number,
default: 0
},
c: {
type: Number,
default: 0,
required: false
},
d: {
type: Boolean, // Boolean is the only type that doesn't require default
},
/* ✗ BAD */
e: Number,
f: [Number, String],
g: [Boolean, Number],
j: {
type: Number
},
i: {
type: Number,
required: false
}
}
}
</script>
🔧 Options
Nothing.