Skip to content

vue/no-mutating-props should warn on Object.assign with prop as first argument #2823

@Wiseqube

Description

@Wiseqube

What rule do you want to change?
vue/no-mutating-props should detect Object.assign on props with the prop as first argument as this target is mutated by the function

Does this change cause the rule to produce more or fewer warnings?
The rule would produce more warnings, due to detecting more unintended mutations on props

How will the change be implemented? (New option, new default behavior, etc.)?
I'd say this should be a default behavior for this rule

Please provide some example code that this change will affect:

this.$emit(
    'update:modelValue',
    Object.assign(this.modelValue, {[this.colname]: val}),
)
<input @input="$emit('update:modelValue', Object.assign(modelValue, {[colname]: $event.target.value}))" />

What does the rule currently do for this code?
This code is currently ignored by this rule!

What will the rule do after it's changed?
The rule should detect this kind of code and warn about it

Additional context
MDN Object.assign

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions