Skip to content

Conversation

@Newbie012
Copy link
Collaborator

@Newbie012 Newbie012 commented Oct 15, 2025

🎯 Changes

fixes #9097

While a proper solution would be to split rules that requires type check, it's a bit too early to do it. for now, let's keep it simple.

βœ… 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).

Summary by CodeRabbit

  • New Features
    • None
  • Bug Fixes
    • Updated the β€œno-void-query-fn” lint rule to remove reliance on a direct TypeScript import and instead use parser-provided type information, improving compatibility and reducing incorrect reports or crashes for awaited void/undefined returns.
  • Chores
    • Added a changeset entry for a patch release of the ESLint plugin.

@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

πŸ¦‹ Changeset detected

Latest commit: d9ad4a7

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 Oct 15, 2025

Walkthrough

Replaces direct typescript runtime import in the no-void-query-fn ESLint rule with type-only parser-service usage; adds a changeset entry for a patch release describing this avoidance and refactors type-checking to use local TypeFlags and parser-derived type aliases.

Changes

Cohort / File(s) Summary
Release metadata
/.changeset/shy-wasps-pull.md
Adds a patch changeset for @tanstack/eslint-plugin-query explaining the removal of a direct TypeScript import in the rule.
Rule refactor (no direct TS import)
/packages/eslint-plugin-query/src/rules/no-void-query-fn/no-void-query-fn.rule.ts
Removes runtime typescript usage; adds a type-only import for ParserServicesWithTypeInformation; derives Program, TypeChecker, and Type aliases from parser services; introduces local TypeFlags constants (Void, Undefined) and updates return-type checks to use parser-provided type checker and bitwise checks against local flags.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as ESLint CLI
  participant ESL as ESLint
  participant Rule as no-void-query-fn rule
  participant PS as ParserServicesWithTypeInformation
  participant TC as TypeChecker (from PS)

  Dev->>ESL: Run lint
  ESL->>Rule: Evaluate rule for function node
  Rule->>PS: getParserServices() / request Program & services
  PS-->>Rule: Program, parser services, and typeChecker
  Rule->>TC: getTypeAtLocation(returnNode)
  TC-->>Rule: Type
  Note over Rule: Use local TypeFlags (Void/Undefined) to check awaited type
  Rule-->>ESL: Report violation if illegal void/undefined return
  ESL-->>Dev: Lint results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • lachlancollins
  • TkDodo

Poem

A rabbit hops through parser trees at night,
I swap imports for services, tidy and light.
Flags for void and undefined I spy,
I nibble buggy returns as they flutter by.
Patch stitched, I thumpβ€”merge takes flight. πŸ₯•

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description includes the required sections and a completed checklist, but the 🎯 Changes section still contains the placeholder comment and lacks a clear summary of the actual code modifications. This omission obscures the specific updates made to the ESLint rule and the motivation behind them. Because the placeholder remains, reviewers cannot quickly verify the scope and impact of the change. The authors should remove the placeholder comment in the 🎯 Changes section and provide a concise description of the code changes, such as replacing TypeScript imports with parser services and updating type checks.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (3 passed)
Check name Status Explanation
Title Check βœ… Passed The pull request title succinctly and accurately reflects the primary change of avoiding direct TypeScript imports in the ESLint plugin rule and follows conventional commit style with an appropriate scope. It clearly conveys the intent without extraneous detail or vagueness and will be informative in the project history. This makes it easy for anyone scanning the commit log to understand the key fix at a glance.
Linked Issues Check βœ… Passed The modifications remove direct imports of the TypeScript package by using type-only imports of ParserServicesWithTypeInformation and deriving type checker interfaces from parser services, which directly addresses the peer dependency resolution failures described in issue #9097. It replaces direct ts.TypeFlags usage with a local TypeFlags constant and integrates with parser-provided type information. These changes ensure ESLint can run without requiring a hoisted TypeScript dependency and align with the expected behavior outlined in the linked issue.
Out of Scope Changes Check βœ… Passed All modifications are limited to the changeset entry and the no-void-query-fn ESLint rule, which are both directly related to fixing the TypeScript import issue. There are no unrelated or out-of-scope updates in this pull request. The changes do not introduce any additional features or affect other parts of the codebase.
✨ Finishing touches
  • πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-avoid-importing-typescript

πŸ“œ Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 35da1a6 and d9ad4a7.

πŸ“’ Files selected for processing (1)
  • packages/eslint-plugin-query/src/rules/no-void-query-fn/no-void-query-fn.rule.ts (3 hunks)
⏰ 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 (2)
packages/eslint-plugin-query/src/rules/no-void-query-fn/no-void-query-fn.rule.ts (2)

5-5: Excellent approach to eliminate the runtime typescript dependency.

The type-only import and derived type aliases successfully avoid importing typescript at runtime while maintaining full type safety through the parser services. This directly addresses the core issue reported in #9097 where package managers without hoisting couldn't resolve the typescript module.

Also applies to: 77-79


81-81: Function correctly updated to use local types and flags.

The function signature and bitwise flag check properly utilize the locally defined type aliases and TypeFlags constant, maintaining the original logic while eliminating the typescript import dependency.

Also applies to: 90-90


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.

@nx-cloud
Copy link

nx-cloud bot commented Oct 15, 2025

View your CI Pipeline Execution β†— for commit d9ad4a7

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... βœ… Succeeded 1m 28s View β†—
nx run-many --target=build --exclude=examples/*... βœ… Succeeded 5s View β†—

☁️ Nx Cloud last updated this comment at 2025-10-15 08:18:16 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 15, 2025

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: d9ad4a7

@github-actions
Copy link
Contributor

github-actions bot commented Oct 15, 2025

Sizes for commit d9ad4a7:

Branch Bundle Size
Main
This PR

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
βœ… Project coverage is 83.36%. Comparing base (36ece87) to head (d9ad4a7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #9759       +/-   ##
===========================================
+ Coverage   45.54%   83.36%   +37.81%     
===========================================
  Files         196       19      -177     
  Lines        8328      559     -7769     
  Branches     1903      204     -1699     
===========================================
- Hits         3793      466     -3327     
+ Misses       4093       71     -4022     
+ Partials      442       22      -420     
Components Coverage Ξ”
@tanstack/angular-query-experimental βˆ… <ΓΈ> (βˆ…)
@tanstack/eslint-plugin-query 83.36% <33.33%> (+0.32%) ⬆️
@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: 1

🧹 Nitpick comments (1)
packages/eslint-plugin-query/src/rules/no-void-query-fn/no-void-query-fn.rule.ts (1)

81-91: LGTM!

The refactored isIllegalReturn function correctly uses the local TypeFlags constant and maintains the same logic as before.

Optional: The ternary on line 90 can be simplified:

-  return awaited.flags & (TypeFlags.Void | TypeFlags.Undefined) ? true : false
+  return (awaited.flags & (TypeFlags.Void | TypeFlags.Undefined)) !== 0
πŸ“œ Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 36ece87 and 35da1a6.

πŸ“’ Files selected for processing (2)
  • .changeset/shy-wasps-pull.md (1 hunks)
  • packages/eslint-plugin-query/src/rules/no-void-query-fn/no-void-query-fn.rule.ts (3 hunks)
⏰ 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). (2)
  • GitHub Check: Preview
  • GitHub Check: Test
πŸ”‡ Additional comments (3)
.changeset/shy-wasps-pull.md (1)

1-5: LGTM!

The changeset correctly documents this as a patch-level fix. The description accurately captures the essence of the change.

packages/eslint-plugin-query/src/rules/no-void-query-fn/no-void-query-fn.rule.ts (2)

5-5: LGTM!

The type-only import of ParserServicesWithTypeInformation is correct and eliminates the need for direct TypeScript imports.


77-79: LGTM!

The type aliases correctly derive types from ParserServicesWithTypeInformation without importing TypeScript directly. This approach is actually more type-safe because it guarantees compatibility with the parser services' actual return types.

@TkDodo TkDodo merged commit b9a478d into main Oct 15, 2025
8 of 9 checks passed
@TkDodo TkDodo deleted the fix-avoid-importing-typescript branch October 15, 2025 08:28
@github-actions github-actions bot mentioned this pull request Oct 15, 2025
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/eslint-plugin-query missing (peer) dependency on typescript

3 participants