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

eslint-plugin-react-hooks - autofix useCallback/useMemo behaviour #15153

Open
RedTn opened this issue Mar 19, 2019 · 0 comments
Open

eslint-plugin-react-hooks - autofix useCallback/useMemo behaviour #15153

RedTn opened this issue Mar 19, 2019 · 0 comments

Comments

@RedTn
Copy link
Contributor

RedTn commented Mar 19, 2019

Do you want to request a feature or report a bug?

Discussion for new feature

What is the current behavior?

useCallback/useMemo hook's do nothing when there is no second argument provided for deps. The eslint plugin reports this but does not autofix

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

16.8.4

PR to implement:

#15146

 

Currently, the eslint plugin does not autofix useCallback/useMemo to infer deps if there isn't a second argument provided to the hook. We can autofix it to infer deps if needed, or autofix to remove the hook altogether if there no deps needed (according to https://reactjs.org/docs/hooks-reference.html#usememo, if no second argument is provided it behaves as if the hook doesn't exist anyways).

What would be the best way to implement this autofix? In my opinion, linting shouldn't be breaking functionality on an autofix, so autofixing to remove the hook is the safest to implement. Autofixing to infer deps will change behavior in code so I was thinking of having a config option the dev needs to specify so that linting changes that is affecting behavior is explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants