Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 1.06 KB

require-prop-types.md

File metadata and controls

57 lines (43 loc) · 1.06 KB

require type definitions in props (vue/require-prop-types)

  • ⚙️ This rule is included in "plugin:vue/strongly-recommended" and "plugin:vue/recommended".

In committed code, prop definitions should always be as detailed as possible, specifying at least type(s).

📖 Rule Details

This rule enforces that a props statement contains type definition.

👎 Examples of incorrect code for this rule:

props: ['status']

👍 Examples of correct code for this rule:

// Without options, just type reference
props: {
  status: String
}
// With options with type field
props: {
  status: {
    type: String,
    required: true,
  }
}
// With options without type field but with validator field
props: {
  status: {
    required: true,
    validator: function (value) {
      return (
        value === null ||
        Array.isArray(value) && value.length > 0
      )
    }
  }
}

🔧 Options

Nothing.

Related links