Vize

script/return-in-computed-property

Require a return value in every computed getter.

Default severity Presets Automatic fix Options
error essential, happy-path, ecosystem, nuxt, opinionated No None

Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form.

Bad

The block-bodied computed getter evaluates 1 + 2 but never returns it, leaving the computed value undefined.

<script setup lang="ts">
import { computed } from "vue";
const total = computed(() => { 1 + 2; });
</script>

Good

return 1 + 2 turns the expression into the getter’s returned value. The rule looks for a value-returning return in the getter itself, not merely an expression statement.

<script setup lang="ts">
import { computed } from "vue";
const total = computed(() => { return 1 + 2; });
</script>

Configuration (Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "script/return-in-computed-property": "error"
    }
  },
});

Then run vp run lint.