Skip to content

test(eslint-plugin-query/no-void-query-fn): add coverage for prefetchQuery, prefetchInfiniteQuery, ensureQueryData, ensureInfiniteQueryData#10353

Merged
TkDodo merged 2 commits intoTanStack:mainfrom
Zelys-DFKH:test/no-void-query-fn-prefetch-methods
Mar 30, 2026
Merged

test(eslint-plugin-query/no-void-query-fn): add coverage for prefetchQuery, prefetchInfiniteQuery, ensureQueryData, ensureInfiniteQueryData#10353
TkDodo merged 2 commits intoTanStack:mainfrom
Zelys-DFKH:test/no-void-query-fn-prefetch-methods

Conversation

@Zelys-DFKH
Copy link
Copy Markdown
Contributor

@Zelys-DFKH Zelys-DFKH commented Mar 29, 2026

Summary

Follows #10332, which added no-void-query-fn coverage for useInfiniteQuery, useSuspenseQuery, queryOptions, and fetchQuery. The four remaining QueryClient methods that accept a queryFn had no tests: prefetchQuery, prefetchInfiniteQuery, ensureQueryData, and ensureInfiniteQueryData.

Adds 5 valid cases and 5 invalid cases, one pair per method. No rule changes — the existing Property node check already handles these correctly.

All 1548 existing tests continue to pass.

Checklist

  • I have followed the steps in the Contributing guide
  • This change is docs/CI/dev-only (no release)

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for ESLint rule validation of React Query's QueryClient methods (prefetchQuery, prefetchInfiniteQuery, ensureQueryData, ensureInfiniteQueryData) to ensure proper detection of query function return value handling.

…Query, prefetchInfiniteQuery, ensureQueryData, ensureInfiniteQueryData
@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Mar 29, 2026

View your CI Pipeline Execution ↗ for commit 7e21b8b

Command Status Duration Result
nx run-many --target=build --exclude=examples/*... ✅ Succeeded <1s View ↗
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 20s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-30 13:06:26 UTC

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e385705-c0ad-4ccc-9853-f211075a4900

📥 Commits

Reviewing files that changed from the base of the PR and between afb5812 and 2c3c84c.

📒 Files selected for processing (1)
  • packages/eslint-plugin-query/src/__tests__/no-void-query-fn.test.ts

📝 Walkthrough

Walkthrough

This PR adds test coverage for an ESLint rule in the @tanstack/react-query eslint plugin, specifically for QueryClient methods prefetchQuery, prefetchInfiniteQuery, ensureQueryData, and ensureInfiniteQueryData. Tests validate that the rule correctly identifies when queryFn callbacks return values versus when they are void.

Changes

Cohort / File(s) Summary
no-void-query-fn Rule Tests
packages/eslint-plugin-query/src/__tests__/no-void-query-fn.test.ts
Added 114 lines of valid and invalid test cases for prefetchQuery, prefetchInfiniteQuery, ensureQueryData, and ensureInfiniteQueryData methods, verifying the rule correctly detects when queryFn implementations return values versus remain void.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

package: eslint-plugin-query

Poem

🐰 Hops through test cases, row by row,
Void and values, watch them go!
Query functions checked with care,
Linting patterns, tested fair!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the test coverage additions for four QueryClient methods, directly matching the pull request's main objective.
Description check ✅ Passed The description provides comprehensive context, references the related issue, explains the changes clearly, and includes both checklist items completed appropriately.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 29, 2026

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10353

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10353

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10353

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@10353

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10353

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10353

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10353

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@10353

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@10353

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10353

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10353

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@10353

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@10353

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10353

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10353

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@10353

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10353

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10353

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@10353

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10353

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10353

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@10353

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10353

commit: 7e21b8b

@TkDodo TkDodo merged commit 7e5fe21 into TanStack:main Mar 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants