Skip to content

[lint]: no-rest-destructuring does not report on custom hooks #8951

Open
@zbarbuto

Description

@zbarbuto

Describe the bug

When using custom hooks for a query function, the no-rest-destructuring does not report.

Steps to reproduce

// Custom hook for query
const useTodos = () => {
  return useQuery({
    queryKey: ['todos'],
    queryFn: () => fetch('example.com/todos'),
  });
  // NB results the same with const result = useQuery(/* */); return result;
};

function TodoList() {
  // ✅ Normal usage - issue reported
  const { dataA, ...restA } = useQuery({
    queryKey: ['todos'],
    queryFn: () => fetch('example.com/todos'),
  });

  // ❌ Custom hook - no issue reported
  const { dataB, ...restB } = useTodos();

  return <></>;
}

Expected behavior

Should report destructuring error when using const { ...rest } = useCustomQueryHook()

TanStack Query version

React query v5.50.1, eslint-plugin-query v5.71.5

TypeScript version

5.8.2

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