-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Copy link
Description
Describe the bug
@tanstack/eslint-plugin-query@5.60.1
incorrect exhaustive-deps error for constant values when using them in queryOptions + in a const
scope
import { queryOptions } from '@tanstack/react-query';
const EXAMPLE_CONST = 1;
// This works great
export const thisDoesNotShowError = () => ({
q3: queryOptions({
queryKey: ['getAll'],
queryFn: () => Promise.resolve(EXAMPLE_CONST),
}),
});
// This shows an "The following dependencies are missing in your queryKey: EXAMPLE_CONST" error
export const thisShowsError = {
q3: queryOptions({
queryKey: ['getAll'],
queryFn: () => Promise.resolve(EXAMPLE_CONST),
}),
};
npx eslint ./test.ts
/workspace/example.ts
16:5 error The following dependencies are missing in your queryKey: EXAMPLE_CONST @tanstack/query/exhaustive-deps
✖ 1 problem (1 error, 0 warnings)
Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-jx3ix8?file=src%2Ftest.ts
Steps to reproduce
- Create an object with properties
- Use
queryOptions
in one of those property definitions - Access a
const
outside the scope of the function - ESLint will flag the
@tanstack/query/exhaustive-deps
rule violation
Expected behavior
Constants should not count as a dependency
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
VSCode
Tanstack Query adapter
None
TanStack Query version
v5.59.9
TypeScript version
v5.3.3