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
[eslint-plugin-react-hooks]: auto-fix may crash app when deps is array/object types #16006
Comments
Yeah. See #15204 (comment) for context. I guess we’ll have to disable autofix if running it without looking is so common. The original intention was to make it an IDE suggestion only but ESLint doesn’t offer a way to do that. If we disable it, we’ll lose manual IDE autocompletion too which sucks. |
I’ll reach out to see if ESLint would be open to add a feature like this. |
Regarding the autofix, I hope eslint/rfcs#30 will let us solve the problem without compromising on IDE suggestions. |
Let's consolidate and track this in #16313 instead. |
This is resolved now. |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
before run lint, my code is
after 'eslint --fix'
The original code works fine and after 'eslint --fix' it just crashed cuz
optionCodes
is an array created in render function, the effect runs every time and crash my app with error :I've also notice this rule fix will add other params used by effect function to deps automatically. Like
What is the expected behavior?
For 'eslint --fix', what we expect is 'try to fix lint error automatically and SAFELY', SAFELY means DO NOT change my code logic, run 'eslint --fix' should never change your design or crash your app .
It would be better to tell developers to fix the deps by lint message, not auto fix it in dangerous way.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
eslint-plugin-react-hooks@1.6.1
The text was updated successfully, but these errors were encountered: