query icon indicating copy to clipboard operation
query copied to clipboard

ESLint prefer-query-object-syntax rule dose not fix and raise error useInfiniteQuery

Open say8425 opened this issue 2 years ago • 3 comments

Describe the bug

@tanstack/query/prefer-query-object-syntax rule dose not look useInfiniteQuery to a error.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/old-microservice-g6mfwh?file=%2Fpages%2Findex.js%3A36%2C1-37%2C1

Steps to reproduce

  1. install @tanstack/eslint-plugin-query
  2. configure @tanstack/query/prefer-query-object-syntax rule
  3. run eslint fix

Expected behavior

useInfiniteQuery should be error and can be fixed.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • macOS 13.4
  • Chrome 114

Tanstack Query adapter

None

TanStack Query version

v4.0.10

TypeScript version

v5.0.4

Additional context

I think adding useInfiniteQuery, useIsFetching, useIsMutating into QUERY_CALLS will fix this issue. Is that true, then I will fix it.

say8425 avatar Jun 12 '23 07:06 say8425

yes, it's only implemented for useQuery. Not sure if we have plans to add anything else, because in v5, the rule is removed because the object syntax is the only valid syntax.

If it's as staightforward as your analysis shows, please go ahead and make a PR with some tests to verify, and I'll happily merge it :)

@Newbie012 FYI

TkDodo avatar Jun 12 '23 08:06 TkDodo

@TkDodo should I update the rule to catch useInfiniteQuery as well?

Newbie012 avatar Jul 17 '23 14:07 Newbie012

@Newbie012 yes please

TkDodo avatar Jul 17 '23 14:07 TkDodo

@TkDodo since we removed prefer-query-object-syntax, should we close this issue?

Newbie012 avatar Apr 02 '24 09:04 Newbie012