TanStack / query

πŸ€– Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
https://tanstack.com/query
MIT License
42.75k stars 2.92k forks source link

fix: handle nullish coalescing operator in exhaustive-deps rule #8146

Closed Newbie012 closed 1 month ago

Newbie012 commented 1 month ago

fixes https://github.com/TanStack/query/issues/8131

Ensure that the exhaustive-deps rule correctly handles cases where the nullish coalescing operator (??) is used in query functions.

Example test case:

useQuery({
  queryKey: ["foo", options],
  queryFn: () => options?.params ?? options
});
nx-cloud[bot] commented 1 month ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 4e1774adf527439587a66ed0235edefcceb08719. 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 targets - [`nx affected --targets=test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build --parallel=3`](https://cloud.nx.app/runs/dcCwSSmgQ7?utm_source=pull-request&utm_medium=comment) - [`nx run-many --target=build --exclude=examples/** --exclude=integrations/**`](https://cloud.nx.app/runs/CtqBsWkE5x?utm_source=pull-request&utm_medium=comment)

Sent with πŸ’Œ from NxCloud.

pkg-pr-new[bot] commented 1 month ago

Open in Stackblitz

More templates

- [@tanstack/query-example-angular-basic](https://pkg.pr.new/template/c88f3eaf-afc3-4871-943e-7ab6a72c6fe4) - [@tanstack/query-example-angular-infinite-query-with-max-pages](https://pkg.pr.new/template/55de639c-f8b3-4868-b556-faaea730aa25) - [@tanstack/query-example-angular-pagination](https://pkg.pr.new/template/b207edf9-ef65-407e-aae2-e39c448dff88) - [@tanstack/query-example-angular-router](https://pkg.pr.new/template/c0f18514-1b72-40fd-b7b9-75f4fc7e2f78) - [@tanstack/query-example-angular-rxjs](https://pkg.pr.new/template/428fd253-80ea-4751-842e-7153de362a17) - [@tanstack/query-example-angular-simple](https://pkg.pr.new/template/1a82d29d-a531-446a-b9d9-786c54da1834) - [@tanstack/query-example-solid-astro](https://pkg.pr.new/template/7ad9c3d1-2654-42bc-97fd-1e414691d496) - [@tanstack/query-example-solid-basic](https://pkg.pr.new/template/61123a98-96f7-4acc-8ef7-c5747689c697) - [@tanstack/query-example-solid-basic-graphql-request](https://pkg.pr.new/template/8904c7ed-a86e-452f-ad16-25dd022f0e6d) - [@tanstack/query-example-solid-default-query-function](https://pkg.pr.new/template/6dfad8da-3e37-41c5-bee8-40c5e407ef0b) - [@tanstack/query-example-solid-simple](https://pkg.pr.new/template/8b90b319-0738-4e9b-88e9-5e8c6840ca4e) - [@tanstack/query-example-solid-start-streaming](https://pkg.pr.new/template/b70ec96f-c7f7-4774-b16e-79bc1fffb6d8) - [@tanstack/query-example-svelte-auto-refetching](https://pkg.pr.new/template/cf9710ae-f6a2-47d3-9b7f-36a7c5e61ed7) - [@tanstack/query-example-svelte-basic](https://pkg.pr.new/template/a454ffd7-7bca-4bfe-9a1a-e64252e9346c) - [@tanstack/query-example-svelte-load-more-infinite-scroll](https://pkg.pr.new/template/e403d9b2-8906-4ee2-83cf-ee0b60dec23f) - [@tanstack/query-example-svelte-optimistic-updates](https://pkg.pr.new/template/fb02286d-edb2-4848-bee4-5e2a3e485a74) - [@tanstack/query-example-svelte-playground](https://pkg.pr.new/template/21656a1a-4189-4fc2-a2ba-fbe9a6d8b63e) - [@tanstack/query-example-svelte-simple](https://pkg.pr.new/template/96a1c2db-15e9-4c61-9430-9240da89cf8d) - [@tanstack/query-example-svelte-ssr](https://pkg.pr.new/template/70afa8e5-ef5b-4cde-a588-37ea4fbc9b79) - [@tanstack/query-example-svelte-star-wars](https://pkg.pr.new/template/8e3ae3fb-4483-43a5-a520-065db5f65e86) - [@tanstack/query-example-react-algolia](https://pkg.pr.new/template/0bb1695b-e215-4a4f-bb46-006d58e4c6fc) - [@tanstack/query-example-react-auto-refetching](https://pkg.pr.new/template/3e142624-312a-4504-92ec-40e68e5afa18) - [@tanstack/query-example-react-basic](https://pkg.pr.new/template/2ac54282-edaf-4dfb-aa74-9ca57548bd68) - [@tanstack/query-example-react-basic-graphql-request](https://pkg.pr.new/template/fa7972df-328c-4d40-ae45-a09fdd5fc2f3) - [@tanstack/query-example-react-default-query-function](https://pkg.pr.new/template/d93a1e1e-0157-42be-bb67-9d2f885964d0) - [@tanstack/query-example-react-devtools-panel](https://pkg.pr.new/template/37b51378-2185-4851-9326-72be35532ee9) - [@tanstack/query-example-react-infinite-query-with-max-pages](https://pkg.pr.new/template/859288bf-cb44-42f1-88cf-8b34523e0917) - [@tanstack/query-example-react-load-more-infinite-scroll](https://pkg.pr.new/template/61e84c0b-9079-4750-bf4f-7ba5f19e6e19) - [@tanstack/query-example-react-nextjs](https://pkg.pr.new/template/11c74d8b-5fce-4c01-a714-82340621e560) - [@tanstack/query-example-react-nextjs-app-prefetching](https://pkg.pr.new/template/cf250fd3-8c0c-4f02-95f9-fd8bfabc762c) - [@tanstack/query-example-nextjs-suspense-streaming](https://pkg.pr.new/template/4bc1b853-52ba-4423-beb7-93a5994815a0) - [@tanstack/query-example-react-offline](https://pkg.pr.new/template/d8ab56b1-16a7-4162-ba99-6c8c1e838208) - [@tanstack/query-example-react-optimistic-updates-ui](https://pkg.pr.new/template/b1f3ab55-62f4-4650-a7ad-6498bcc79c1d) - [@tanstack/query-example-react-optimistic-updates-cache](https://pkg.pr.new/template/6ed6af0b-0ff0-48c8-91bd-189576ac8034) - [@tanstack/query-example-react-pagination](https://pkg.pr.new/template/d0ebe1b1-ebc1-41d5-b1ee-a9c3b23abe83) - [@tanstack/query-example-react-playground](https://pkg.pr.new/template/0f1ccde4-f7a6-43b2-b346-eb3255430d51) - [@tanstack/query-example-react-prefetching](https://pkg.pr.new/template/6a822711-6c52-4606-92d9-90e1df7946f5) - [@tanstack/query-example-react-router](https://pkg.pr.new/template/5de01ba5-0d7e-4c00-8816-e3ab55d0da98) - [@tanstack/query-example-react-react-native](https://pkg.pr.new/template/f229d80e-87c2-4591-b578-90df3d20b6af) - [@tanstack/query-example-react-rick-morty](https://pkg.pr.new/template/13a42b18-d765-4282-9094-831f1e09882d) - [@tanstack/query-example-react-shadow-dom](https://pkg.pr.new/template/5b8d5197-acd5-4c81-bd67-db328cd70e46) - [@tanstack/query-example-react-simple](https://pkg.pr.new/template/0a3b613e-de50-4d14-82c4-c6c1e56e1547) - [@tanstack/query-example-react-star-wars](https://pkg.pr.new/template/e716790e-c781-4cc3-a051-acf8b9bf430a) - [@tanstack/query-example-react-suspense](https://pkg.pr.new/template/cfccbd50-dd6b-4ee5-9f3f-d696ae2e97b8) - [@tanstack/query-example-vue-2.6-basic](https://pkg.pr.new/template/89c492b9-6ea5-42fa-86ef-181e9c8b711b) - [@tanstack/query-example-vue-2.7-basic](https://pkg.pr.new/template/92142809-030b-4299-bb40-e9f5f5197432) - [@tanstack/query-example-vue-basic](https://pkg.pr.new/template/c16e9644-9721-4f59-80f8-cfcb382985da) - [@tanstack/query-example-vue-dependent-queries](https://pkg.pr.new/template/7d34f229-8944-4b80-a92d-eac7daae4ef3) - [@tanstack/query-example-vue-nuxt3](https://pkg.pr.new/template/5a997c7c-9594-48de-87eb-71058d58274c) - [@tanstack/query-example-vue-persister](https://pkg.pr.new/template/7e50213d-188e-47b3-aeef-ad482af30f8c) - [@tanstack/query-example-vue-simple](https://pkg.pr.new/template/5c4472bb-5407-4f76-8973-b42763b0ed0d)

@tanstack/angular-query-devtools-experimental

``` pnpm add https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@8146 ```

@tanstack/eslint-plugin-query

``` pnpm add https://pkg.pr.new/@tanstack/eslint-plugin-query@8146 ```

@tanstack/angular-query-experimental

``` pnpm add https://pkg.pr.new/@tanstack/angular-query-experimental@8146 ```

@tanstack/query-broadcast-client-experimental

``` pnpm add https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@8146 ```

@tanstack/query-async-storage-persister

``` pnpm add https://pkg.pr.new/@tanstack/query-async-storage-persister@8146 ```

@tanstack/query-core

``` pnpm add https://pkg.pr.new/@tanstack/query-core@8146 ```

@tanstack/query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/query-devtools@8146 ```

@tanstack/query-persist-client-core

``` pnpm add https://pkg.pr.new/@tanstack/query-persist-client-core@8146 ```

@tanstack/query-sync-storage-persister

``` pnpm add https://pkg.pr.new/@tanstack/query-sync-storage-persister@8146 ```

@tanstack/react-query

``` pnpm add https://pkg.pr.new/@tanstack/react-query@8146 ```

@tanstack/react-query-next-experimental

``` pnpm add https://pkg.pr.new/@tanstack/react-query-next-experimental@8146 ```

@tanstack/react-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/react-query-devtools@8146 ```

@tanstack/solid-query

``` pnpm add https://pkg.pr.new/@tanstack/solid-query@8146 ```

@tanstack/react-query-persist-client

``` pnpm add https://pkg.pr.new/@tanstack/react-query-persist-client@8146 ```

@tanstack/solid-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/solid-query-devtools@8146 ```

@tanstack/solid-query-persist-client

``` pnpm add https://pkg.pr.new/@tanstack/solid-query-persist-client@8146 ```

@tanstack/svelte-query

``` pnpm add https://pkg.pr.new/@tanstack/svelte-query@8146 ```

@tanstack/svelte-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/svelte-query-devtools@8146 ```

@tanstack/svelte-query-persist-client

``` pnpm add https://pkg.pr.new/@tanstack/svelte-query-persist-client@8146 ```

@tanstack/vue-query

``` pnpm add https://pkg.pr.new/@tanstack/vue-query@8146 ```

@tanstack/vue-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/vue-query-devtools@8146 ```

commit: 4e1774a

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.82%. Comparing base (495b086) to head (4e1774a). Report is 1 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/TanStack/query/pull/8146/graphs/tree.svg?width=650&height=150&src=pr&token=jqEbswkEDQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack)](https://app.codecov.io/gh/TanStack/query/pull/8146?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) ```diff @@ Coverage Diff @@ ## main #8146 +/- ## ========================================= + Coverage 0 87.82% +87.82% ========================================= Files 0 15 +15 Lines 0 493 +493 Branches 0 183 +183 ========================================= + Hits 0 433 +433 - Misses 0 46 +46 - Partials 0 14 +14 ``` | [Components](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | Coverage Ξ” | | |---|---|---| | [@tanstack/angular-query-devtools-experimental](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/angular-query-experimental](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/eslint-plugin-query](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `87.82% <100.00%> (βˆ…)` | | | [@tanstack/query-async-storage-persister](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/query-broadcast-client-experimental](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/query-codemods](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/query-core](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/query-persist-client-core](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/query-sync-storage-persister](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/react-query](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/react-query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/react-query-next-experimental](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/react-query-persist-client](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/solid-query](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/solid-query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/solid-query-persist-client](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/svelte-query](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/svelte-query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/svelte-query-persist-client](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/vue-query](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | | | [@tanstack/vue-query-devtools](https://app.codecov.io/gh/TanStack/query/pull/8146/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `βˆ… <ΓΈ> (βˆ…)` | |