Skip to content

eslint-plugin: "dependencies are missing in your queryKey" error if the dependency is cast to boolen #4429

@SpadarShut

Description

@SpadarShut

Describe the bug

if a dependency is used as !! myDependency in the key, missing dependency error is triggered.

Steps to reproduce

const useFoo = ({myNonSerializableDep}) => {
  return useQuery({
    // ESLint: The following dependencies are missing in your queryKey: myNonSerializableDep(@tanstack/query/exhaustive-deps)
    queryKey: ['foo', !!myNonSerializableDep], // <= get the error on this line
  })
} 

Expected behavior

there should be no error

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

MacOS

react-query version

4.14.1

TypeScript version

4.8.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions