javascript
javascript copied to clipboard
Ignore property modifications on params named "state"
The no-param-reassign rule allows property modifications for params with certain names, like acc and response. I would like to suggest that state is also allowed, for users of Redux Toolkit. The Redux Toolkit documentation recommends this.
state.push isn't reassignment; it's only state.x = mutation that seems like you're asking for?
https://redux-toolkit.js.org/usage/immer-reducers#resetting-and-replacing-state suggests that state = is actually a huge footgun and antipattern. I'm not sure it's worth it to have this in the default config, considering you can override/extend the rule config yourself to allow it.
Yep, it's only the state.x = pattern that I'm referring to. I've updated the description to be more clear.
If there was a way to prevent reassignment but allow mutation, that'd be worth considering, but i believe the rule doesn't offer that level of granularity.