Skip to content

vue/max-props Restriction

What it does

Enforce maximum number of props in Vue component.

Why is this bad?

This rule enforces a maximum number of props in a Vue SFC, in order to aid in maintainability and reduce complexity.

Examples

Examples of incorrect code for this rule with the default { maxProps: 1 } option:

js
<script setup>
defineProps({
  prop1: String,
  prop2: String,
})
</script>

Examples of correct code for this rule with the default { maxProps: 1 } option:

js
<script setup>
defineProps({
  prop1: String,
})
</script>

Options

This rule takes an object, where you can specify the maximum number of props allowed in a Vue SFC.

json
{
  "vue/max-props": [
    "error",
    {
      "maxProps": 1
    }
  ]
}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny vue/max-props --vue-plugin
json
{
  "plugins": ["vue"],
  "rules": {
    "vue/max-props": "error"
  }
}

References

Released under the MIT License.