Skip to content
Source
Sign inSign up
TanStack/query

ESLint rule `@tanstack/query/exhaustive-deps` reports missing dependencies when using optional changing #8112

Send to my agent
Closednickrttn(GitHub profile, opens in a new tab) opened this issue 3 comments

Describe the bug

The ESLint rule @tanstack/query/exhaustive-deps reports false positive missing dependencies when using optional chaining in the queryKey.

Your minimal, reproducible example

https://stackblitz.com/edit/stackblitz-starters-rqku3u?file=app%2Fuse-users.ts

Steps to reproduce

  1. Go to https://stackblitz.com/edit/stackblitz-starters-rqku3u?file=app%2Fuse-users.ts
  2. Run npx eslint . in the terminal

Expected behavior

I would not expect an error to be shown when linting. I would expect the optional chaining to be valid.

How often does this bug happen?

Every time

Screenshots or Videos

Image

Platform

  • macOS Sequoia 15.0

Tanstack Query adapter

react-query

TanStack Query version

5.45.1

TypeScript version

5.6.2

Additional context

No response

  1. TkDodo added labelsbug

  2. TkDodo added labelspackage: eslint-plugin-query

  3. do you want to work on this @nickrttn ?

  4. TkDodo assignednickrttn

  5. TkDodo closed this

Sign in to join this conversation.