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

feat(eslint-plugin-query): add rule to ensure property order of infinite query functions #8072

Merged

Conversation

schiller-manuel
Copy link
Contributor

No description provided.

@github-actions github-actions bot added documentation Improvements or additions to documentation package: eslint-plugin-query labels Sep 19, 2024
Copy link

nx-cloud bot commented Sep 19, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 6182304. 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 1 target

Sent with 💌 from NxCloud.

Copy link

pkg-pr-new bot commented Sep 19, 2024

Open in Stackblitz

More templates

@tanstack/angular-query-devtools-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/angular-query-experimental

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query-devtools

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

@tanstack/react-query

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 6182304

@schiller-manuel schiller-manuel force-pushed the feat/eslint-infinite-query-property-order branch 2 times, most recently from 6736760 to 4084d0b Compare September 19, 2024 22:59
@schiller-manuel schiller-manuel force-pushed the feat/eslint-infinite-query-property-order branch from a08116f to 4084d0b Compare September 20, 2024 16:40
@schiller-manuel schiller-manuel force-pushed the feat/eslint-infinite-query-property-order branch from 82228d7 to a8ad7af Compare September 20, 2024 16:45
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 92.42424% with 5 lines in your changes missing coverage. Please review.

Project coverage is 44.97%. Comparing base (ca9e3c4) to head (6182304).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           main    #8072       +/-   ##
=========================================
+ Coverage      0   44.97%   +44.97%     
=========================================
  Files         0      199      +199     
  Lines         0     7362     +7362     
  Branches      0     1664     +1664     
=========================================
+ Hits          0     3311     +3311     
- Misses        0     3674     +3674     
- Partials      0      377      +377     
Components Coverage Δ
@tanstack/angular-query-devtools-experimental ∅ <ø> (∅)
@tanstack/angular-query-experimental 86.58% <ø> (∅)
@tanstack/eslint-plugin-query 87.15% <92.42%> (∅)
@tanstack/query-async-storage-persister 43.85% <ø> (∅)
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods 0.00% <ø> (∅)
@tanstack/query-core 92.81% <ø> (∅)
@tanstack/query-devtools 4.86% <ø> (∅)
@tanstack/query-persist-client-core 57.73% <ø> (∅)
@tanstack/query-sync-storage-persister 82.50% <ø> (∅)
@tanstack/react-query 92.50% <ø> (∅)
@tanstack/react-query-devtools 10.00% <ø> (∅)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (∅)
@tanstack/solid-query 78.20% <ø> (∅)
@tanstack/solid-query-devtools ∅ <ø> (∅)
@tanstack/solid-query-persist-client 100.00% <ø> (∅)
@tanstack/svelte-query 87.33% <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client 100.00% <ø> (∅)
@tanstack/vue-query 71.51% <ø> (∅)
@tanstack/vue-query-devtools ∅ <ø> (∅)

Comment on lines +9 to +13
export const checkedProperties = [
'queryFn',
'getPreviousPageParam',
'getNextPageParam',
] as const
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the full order that we must have in the object? Because it shouldn't matter if getNextPageParam comes before or after getPreviousPageParam - it only matters that they are after queryFn. So maybe it needs like a dependency tree:

const propertyDependencies = {
  queryFn: ['getPreviousPageParam', 'getNextPageParam']
}

this would define that 'getPreviousPageParam' and 'getNextPageParam' depend on queryFn and thus must be after it. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ideally a tree like structure would be best. I decided against this in router (similar issue with validateSearch and params.parse) to keep this plugin simple.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok fine by me for now

@TkDodo TkDodo merged commit f8d65fb into TanStack:main Sep 20, 2024
8 checks passed
@timvandam
Copy link

timvandam commented Sep 20, 2024

Can’t NoInfer<> make type inference work regardless of the order of properties? Or how exactly can the order of properties cause incorrect type inference?

@schiller-manuel
Copy link
Contributor Author

this is explained here

https://www.totaltypescript.com/property-order-matters

@timvandam
Copy link

I see, thanks for sharing

@schiller-manuel schiller-manuel deleted the feat/eslint-infinite-query-property-order branch September 21, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation package: eslint-plugin-query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants