Skip to content
← Back to rules

vue/require-default-prop Style

What it does ​

Requires default value to be set for props that are not marked as required.

Why is this bad? ​

A prop that is neither required nor given a default is implicitly undefined when omitted. Forcing a default keeps the component's behavior explicit and avoids undefined leaking into the template and logic. Boolean props are exempt because they already default to false.

Examples ​

Examples of incorrect code for this rule:

vue
<script>
export default {
  props: {
    name: String,
  },
};
</script>

Examples of correct code for this rule:

vue
<script>
export default {
  props: {
    name: {
      type: String,
      default: "",
    },
  },
};
</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-default-prop": "error"
  }
}
ts
import { defineConfig } from "oxlint";

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

Version ​

This rule was added in v1.70.0.

References ​