Skip to content

vue-doctor/reactivity/prefer-computed ​

Use const value = computed(() => expression) instead of a watcher that only sets a ref

PropertyValue
CategoryReactivity
Default Severitywarning
Confidencemedium
FixableNo
Engineoxlint
Sincev1.0.0
Frameworksvue, nuxt

Why it matters ​

Use const value = computed(() => expression) instead of a watcher that only sets a ref

How to fix ​

Review the finding and update the code according to best practices below.

Agent Guidance ​

Replace the watcher that only assigns a ref with a computed that returns the same expression. Remove the now unused ref and its initial value.


Rule source: vue-doctor/reactivity/prefer-computed

Released under the MIT License.