Open History to see the last commit
1---
2id: eslint-plugin-query
3title: ESLint Plugin Query
4---
5β
6TanStack Query comes with its own ESLint plugin. This plugin is used to enforce best practices and to help you avoid common mistakes.
7β
8## Installation
9β
10The plugin is a separate package that you need to install:
11β
12```bash
13$ npm i -D @tanstack/eslint-plugin-query
14# or
15$ pnpm add -D @tanstack/eslint-plugin-query
16# or
17$ yarn add -D @tanstack/eslint-plugin-query
18```
19β
20## Usage
21β
22To enable all of the recommended rules for our plugin, add `plugin:@tanstack/eslint-plugin-query/recommended` in extends:
23β
24```json
25{
26 "extends": ["plugin:@tanstack/eslint-plugin-query/recommended"]
27}
28```
29β
30### Alternative config
31β
32Alternatively, add `@tanstack/eslint-plugin-query` to the plugins section of your `.eslintrc` configuration file:
33β
34```json
35{
36 "plugins": ["@tanstack/query"]
37}
38```
39β
40Then configure the rules you want to use under the rules section:
41β
42```json
43{
44 "rules": {
45 "@tanstack/query/exhaustive-deps": "error",
46 "@tanstack/query/no-rest-destructuring": "warn",
47 "@tanstack/query/stable-query-client": "error"
48 }
49}
50```