vue/return-in-computed-property Correctness
What it does
Enforce that a return statement is present in every computed property.
Why is this bad?
A Vue computed property is a getter that must produce a value. Forgetting to return turns the value into undefined, which silently breaks templates and reactive code that depend on the computed.
Examples
Examples of incorrect code for this rule:
vue
<script>
export default {
computed: {
foo() {
// missing return
},
},
};
</script>Examples of correct code for this rule:
vue
<script>
export default {
computed: {
foo() {
return this.bar;
},
},
};
</script>Configuration
treatUndefinedAsUnspecified
type: boolean
default: true
When true (default), return; (without a value) is treated as a missing return. Set to false to allow bare return; as if it returned a value.
How to use
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["vue"],
"rules": {
"vue/return-in-computed-property": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["vue"],
rules: {
"vue/return-in-computed-property": "error",
},
});bash
oxlint --deny vue/return-in-computed-property --vue-pluginVersion
This rule was added in v1.63.0.
