Skip to content
← Back to rules

vue/require-prop-types Style

What it does

This rule enforces that a props statement contains type definition.

Why is this bad?

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

Examples

Examples of incorrect code for this rule:

vue
<script setup>
const props = defineProps({
  name: String,
});
</script>

Examples of correct code for this rule:

vue
<script setup>
const props = defineProps({
  name: { type: String },
});
</script>

// Or with validator
<script setup>
const props = defineProps({
  name: {
    validator: (value) => value.length > 0,
  },
});
</script>

How to use

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

json
{
  "plugins": ["vue"],
  "rules": {
    "vue/require-prop-types": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["vue"],
  rules: {
    "vue/require-prop-types": "error",
  },
});
bash
oxlint --deny vue/require-prop-types --vue-plugin

Version

This rule was added in vnext.

References