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.72k stars 2.93k forks source link

fix(react-query): eslint-plugin-query now working with vanilla js #8322

Open ShyneADL opened 1 week ago

ShyneADL commented 1 week ago

To fix the issue with detecting imports in both TypeScript and JavaScript files, I modify the ImportDeclaration handler to handle cases where importKind might be undefined.

The key change is adding node.importKind === undefined to the condition. This ensures the import detection works for both TypeScript (whereimportKind is explicitly 'value') and JavaScript (where importKind is undefined).

This modification should resolve the lint plugin's compatibility issue with vanilla JavaScript apps by allowing import detection regardless of the importKind value.

closes #8257

nx-cloud[bot] commented 1 week ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit b23e44baf49c764d42087cfe67c77774c7e11940. 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/NlHC8xtEZb?utm_source=pull-request&utm_medium=comment) - [`nx run-many --target=build --exclude=examples/** --exclude=integrations/**`](https://cloud.nx.app/runs/BfTyB1tnTa?utm_source=pull-request&utm_medium=comment)

Sent with 💌 from NxCloud.

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

Open in Stackblitz

More templates

- [@tanstack/query-example-angular-basic](https://pkg.pr.new/template/cb1ea92e-c483-4c93-b138-4d8349fd4110) - [@tanstack/query-example-angular-devtools-panel](https://pkg.pr.new/template/a9e1f058-64f3-4e8a-8c70-6767c4fe0766) - [@tanstack/query-example-angular-infinite-query-with-max-pages](https://pkg.pr.new/template/596194bd-3af1-410e-afd5-1771f9a3ab8d) - [@tanstack/query-example-angular-query-options-from-a-service](https://pkg.pr.new/template/77ccdb14-0108-43f7-9ffa-65c84503db93) - [@tanstack/query-example-angular-router](https://pkg.pr.new/template/2cd10b73-3dc6-4339-9f36-71a9ac815399) - [@tanstack/query-example-angular-pagination](https://pkg.pr.new/template/55f123f5-bf07-4f33-bbac-f1421778afc3) - [@tanstack/query-example-angular-rxjs](https://pkg.pr.new/template/e92b4653-3118-4a88-9b91-357761284534) - [@tanstack/query-example-angular-simple](https://pkg.pr.new/template/91db8a09-105b-4e5d-9670-d491314cea21) - [@tanstack/query-example-solid-basic](https://pkg.pr.new/template/c3c27665-51a8-40dc-8188-f938887cad6d) - [@tanstack/query-example-solid-astro](https://pkg.pr.new/template/de3ec842-c9ef-4e68-bdd2-19eb7d6cb9a4) - [@tanstack/query-example-solid-basic-graphql-request](https://pkg.pr.new/template/4e0be50f-565f-4c57-b37e-bc9e3cfc08b1) - [@tanstack/query-example-solid-default-query-function](https://pkg.pr.new/template/f0cd4da4-8a2b-47d1-a9cc-2ae49cff10a1) - [@tanstack/query-example-solid-simple](https://pkg.pr.new/template/94697967-e8b7-4aff-8f38-4f2919315643) - [@tanstack/query-example-solid-start-streaming](https://pkg.pr.new/template/75ca22e3-e892-4c5a-a4cb-d5ed5ebab563) - [@tanstack/query-example-svelte-auto-refetching](https://pkg.pr.new/template/43dc1983-ab6d-4996-999e-86c36e238182) - [@tanstack/query-example-svelte-basic](https://pkg.pr.new/template/fb455268-518f-44d3-9c17-ac2db7047c2e) - [@tanstack/query-example-svelte-load-more-infinite-scroll](https://pkg.pr.new/template/e9506b4e-f7c8-4913-86a2-8066cf42736b) - [@tanstack/query-example-svelte-optimistic-updates](https://pkg.pr.new/template/25934ef0-795d-493b-bf6e-c3044efb8170) - [@tanstack/query-example-svelte-playground](https://pkg.pr.new/template/20fb3d6b-a35e-4f3f-87ca-6d5026fedd1b) - [@tanstack/query-example-svelte-simple](https://pkg.pr.new/template/7d9b3507-229b-4a58-af65-1ab3f7a05d5e) - [@tanstack/query-example-svelte-ssr](https://pkg.pr.new/template/81face8c-2c79-40c4-88d0-ac05c9c64119) - [@tanstack/query-example-svelte-star-wars](https://pkg.pr.new/template/6241b4ae-4a9d-4d65-89f4-52d50e8bdb56) - [@tanstack/query-example-react-algolia](https://pkg.pr.new/template/cf983559-2eb2-4fd2-92bf-91084195c123) - [@tanstack/query-example-react-basic](https://pkg.pr.new/template/06526813-7cdf-4da4-bbfe-8a28720e812e) - [@tanstack/query-example-react-auto-refetching](https://pkg.pr.new/template/c5e98fb7-5f7a-40eb-a826-ed75395f3087) - [@tanstack/query-example-react-basic-graphql-request](https://pkg.pr.new/template/cd674933-5736-42e3-b222-7cebc8da7b05) - [@tanstack/query-example-react-default-query-function](https://pkg.pr.new/template/20474068-8905-4406-9b9b-f6ada68fe7cf) - [@tanstack/query-example-react-infinite-query-with-max-pages](https://pkg.pr.new/template/73566eee-e7ab-4b0f-a412-be2ac9627eab) - [@tanstack/query-example-react-devtools-panel](https://pkg.pr.new/template/afad67da-8a5d-420e-bc4d-bbbf14c6d57e) - [@tanstack/query-example-react-load-more-infinite-scroll](https://pkg.pr.new/template/456ca617-500f-47d5-96e0-293c26f24fbf) - [@tanstack/query-example-react-nextjs](https://pkg.pr.new/template/39f2d29b-32bc-48dc-a3c2-76ef1341023e) - [@tanstack/query-example-react-nextjs-app-prefetching](https://pkg.pr.new/template/5ef31c9f-f41e-4ee5-a1b3-4ef73b7b2a10) - [@tanstack/query-example-nextjs-suspense-streaming](https://pkg.pr.new/template/1af43494-eb07-42ee-b12d-1f16d613f95b) - [@tanstack/query-example-react-offline](https://pkg.pr.new/template/79bbbd68-7a79-47bd-9cdb-d3cf3b7f65d8) - [@tanstack/query-example-react-optimistic-updates-cache](https://pkg.pr.new/template/9e09d3ff-b546-4794-86e3-2ec651a50e92) - [@tanstack/query-example-react-optimistic-updates-ui](https://pkg.pr.new/template/091ad86f-0310-4f29-9e5f-ef9713687188) - [@tanstack/query-example-react-pagination](https://pkg.pr.new/template/1d509673-d874-499a-8e0c-80b3f90622ac) - [@tanstack/query-example-react-prefetching](https://pkg.pr.new/template/7a6f46dc-8a0d-4841-9fc0-9aa6f974d344) - [@tanstack/query-example-react-playground](https://pkg.pr.new/template/4844128e-a919-4262-befc-00013897e6cd) - [@tanstack/query-example-react-react-native](https://pkg.pr.new/template/53f49df2-646d-4ace-8deb-9ce2198f5f48) - [@tanstack/query-example-react-router](https://pkg.pr.new/template/265ed98e-7958-4bf8-8c1f-506b7df7b058) - [@tanstack/query-example-react-rick-morty](https://pkg.pr.new/template/11053678-4ad1-4dc4-98b2-418cc8d1869a) - [@tanstack/query-example-react-shadow-dom](https://pkg.pr.new/template/6fe49981-109f-4f4f-9ace-1128d7d52d05) - [@tanstack/query-example-react-simple](https://pkg.pr.new/template/28e32f0b-ff1f-4432-b962-0a398eda8dd8) - [@tanstack/query-example-react-star-wars](https://pkg.pr.new/template/118d8dd2-d86c-4469-be1e-1d567e1d9741) - [@tanstack/query-example-react-suspense](https://pkg.pr.new/template/80f65d4c-9daf-4eb4-a43e-dfefcfdb934b) - [@tanstack/query-example-vue-2.7-basic](https://pkg.pr.new/template/e8c6851b-0ee4-4416-b7f2-56793e769b8a) - [@tanstack/query-example-vue-2.6-basic](https://pkg.pr.new/template/16624556-6162-424a-80f6-ec95b78759a9) - [@tanstack/query-example-vue-basic](https://pkg.pr.new/template/ee30b814-bb77-4453-8e70-d63221ffc830) - [@tanstack/query-example-vue-nuxt3](https://pkg.pr.new/template/7c76bb3f-8775-4b02-94f1-0226f7c0ce9b) - [@tanstack/query-example-vue-dependent-queries](https://pkg.pr.new/template/b5f0d38a-d3a7-4150-8087-c29e5bb4aa6f) - [@tanstack/query-example-vue-persister](https://pkg.pr.new/template/5c1e5142-595d-4b62-9fc1-a798f2a1d7b4) - [@tanstack/query-example-vue-simple](https://pkg.pr.new/template/9959e693-17a8-41ba-8b9b-0deac638affe)

@tanstack/angular-query-devtools-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/angular-query-experimental

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-devtools

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: b23e44b

TkDodo commented 1 week ago

there’s a lint error because typescript thinks the check is unnecessary:

/home/workflows/workspace/packages/eslint-plugin-query/src/utils/detect-react-query-imports.ts
  58:43  error  Unnecessary conditional, both sides of the expression are literal values  @typescript-eslint/no-unnecessary-condition

you must likely disable the linter for this line

codecov[bot] commented 5 days ago

Codecov Report

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

Project coverage is 88.15%. Comparing base (bdafc84) to head (b23e44b). 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/8322/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/8322?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) ```diff @@ Coverage Diff @@ ## main #8322 +/- ## =========================================== + Coverage 45.96% 88.15% +42.18% =========================================== Files 200 15 -185 Lines 7508 498 -7010 Branches 1715 186 -1529 =========================================== - Hits 3451 439 -3012 + Misses 3680 45 -3635 + Partials 377 14 -363 ``` | [Components](https://app.codecov.io/gh/TanStack/query/pull/8322/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/8322/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/8322/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/8322/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `88.15% <100.00%> (ø)` | | | [@tanstack/query-async-storage-persister](https://app.codecov.io/gh/TanStack/query/pull/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/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/8322/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TanStack) | `∅ <ø> (∅)` | |

🚨 Try these New Features: