# useTanstackQueryExhaustiveDependencies

Rule `biome/useTanstackQueryExhaustiveDependencies`. Require query keys to include every value that the query function uses.

- Source: biome
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 30.6M weekly downloads of presets that enable it
- Trend: +109.3% last quarter
- Rank: #614 by reach, #249 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Biome | `nursery/useTanstackQueryExhaustiveDependencies` | yes | unsafe | group nursery, since 2.6.9 | [docs](https://biomejs.dev/linter/rules/use-tanstack-query-exhaustive-dependencies/) |

## Code examples

### Incorrect: the rule reports this

```js
import { useQuery } from "@tanstack/react-query";

function Todo({ todoId }) {
    const query = useQuery({
        queryKey: ["todo"],
        queryFn: () => fetchTodo(todoId),
    });
}
```

```js
const todoQueries = {
    detail: (id) => ({ queryKey: ["todo"], queryFn: () => fetchTodo(id) }),
};
```

### Correct: the rule accepts this

```js
import { useQuery } from "@tanstack/react-query";

function Todo({ todoId }) {
    const todos = useTodos();
    const query = useQuery({
        queryKey: ["todo", todoId],
        queryFn: () => todos.getTodo(todoId),
    });
}

const todoQueries = {
    detail: (id) => ({ queryKey: ["todo", id], queryFn: () => fetchTodo(id) }),
};
```

Examples from the Biome documentation.

## Enable it

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useTanstackQueryExhaustiveDependencies": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |

## Related rules

- [biome/useTailwindVariablesShorthand](https://lintradar.dev/rules/biome/useTailwindVariablesShorthand.md): Enforce the shorthand syntax for CSS variables in Tailwind CSS classes.
- [biome/useTanstackQueryInfiniteQueryPropertyOrder](https://lintradar.dev/rules/biome/useTanstackQueryInfiniteQueryPropertyOrder.md): Enforce a consistent property order in the options of TanStack Query infinite query functions.
- [biome/useSvelteShorthandDirective](https://lintradar.dev/rules/biome/useSvelteShorthandDirective.md): Enforce the shorthand syntax for Svelte `bind:`, `class:`, and `style:` directives.
- [biome/useTanstackQueryMutationPropertyOrder](https://lintradar.dev/rules/biome/useTanstackQueryMutationPropertyOrder.md): Enforce that `onMutate` comes before `onError` and `onSettled` in the options of TanStack Query mutations.
- [biome/useSvelteRequireEachKey](https://lintradar.dev/rules/biome/useSvelteRequireEachKey.md): Require keyed `{#each}` blocks in Svelte templates.
- [biome/useTanstackQueryQueryOptions](https://lintradar.dev/rules/biome/useTanstackQueryQueryOptions.md): Require TanStack Query options to be created with `queryOptions()`.

---

Web page: https://lintradar.dev/rules/biome/useTanstackQueryExhaustiveDependencies. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
