Skip to content

Conversation

@gk9848970
Copy link
Contributor

@gk9848970 gk9848970 commented Dec 31, 2025

🎯 Changes

Fixes: #9962

In this PR, I am identifying vue files and and fixing the exhaustive depths rule not working for them.
Motivation - Thought to start my new year with some OSS contribution

In react, Similar case which works fine

Screenshot 2026-01-01 at 12 54 38 AM

Before this PR

Screenshot 2026-01-01 at 12 58 34 AM

After this PR

Screenshot 2026-01-01 at 12 57 02 AM

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

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

changeset-bot bot commented Dec 31, 2025

🦋 Changeset detected

Latest commit: 818e9b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/eslint-plugin-query Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 31, 2025

📝 Walkthrough

Walkthrough

The changes fix the exhaustive-deps ESLint rule for Vue single-file components by adding filename context to dependency reference validation. When no function ancestor exists, the rule now specifically validates Vue files and treats undefined definitions and imports as globals, preventing false positives.

Changes

Cohort / File(s) Summary
Changeset
.changeset/slimy-taxes-make.md
Patch bump for @tanstack/eslint-plugin-query documenting the exhaustive-deps rule fix for Vue files
Test additions
packages/eslint-plugin-query/src/__tests__/exhaustive-deps.test.ts
Adds Vue single-file component test scenarios covering valid cases (correct deps, imports/globals excluded) and invalid cases (missing deps with fix suggestions)
Core implementation
packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.rule.ts, exhaustive-deps.utils.ts
Passes filename context to isRelevantReference; reworks control flow to differentiate between function scope and Vue file context, treating undefined definitions and imports as non-relevant in Vue files

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • TkDodo
  • Newbie012

Poem

🐰 Through Vue's component files we hop,
Dependencies we'll never drop,
With filenames to guide our way,
Exhaustive checks will save the day! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: fixing the exhaustive-deps ESLint rule for Vue files, which is the core objective of this PR.
Description check ✅ Passed The description includes changes explanation, all checklist items checked, and release impact documented with a changeset generated, following the template requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

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.

@gk9848970 gk9848970 changed the title Fixes Eslint plugin exhaustive deps rule not working for vue files Dec 31, 2025
@nx-cloud
Copy link

nx-cloud bot commented Dec 31, 2025

View your CI Pipeline Execution ↗ for commit 818e9b7

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

☁️ Nx Cloud last updated this comment at 2025-12-31 19:36:32 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 31, 2025

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 818e9b7

@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.82%. Comparing base (f616474) to head (818e9b7).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #10011       +/-   ##
===========================================
+ Coverage   45.82%   83.82%   +37.99%     
===========================================
  Files         200       19      -181     
  Lines        8525      581     -7944     
  Branches     1977      216     -1761     
===========================================
- Hits         3907      487     -3420     
+ Misses       4158       72     -4086     
+ Partials      460       22      -438     
Components Coverage Δ
@tanstack/angular-query-experimental ∅ <ø> (∅)
@tanstack/eslint-plugin-query 83.82% <100.00%> (+0.22%) ⬆️
@tanstack/query-async-storage-persister ∅ <ø> (∅)
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods ∅ <ø> (∅)
@tanstack/query-core ∅ <ø> (∅)
@tanstack/query-devtools ∅ <ø> (∅)
@tanstack/query-persist-client-core ∅ <ø> (∅)
@tanstack/query-sync-storage-persister ∅ <ø> (∅)
@tanstack/query-test-utils ∅ <ø> (∅)
@tanstack/react-query ∅ <ø> (∅)
@tanstack/react-query-devtools ∅ <ø> (∅)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client ∅ <ø> (∅)
@tanstack/solid-query ∅ <ø> (∅)
@tanstack/solid-query-devtools ∅ <ø> (∅)
@tanstack/solid-query-persist-client ∅ <ø> (∅)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query ∅ <ø> (∅)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

��� Nitpick comments (1)
packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.utils.ts (1)

26-40: LGTM! Vue file handling logic is sound.

The Vue-specific logic correctly identifies Vue single-file components and excludes global variables and imports from required dependencies, matching the expected behavior from React's exhaustive-deps rule. This properly handles Vue 3's Composition API script setup where code runs at the module level without a wrapping function.

💡 Optional: Consider adding an explanatory comment

Adding a brief comment would help future maintainers understand why Vue files are treated differently:

    } else {
+     // Vue SFCs with script setup run at module level without a function wrapper.
+     // Check filename to apply Vue-specific reference resolution.
      const isVueFile = filename.endsWith('.vue')
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f616474 and 0e55211.

📒 Files selected for processing (4)
  • .changeset/slimy-taxes-make.md
  • packages/eslint-plugin-query/src/__tests__/exhaustive-deps.test.ts
  • packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.rule.ts
  • packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.utils.ts
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-09-02T17:57:33.184Z
Learnt from: TkDodo
Repo: TanStack/query PR: 9612
File: packages/query-async-storage-persister/src/asyncThrottle.ts:0-0
Timestamp: 2025-09-02T17:57:33.184Z
Learning: When importing from tanstack/query-core in other TanStack Query packages like query-async-storage-persister, a workspace dependency "tanstack/query-core": "workspace:*" needs to be added to the package.json.

Applied to files:

  • .changeset/slimy-taxes-make.md
📚 Learning: 2025-08-19T03:18:18.303Z
Learnt from: oscartbeaumont
Repo: TanStack/query PR: 9564
File: packages/solid-query-devtools/src/production.tsx:2-3
Timestamp: 2025-08-19T03:18:18.303Z
Learning: In the solid-query-devtools package, the codebase uses a pattern of type-only default imports combined with typeof for component type annotations (e.g., `import type SolidQueryDevtoolsComp from './devtools'` followed by `typeof SolidQueryDevtoolsComp`). This pattern is consistently used across index.tsx and production.tsx files, and the maintainers prefer consistency over changing this approach.

Applied to files:

  • packages/eslint-plugin-query/src/__tests__/exhaustive-deps.test.ts
📚 Learning: 2025-11-22T09:06:05.219Z
Learnt from: sukvvon
Repo: TanStack/query PR: 9892
File: packages/solid-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx:331-335
Timestamp: 2025-11-22T09:06:05.219Z
Learning: In TanStack/query test files, when a queryFn contains side effects (e.g., setting flags for test verification), prefer async/await syntax for clarity; when there are no side effects, prefer the .then() pattern for conciseness.

Applied to files:

  • packages/eslint-plugin-query/src/__tests__/exhaustive-deps.test.ts
🧬 Code graph analysis (2)
packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.utils.ts (1)
packages/eslint-plugin-query/src/utils/ast-utils.ts (1)
  • ASTUtils (5-391)
packages/eslint-plugin-query/src/__tests__/exhaustive-deps.test.ts (1)
packages/eslint-plugin-query/src/__tests__/test-utils.ts (1)
  • normalizeIndent (3-7)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test
🔇 Additional comments (8)
packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.utils.ts (2)

11-13: LGTM! Filename context added correctly.

The filename parameter is properly added to the function signature and destructured, enabling file-context-aware relevance checks for Vue files.


16-26: LGTM! Existing React/Solid logic preserved correctly.

The function ancestor check remains unchanged, maintaining the original behavior for React and Solid components where references must be declared within the component function.

packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.rule.ts (1)

85-85: LGTM! Filename context properly plumbed through.

The filename from the ESLint rule context is correctly passed to the utility function, enabling file-based relevance checks.

packages/eslint-plugin-query/src/__tests__/exhaustive-deps.test.ts (5)

551-563: LGTM! Vue valid test case properly structured.

This test correctly validates that the rule passes when local variables are properly included in the queryKey for Vue single-file components with script setup.


564-576: LGTM! Import exclusion test is correct.

This test properly validates that imported functions (ImportBinding) are correctly excluded from required dependencies in Vue files, matching the expected behavior from React hooks.


577-589: LGTM! Global variable exclusion test is correct.

This test properly validates that global variables like fetch are correctly excluded from required dependencies while local variables like id are still required, demonstrating the correct distinction in Vue files.


1017-1050: LGTM! Single missing dependency test is comprehensive.

This test correctly validates that the rule identifies missing local variables in Vue files and provides an appropriate fix suggestion. The test structure matches existing patterns and the expected output is accurate.


1051-1086: LGTM! Multiple missing dependencies test is comprehensive.

This test correctly validates that the rule can identify and suggest fixes for multiple missing dependencies in Vue files, with proper comma-separated output and correct fix suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment