Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

eslint-plugin-query.md

49 lines1020 Bytes

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
26 "plugins": ["@tanstack/query"]
28```
29​
30Then configure the rules you want to use under the rules section:
31​
32```json
34 "rules": {
35 "@tanstack/query/exhaustive-deps": "error",
36 "@tanstack/query/stable-query-client": "error"
37 }
39```
40​
41### Recommended config
42​
43You can also enable all the recommended rules for our plugin. Add `plugin:@tanstack/eslint-plugin-query/recommended` in extends:
44​
45```json
47 "extends": ["plugin:@tanstack/eslint-plugin-query/recommended"]
49```