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
Add option to ignore stable hooks from eslint-exhaustive-deps rule #20513
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 178bdeb:
|
|
Another idea is to have a pattern for dependencies instead of their hook (i.e. |
Details of bundled changes.Comparing: 50393dc...178bdeb eslint-plugin-react-hooks
Size changes (experimental) |
Details of bundled changes.Comparing: 50393dc...178bdeb eslint-plugin-react-hooks
Size changes (stable) |
|
Is this going to be the path forward or what other options are there besides ignoring eslint exhaustive hooks? |
|
I'm happy to resolve conflicts and pick it back up if maintainers want to. I think there might be forks that solve this problem. |
|
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated. |
|
Any updates on this? I've been using a prefix since it's hard to distinguish between stable and non stable deps, but it has kind of made the code unnecessarily verbose 😕 |
|
No interest from maintainers. You can get the diff from this and create your own eslint rule. Honestly I've just been passing stable refs to my dep list 🤷 |
|
Closing, I'll use a fork. Thanks @facebook |
|
bump |
|
bump x2 |
|
bump x3 |
Summary
I find myself using a bunch of custom
ref-esque dependencies inside ofuseEffect. I'd like to ignore them from exhaustive deps errors just like the rule currently ignoresuseRef. MyuseEffectdeps are usually decorated witheslint-ignores due to this, and non of my deps are linted anymore, including ones that are not coming from stable hooks.It would be nice to be able to ignore some of these globally, per file, or on a line basis. One way to go about it is to either add a pattern for stable hooks.
Example:
resolves #16873
Test Plan
I wrote a couple of tests for valid and invalid cases.