Vue · Reactivity

VUE0028Keep computed getters pure and synchronous

Flags computed getters that write state, sort or reverse a reactive array in place, start timers, or return a Promise.

Why it happens

Computed getters are lazy and cached, so side effects inside them run at unpredictable times, .sort() and `.`reverse() reorder the source array in place, and an async getter makes the computed value a Promise instead of the data.

Fix

Keep the getter pure and synchronous: sort a copy, move writes and timers into a watcher or event handler, and load async data into a ref that the computed reads.

Example

Sort a copy inside computed

Before

<script setup lang="ts">
const items = ref([3, 1, 2])
const sorted = computed(() => items.value.sort())
</script>

After

<script setup lang="ts">
const items = ref([3, 1, 2])
const sorted = computed(() => items.value.toSorted())
</script>

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework vue --rules vue/reactivity/no-computed-side-effects
Copyright © 2026