Open ianschmitz opened 7 years ago
maybe just go ahead and send a pr?
Seems reasonable. However, this rule would have to warn any time the entire props object is passed to a function (which is a bad practice anyways) because that makes it impossible (in most cases) to determine if it's being mutated.
How can I achieve "no-mutation-props" in my eslint config ?
@pgangwani #1416 isn’t merged yet.
I desperately need this. Got bunch of issues and instance where Devs have written this.props.someKey = "somevalue" in render functions.
Who can merge and by when ?
You can read the PR to find out the challenges.
Really, stopping mutation isn’t something that can be done with static analysis - you can do it in your tests more reliably.
A component is never meant to modify its own props (https://facebook.github.io/react/docs/components-and-props.html#props-are-read-only).
I suggest we had a
no-mutation-props
rule to check for mutations of a components own props. It looks like we could likely copy the logic used in no-direct-mutation-state.js.