Skip to content
← Back to rules

vue/require-render-return Correctness

What it does

Enforce that a render function always returns a value.

Why is this bad?

A Vue component's render function must produce a VNode tree. If a code path falls through without returning, Vue receives undefined and silently renders nothing.

Examples

Examples of incorrect code for this rule:

vue
<script>
export default {
  render() {
    if (foo) {
      return h("div");
    }
    // falls through without returning
  },
};
</script>

Examples of correct code for this rule:

vue
<script>
export default {
  render() {
    return h("div");
  },
};
</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-render-return": "error"
  }
}
ts
import { defineConfig } from "oxlint";

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

Version

This rule was added in vnext.

References