Skip to content

fix(eslint-plugin-query): fix no-void-query-fn false positive on enums for TS 6#10460

Open
park-jemin wants to merge 1 commit intoTanStack:mainfrom
park-jemin:fix/no-void-query-fn-ts6-enum
Open

fix(eslint-plugin-query): fix no-void-query-fn false positive on enums for TS 6#10460
park-jemin wants to merge 1 commit intoTanStack:mainfrom
park-jemin:fix/no-void-query-fn-ts6-enum

Conversation

@park-jemin
Copy link
Copy Markdown

@park-jemin park-jemin commented Apr 12, 2026

🎯 Changes

Resolves: #10461

The no-void-query-fn rule incorrectly reports a violation when returning a TypeScript enum member via queryFn. This only occurs when using TypeScript 6.0+

On investigating, looks like we're implicitly relying on these values for TypeFlags which should be internal to TS.

The underlying values for TypeFlags were reordered in this change: microsoft/TypeScript#63084. This ends up actually testing for UniqueESSymbol | EnumLiteral instead of Void | Undefined as intended.

Fix

Went ahead and replaced this flag check with checker.typeToString(), which should be a stable public API that works identically across all supported TypeScript versions since checker was introduced:

// Before (broken in TS 6)
return awaited.flags & (TypeFlags.Void | TypeFlags.Undefined) ? true : false

// After (works in TS 5.4+ and TS 6.0+)
const typeString = checker.typeToString(type)
return typeString === 'void' || typeString === 'undefined'

✅ 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

Bug Fixes

  • Fixed the no-void-query-fn ESLint rule to correctly handle TypeScript enum return types, preventing false positives when query functions return enum values.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 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: 6dc1c3c1-b050-40e5-8378-9f5ae1c89ce2

📥 Commits

Reviewing files that changed from the base of the PR and between 24de260 and 26d8141.

📒 Files selected for processing (3)
  • .changeset/no-void-query-fn-ts6-enum.md
  • packages/eslint-plugin-query/src/__tests__/no-void-query-fn.test.ts
  • packages/eslint-plugin-query/src/rules/no-void-query-fn/no-void-query-fn.rule.ts

📝 Walkthrough

Walkthrough

Fixed a TypeScript 6 compatibility issue in the no-void-query-fn ESLint rule where enum return types triggered false positives. The fix replaces numeric flag-bit checks with string-based type comparisons, adds comprehensive test coverage for enum scenarios, and includes a changelog entry.

Changes

Cohort / File(s) Summary
Rule Implementation
packages/eslint-plugin-query/src/rules/no-void-query-fn/no-void-query-fn.rule.ts
Replaced hardcoded TypeFlags constants and bitwise flag checks with checker.typeToString() for determining void/undefined return types, resolving TypeScript 6 compatibility where flag values were reordered.
Test Coverage
packages/eslint-plugin-query/src/__tests__/no-void-query-fn.test.ts
Added four new valid test cases covering numeric enum members, string enum members, async queryFn with enums, and const enum scenarios to verify the rule no longer falsely reports enum returns.
Changeset
.changeset/no-void-query-fn-ts6-enum.md
Added changeset entry documenting a patch release fixing the no-void-query-fn false positive with TypeScript 6 enum return types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 TypeScript enums, once causing a fright,
Now skip the lint check with string-based might!
No more false alarms when flags disagree,
Just simple string matching—works for TS6! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 accurately summarizes the main change: fixing a false positive in the no-void-query-fn rule when TypeScript 6 enum return types are involved.
Description check ✅ Passed The description follows the template with complete sections: it explains the issue (enum returns triggering false positive), the root cause (TypeFlags reordering in TS 6), and the fix (using checker.typeToString). Both checklist items are marked as completed.
Linked Issues check ✅ Passed The PR addresses issue #10461 by identifying the TypeFlags reordering problem and implementing a fix that replaces bitwise flag checks with checker.typeToString() to work across TS versions.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the no-void-query-fn rule: updating the implementation, adding test cases for enum returns, and creating the required changeset.

✏️ 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.

[eslint-plugin-query] no-void-query-fn false positive on enum returns with TypeScript 6

1 participant