Skip to content

Usage with eslint no-param-reassign #189

Closed
@brummelte

Description

@brummelte

I don't want to disable the eslint rule "no-param-reassign" globally, because it prevents errors.

So this seems to be the best way to use immer with that rule enabled:

const nextState = produce(baseState, (draftState) => {
    /* eslint-disable no-param-reassign */
    draftState.test = "New value";
    /* eslint-enable no-param-reassign */
});

There is a way to specify "ignorePropertyModificationsFor" for that eslint rule (https://eslint.org/docs/rules/no-param-reassign). So draftState could be ignored. But that would only exclude that name.

Is there a better way without disabling that rule?

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