-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat(eslint-plugin-query): add rule that disallows putting the result of query hooks directly in a React hook dependency array #7911
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 5191cec. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
commit: @tanstack/angular-query-devtools-experimental
@tanstack/angular-query-experimental
@tanstack/eslint-plugin-query
@tanstack/query-async-storage-persister
@tanstack/query-broadcast-client-experimental
@tanstack/query-core
@tanstack/query-devtools
@tanstack/query-persist-client-core
@tanstack/query-sync-storage-persister
@tanstack/react-query
@tanstack/react-query-devtools
@tanstack/react-query-next-experimental
@tanstack/react-query-persist-client
@tanstack/solid-query
@tanstack/solid-query-devtools
@tanstack/solid-query-persist-client
@tanstack/svelte-query
@tanstack/svelte-query-devtools
@tanstack/svelte-query-persist-client
@tanstack/vue-query
@tanstack/vue-query-devtools
More templates
|
d98b8fd
to
e9ad2bc
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7911 +/- ##
===========================================
+ Coverage 44.64% 86.24% +41.60%
===========================================
Files 187 12 -175
Lines 7090 407 -6683
Branches 1575 158 -1417
===========================================
- Hits 3165 351 -2814
+ Misses 3562 42 -3520
+ Partials 363 14 -349
|
e9ad2bc
to
3eac412
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 🙏 . The same reasoning applies to the return value of useQuery
, useSuspenseQuery
, useQueries
, useSuspenseQueries
, useInfiniteQuery
and useSuspenseInfiniteQuery
as well. Do you think it would make sense to unify this into a single rule?
c077354
to
dd1ce96
Compare
@TkDodo I generalized the rule, please have a look. maybe there is a better name though ... |
4c024c0
to
ce75bc4
Compare
… of useMutation directly in a React hook dependency array
c0107d5
to
5191cec
Compare
@TkDodo can we merge this? |
I stumbled across #1858 a few times, so I wrote this eslint plugin.
It will detect if the return value of
useMutation
,useQuery
etc. is directly put in a React hook dependency array.