Vue · VUE0028

Keep 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.
VUE0028vite-doctor/vuereactivityerrorNo fix

Run this rule

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

Why it matters

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.

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>
Copyright © 2026