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: wrong autofix for multi-line queries #4630

Closed
TkDodo opened this issue Dec 13, 2022 · 1 comment · Fixed by #4637
Closed

eslint: wrong autofix for multi-line queries #4630

TkDodo opened this issue Dec 13, 2022 · 1 comment · Fixed by #4637
Labels

Comments

@TkDodo
Copy link
Collaborator

TkDodo commented Dec 13, 2022

the following query auto-fixes correctly when using @tanstack/query/prefer-query-object-syntax:

// input
const query = useQuery(['key'], () => Promise.resolve('data'))

// output
const query = useQuery({ queryKey: ['key'], queryFn: () => Promise.resolve('data') })

However, if you have the same query in a multi-line setup, the output is wrong:

// input
const query = useQuery(
  ['key'], 
  () => Promise.resolve('data'),
)

// output

const query = useQuery(
    ,
{ queryKey: ['key'], queryFn: () => Promise.resolve('data') })

Gif of working version:
screencast 2022-12-13 16-17-33

Gif of non-working version
screencast 2022-12-13 16-16-17

@Newbie012 FYI

@TkDodo TkDodo added bug Something isn't working package: eslint-plugin-query labels Dec 13, 2022
@TkDodo TkDodo changed the title wrong autofix for multi-line queries eslint: wrong autofix for multi-line queries Dec 13, 2022
@Newbie012
Copy link
Collaborator

Newbie012 commented Dec 13, 2022

I'll take a look at it

Edit: #4637

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.

2 participants