Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint-plugin-query: exhaustive-deps does not suport queryFn() {} syntax #7202

Closed
rodrigorm opened this issue Mar 30, 2024 · 3 comments · Fixed by #7213
Closed

eslint-plugin-query: exhaustive-deps does not suport queryFn() {} syntax #7202

rodrigorm opened this issue Mar 30, 2024 · 3 comments · Fixed by #7213
Labels

Comments

@rodrigorm
Copy link

Describe the bug

Usage of the following syntax does not trigger an error from "@tanstack/query/exhaustive-deps":

const id = "foo";

useQuery({
  queryKey: ["deps"],
  queryFn() {
      return id;
  }
});

What I have found is this syntax trigger an error:

const id = "foo";

useQuery({
  queryKey: ["deps"],
  queryFn: () => {
      return id;
  }
});

Your minimal, reproducible example

https://codesandbox.io/p/devbox/fancy-lake-hymxyk

Steps to reproduce

  1. Go to https://codesandbox.io/p/devbox/fancy-lake-hymxyk
  2. Fork
  3. Open a new Terminal
  4. Run yarn eslint src/index.jsx

Expected behavior

Expected output:

yarn run v1.22.19
$ /workspace/node_modules/.bin/eslint src/index.jsx

/workspace/src/index.jsx
  25:5  error  The following dependencies are missing in your queryKey: endpoint  @tanstack/query/exhaustive-deps

✖ 1 problem (1 error, 0 warnings)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Any

Tanstack Query adapter

react-query

TanStack Query version

v5.28.6

TypeScript version

v5.3.0

Additional context

No response

@TkDodo
Copy link
Collaborator

TkDodo commented Apr 2, 2024

@Newbie012 FYI

@Newbie012
Copy link
Collaborator

Will be fixed once #7213 is merged

@rodrigorm
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants