-
-
Notifications
You must be signed in to change notification settings - Fork 681
no-mutating-props seems too strict #1314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for posting this issue. Changing the state of a parent component passed by reference on a child component can be confusing. I don't want to change this rule because I think it should be strict. Thank you for your understanding. |
@ota-meshi Sorry for the duplicate issue, seems like Github search returns different results for vue/no-mutating-props when searching the whole repo and when searching just issues (which I did) Could we maybe toggle this strict behaviour with a rule option? Priority D / Use with caution doesnt mean its plain wrong and I would love to be able to still make sure that I didn't really overwrite a prop somewhere. |
Is there any way to disallow |
I think it is wrong to say this. Using events forces working on copies of the object. Even though it's the safest way to ensure no coupling between components, and is the best for simple values, it's definitively an anti-pattern for complex objects that needs to delegate the handling of an entire sub-structure to a sub-component (and that don't necessary couple the component, one should just document the property's properties are read/write). Vue has a GREAT reactivity system... why not letting it do the job ? However, I agree with the original purpose of rule that the prop value itself should not be reassigned ( = forbidding |
What rule do you want to change?
no-mutating-props
Does this change cause the rule to produce more or fewer warnings?
Fewer
How will the change be implemented? (New option, new default behavior, etc.)?
A new option would suffice, but maybe the default behavior should also be changed as well.
Please provide some example code that this change will affect:
What does the rule currently do for this code?
It flags it as an error, and I have to disable it globally or locally.
What will the rule do after it's changed?
This should be allowed because the property is an object. I'm not mutating
this.localData
itself, but another object inside it.Additional context
The text was updated successfully, but these errors were encountered: