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β
22Add `@tanstack/eslint-plugin-query` to the plugins section of your `.eslintrc` configuration file:
23β
24```json
25{
26 "plugins": ["@tanstack/query"]
27}
28```
29β
30Then configure the rules you want to use under the rules section:
31β
32```json
33{
34 "rules": {
35 "@tanstack/query/exhaustive-deps": "error",
36 }
37}
38```
39β
40### Recommended config
41β
42You can also enable all the recommended rules for our plugin. Add `plugin:@tanstack/eslint-plugin-query/recommended` in extends:
43β
44```json
45{
46 "extends": ["plugin:@tanstack/eslint-plugin-query/recommended"]
47}
48```