Skip to content

[lint]: no-rest-destructuring only reports on inline destructuring #8747

Closed
@TkDodo

Description

@TkDodo

As shown in the docs, this correctly errors:

const useTodos = () => {
  const { data: todos, ...rest } = useQuery({
    queryKey: ['todos'],
    queryFn: () => api.getTodos(),
  })
  return { todos, ...rest }
}

but this does not:

const useTodos = () => {
  const query = useQuery({
    queryKey: ['todos'],
    queryFn: () => api.getTodos(),
  })
  return { ...rest, data: data[0] }
}

It would be great if any destucuring in the same scope could trigger the violation. Is that possible @Newbie012 ?

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