Vue · VUE0032

Do not watch the useAttrs() object

Flags watch() calls whose source is the useAttrs() object itself, which Vue never re-runs.
VUE0032vite-doctor/vueattrserrorSuggestion

Run this rule

pnpm vite-doctor . --framework vue --rules vue/attrs/no-watch-use-attrs

Why it matters

useAttrs() returns a proxy over the component's fallthrough attributes, not a ref or reactive object. watch(attrs, cb) is an invalid watch source: Vue logs "Invalid watch source" in development and the callback never runs. An array entry of attrs is always undefined, and a getter that returns attrs without reading an attribute never changes, so in every case the callback misses attribute updates from the parent.

Declare the attribute as a prop and watch(() => props.name, ...). If it has to stay a fallthrough attribute, watch a getter that reads it, watch(() => attrs.name, ...), or read attrs in onUpdated(). Deep watchers and getters that read attributes are not reported.

Example

Watch a declared prop instead of the attrs object

Before

<script setup lang="ts">
const attrs = useAttrs()
watch(attrs, () => validate(attrs.value))
</script>

After

<script setup lang="ts">
const props = defineProps<{ value?: string }>()
watch(() => props.value, (value) => validate(value))
</script>
Copyright © 2026