You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
incorrect exhaustive-deps error for constant values when using them in queryOptions + in a const scope
import{queryOptions}from'@tanstack/react-query';constEXAMPLE_CONST=1;// This works greatexportconstthisDoesNotShowError=()=>({q3: queryOptions({queryKey: ['getAll'],queryFn: ()=>Promise.resolve(EXAMPLE_CONST),}),});// This shows an "The following dependencies are missing in your queryKey: EXAMPLE_CONST" errorexportconstthisShowsError={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)
Adjusted tests to ensure that the rule does not fail when a queryFn inside queryOptions contains a reference to an external variable. Also updated other tests to wrap query calls in a function component for consistency.
fix#8326
* fix: handle external variable in queryFn without failure
Adjusted tests to ensure that the rule does not fail when a queryFn inside queryOptions contains a reference to an external variable. Also updated other tests to wrap query calls in a function component for consistency.
fix#8326
* ci: apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Describe the bug
@tanstack/[email protected]
incorrect exhaustive-deps error for constant values when using them in queryOptions + in a
const
scopeYour minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-jx3ix8?file=src%2Ftest.ts
Steps to reproduce
queryOptions
in one of those property definitionsconst
outside the scope of the function@tanstack/query/exhaustive-deps
rule violationExpected 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
Additional context
Likely related to #5196, which was fixed in #5446
The text was updated successfully, but these errors were encountered: