vue/no-mutating-props
Disallow mutating component props
Default severity: error
Presets: essential, happy-path, nuxt, ecosystem, opinionated
Automatic fix: None; review the suggested change
Applies to: Vue SFC templates and blocks, with script context where the rule requires it
Options: See typed options and defaults.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/no-mutating-props": "error"
}
},
},
});
vp run lint
Bad
Incrementing props.count writes directly to a value supplied by the parent.
<script setup lang="ts">
const props = defineProps<{ count: number }>();
props.count++;
</script>
Good
The component emits update:count with the next value, leaving the parent responsible for updating the prop.
<script setup lang="ts">
const props = defineProps<{ count: number }>();
const emit = defineEmits<{ "update:count": [value: number] }>();
function increment() {
emit("update:count", props.count + 1);
}
</script>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.