Skip to content

[eslint-plugin] exhaustive-deps reports error even if variable is set in allowList #10334

@antoine-cottineau

Description

@antoine-cottineau

Describe the bug

When using the following config for exhaustive-deps:

"@tanstack/query/exhaustive-deps": ["error", {"allowlist": {"variables": ["ignored"]} }]

This code produces an error:

export const incorrect = () => {
  const ignored = {
    run: () => new Promise()
  }

  useQuery({
    queryKey: ["test"],
    queryFn: () => ignored
    .run() // 💥
  });
};

However, if we change the formatting, the error disappears:

export const correct = () => {
  const ignored = {
    run: () => new Promise()
  }

  useQuery({
    queryKey: ["test"],
    queryFn: () => ignored.run() // ✅
  });
};

Your minimal, reproducible example

https://github.com/antoine-cottineau/tanstack-query-eslint-plugin-bug/tree/main

Steps to reproduce

  • run yarn install
  • run yarn lint

An error is found in the incorrect function but not in the correct one, even if the only difference is formatting.

Expected behavior

No error should be reported, whatever the formatting.

How often does this bug happen?

Every time

Screenshots or Videos

Image

Platform

  • OS: MacOS
  • Browser: Brave
  • Version: 1.88.134

Tanstack Query adapter

react-query

TanStack Query version

v5.95.2

TypeScript version

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions