Skip to content

refactor(preact-query*): rename local 'useRef' variables with the 'Ref' suffix - #11792

Merged
sukvvon merged 2 commits into
mainfrom
refactor/preact-query-eslint-react-naming
Oct 1, 2026
Merged

sukvvon merged 2 commits into
mainfrom
refactor/preact-query-eslint-react-naming

Conversation

@sukvvon

@sukvvon sukvvon commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

  • Rename local useRef variables with the Ref suffix: result → resultRef in preact-query/src/useMutationState.ts, and refs → optionsRef and didRestore → didRestoreRef in preact-query-persist-client/src/PersistQueryClientProvider.tsx.
  • In preact-query tests, name useState value and setter pairs instead of using holes or _ ([_state, setState], [_ref, setRef], [_newState, setNewState], setIsPrefetched), rename mounted to mountedRef, and use stable keys instead of array indexes in useInfiniteQuery and usePrefetchInfiniteQuery tests.

There is no runtime change. The built .d.ts files are identical, and the built JS only differs in the renamed local variables (and the Babel temporary variable names derived from them in the legacy build), so no changeset is needed.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Refactor
    • Updated internal naming in query persistence and mutation state handling. No user-facing behavior changed.
  • Tests
    • Updated pagination test rendering to use stable keys. Query results and pagination behavior remain unchanged.

@sukvvon sukvvon self-assigned this Oct 1, 2026
@nx-cloud

nx-cloud Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 8abb43f

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

☁️ Nx Cloud last updated this comment at 2026-10-01 01:59:29 UTC

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 84884906-86bb-4237-8fd0-291a6e91b84d

📥 Commits

Reviewing files that changed from the base of the PR and between 381e254 and 8abb43f.

📒 Files selected for processing (6)
  • packages/preact-query-persist-client/src/PersistQueryClientProvider.tsx
  • packages/preact-query/src/__tests__/fine-grained-persister.test.tsx
  • packages/preact-query/src/__tests__/useInfiniteQuery.test.tsx
  • packages/preact-query/src/__tests__/usePrefetchInfiniteQuery.test.tsx
  • packages/preact-query/src/__tests__/useQuery.test.tsx
  • packages/preact-query/src/useMutationState.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change renames internal refs and local test variables, and replaces index-based React keys in infinite-query tests with page-value keys. Restore, mutation-state, and query test behavior remains unchanged.

Changes

Preact query maintenance

Layer / File(s) Summary
Internal ref names
packages/preact-query-persist-client/src/PersistQueryClientProvider.tsx, packages/preact-query/src/useMutationState.ts
The provider renames refs used for persistence options and restore tracking. useMutationState renames its cached result ref. The described flows and state updates remain unchanged.
Infinite-query test keys
packages/preact-query/src/__tests__/useInfiniteQuery.test.tsx, packages/preact-query/src/__tests__/usePrefetchInfiniteQuery.test.tsx
Page elements in infinite-query tests use page values instead of array indices as keys. Two nested item-list keys are removed.
Test variable names
packages/preact-query/src/__tests__/fine-grained-persister.test.tsx, packages/preact-query/src/__tests__/useQuery.test.tsx
Test-local state variables, setters, and a ref are renamed. The summaries report no changes to test behavior or expectations.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 8abb4

No product behavior change or material merge risk is established. The test key updates use unique page values; merge after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: renaming local useRef variables with the Ref suffix.
Description check ✅ Passed The description explains the code and test changes, states the motivation and runtime impact, documents test execution, and completes the checklist and release-impact sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@pkg-pr-new

pkg-pr-new Bot commented Oct 1, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11792

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 8abb43f

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.73 KB (0%)
react minimal 8.58 KB (0%)

@sukvvon
sukvvon merged commit 3df6cb9 into main Oct 1, 2026
9 checks passed
@sukvvon
sukvvon deleted the refactor/preact-query-eslint-react-naming branch October 1, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant