# 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

# 🚀 Version

This rule was introduced in eslint-plugin-vue v3.13.0

# 🔍 Implementation

Last Updated: 12/24/2020, 2:51:18 AM