jsx-eslint / eslint-plugin-react

React-specific linting rules for ESLint
MIT License
8.86k stars 2.75k forks source link

[Bug]: Rule "react/no-direct-mutation-state" failing in a stateless component #3751

Closed Lucasdsk closed 1 month ago

Lucasdsk commented 1 month ago

Is there an existing issue for this?

Description Overview

I've created a new project using eslint 9 that brings the eslint-plugin-react config, then I've installed storybook that brings the default Button component as an example.

Default Button component:

image

Eslint config

image

Error

image

Expected Behavior

I believe it shouldn't happen on a function component since the rule is related to not direct mutate a state. I understand I can't disble that rule, otherwise it wont throw an error if there's a code where the state is being directly mutated.

eslint-plugin-react version

7.34.1

eslint version

9.2.0

node version

v20.13.0

Lucasdsk commented 1 month ago

Closing this issue since the work is still in progress to adapt to the eslint 9. Work in progress: https://github.com/jsx-eslint/eslint-plugin-react/pull/3743

I'll use eslint 8 meanwhile.