Skip to content
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

Ignore property modifications on params named "state" #2485

Open
openjck opened this issue Oct 21, 2021 · 3 comments
Open

Ignore property modifications on params named "state" #2485

openjck opened this issue Oct 21, 2021 · 3 comments

Comments

@openjck
Copy link

openjck commented Oct 21, 2021

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.

@ljharb
Copy link
Collaborator

ljharb commented Oct 21, 2021

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.

@openjck
Copy link
Author

openjck commented Oct 21, 2021

Yep, it's only the state.x = pattern that I'm referring to. I've updated the description to be more clear.

@ljharb
Copy link
Collaborator

ljharb commented Oct 21, 2021

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.

@openjck openjck changed the title Allow reassignments of parameters named "state" Allow reassignments of properties of parameters named "state" Oct 21, 2021
@openjck openjck changed the title Allow reassignments of properties of parameters named "state" Ignore property modifications on params named "state" Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants