Note

This is a documentation for version 7.0.0-beta.2.
To check version 6.2.2 go here. To check previous releases go here.

# vue/require-default-prop

require default value for props

  • ⚙️ This rule is included in all of "plugin:vue/vue3-strongly-recommended", "plugin:vue/strongly-recommended", "plugin:vue/vue3-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>
Now loading...

# 🔧 Options

Nothing.

# 📚 Further Reading

# 🔍 Implementation