Skip to content

fix(eslint-plugin-query): fix no-unstable-deps false positive for useSuspenseQueries#10643

Open
lihan3238 wants to merge 1 commit intoTanStack:mainfrom
lihan3238:fix/eslint-no-unstable-deps-suspense-queries
Open

fix(eslint-plugin-query): fix no-unstable-deps false positive for useSuspenseQueries#10643
lihan3238 wants to merge 1 commit intoTanStack:mainfrom
lihan3238:fix/eslint-no-unstable-deps-suspense-queries

Conversation

@lihan3238
Copy link
Copy Markdown

@lihan3238 lihan3238 commented May 5, 2026

Summary

The no-unstable-deps ESLint rule was fixed for useQueries with combine in PR #9720, but the same false positive persists for useSuspenseQueries with combine. Using the combined value in a useMemo or useEffect dependency array incorrectly triggers the rule.

This PR extends the existing fix from #9720 to also cover useSuspenseQueries with a combine property. The rule now recognizes that useSuspenseQueries with combine returns a stable value, just like useQueries with combine.

Closes #10641

Changes

  • Updated no-unstable-deps rule to check for both useQueries and useSuspenseQueries when determining if the combine property makes the return value stable
  • Added test case for useSuspenseQueries with combine in the valid test cases

Test plan

  • All 1624 existing tests pass
  • New test case for useSuspenseQueries with combine passes
  • Existing invalid test for useSuspenseQueries without combine still correctly reports errors

Summary by CodeRabbit

  • Bug Fixes

    • Fixed the rule to correctly recognize useSuspenseQueries with a combine function as a referentially stable dependency, preventing false linting warnings when used in React hook dependency arrays.
  • Tests

    • Added test coverage validating the corrected behavior.

…SuspenseQueries

The `no-unstable-deps` rule was previously fixed for `useQueries` with
`combine` in PR TanStack#9720, but the same false positive persists for
`useSuspenseQueries` with `combine`. This extends the fix to also
recognize `useSuspenseQueries` with a `combine` property as returning
a stable value.

Closes TanStack#10641
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 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: eeb89a9a-df69-457c-abce-b21742e58e80

📥 Commits

Reviewing files that changed from the base of the PR and between 0d8d64b and d996791.

📒 Files selected for processing (2)
  • packages/eslint-plugin-query/src/__tests__/no-unstable-deps.test.ts
  • packages/eslint-plugin-query/src/rules/no-unstable-deps/no-unstable-deps.rule.ts

📝 Walkthrough

Walkthrough

The ESLint rule no-unstable-deps now treats useSuspenseQueries with a combine property as referentially stable, matching the existing behavior for useQueries. A test case validates that combined query results can safely be used in dependency arrays without triggering false positives.

Changes

ESLint Rule Extension for useSuspenseQueries with combine

Layer / File(s) Summary
Core Rule Logic
packages/eslint-plugin-query/src/rules/no-unstable-deps/no-unstable-deps.rule.ts
The VariableDeclarator handler now skips variable tracking for both useQueries and useSuspenseQueries when a combine property is present, treating combined results as referentially stable.
Test Validation
packages/eslint-plugin-query/src/__tests__/no-unstable-deps.test.ts
New valid test case confirms useSuspenseQueries with combine and queries.data in a React hook dependency array produces no lint error.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 A query without combine would hop away,
But now with useSuspenseQueries play,
The lint rule's wise to see them the same,
Referentially stable—no false blame! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing a false positive for useSuspenseQueries with combine in the no-unstable-deps ESLint rule.
Description check ✅ Passed The PR description provides good context about the fix, related issue, and changes made, but the checklist section lacks completed checkmarks for contributed and tested items.
Linked Issues check ✅ Passed The PR successfully addresses issue #10641 by extending the no-unstable-deps rule to treat useSuspenseQueries with combine as referentially stable, allowing its combined value in dependency arrays without triggering false positives.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective of fixing the useSuspenseQueries with combine false positive; no out-of-scope modifications are present.
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.

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.

@tanstack/query/no-unstable-deps - false positive with useSuspenseQueries() + combine

1 participant