Query Docs
Guides & Concepts
- Important Defaults
- Queries
- Query Keys
- Query Functions
- Network Mode
- Parallel Queries
- Dependent Queries
- Background Fetching Indicators
- Window Focus Refetching
- Disabling/Pausing Queries
- Query Retries
- Paginated Queries
- Infinite Queries
- Initial Query Data
- Placeholder Query Data
- Prefetching
- Mutations
- Query Invalidation
- Invalidation from Mutations
- Updates from Mutation Responses
- Optimistic Updates
- Query Cancellation
- Scroll Restoration
- Filters
- SSR & Next.js
- Caching
- Default Query Fn
- Suspense
- Custom Logger
- Testing
- Does this replace [Redux, MobX, etc]?
- Migrating to React Query 3
- Migrating to React Query 4
ESLint
AI/LLM: This documentation page is available in plain markdown format at/query/v4/docs/eslint/eslint-plugin-query.md
ESLint
ESLint Plugin Query
TanStack Query comes with its own ESLint plugin. This plugin is used to enforce best practices and to help you avoid common mistakes.
Installation#
The plugin is a separate package that you need to install:
shell
npm i -D @tanstack/eslint-plugin-query@4or
shell
pnpm add -D @tanstack/eslint-plugin-query@4or
shell
yarn add -D @tanstack/eslint-plugin-query@4Usage#
Add @tanstack/eslint-plugin-query to the plugins section of your .eslintrc configuration file:
json
{
"plugins": ["@tanstack/query"]
}Then configure the rules you want to use under the rules section:
json
{
"rules": {
"@tanstack/query/exhaustive-deps": "error",
"@tanstack/query/no-deprecated-options": "error",
"@tanstack/query/prefer-query-object-syntax": "error",
"@tanstack/query/stable-query-client": "error"
}
}Recommended config#
You can also enable all the recommended rules for our plugin. Add plugin:@tanstack/eslint-plugin-query/recommended in extends:
json
{
"extends": ["plugin:@tanstack/eslint-plugin-query/recommended"]
}