Skip to content
This repository was archived by the owner on Jun 24, 2023. It is now read-only.

KubaJastrz/eslint-plugin-react-query

Repository files navigation

⚠️ PROJECT ARCHIVED ⚠️

The development has been moved to @tanstack/eslint-plugin-query.

New codebase: https://github.com/TanStack/query/blob/main/packages/eslint-plugin-query

NPM: https://www.npmjs.com/package/@tanstack/eslint-plugin-query




ESLint Plugin React Query

Community ESLint rules for React Query.

License MIT NPM Version NPM Downloads

Quick Start

Installation

Install the plugin:

npm install --save-dev eslint-plugin-react-query

Usage

Add react-query to plugins field in your .eslintrc configuration file:

{
	"plugins": ["react-query"],
	"rules": {
		"react-query/rule-name": "error"
	}
}

You can also use recommended rules with this plugin:

{
	"extends": ["plugin:react-query/recommended"]
}

Supported Rules

Key: ✅ = recommended, 🔧 = fixable

Name Description 🔧
mutation-key Enforce mutationKey to be present in useMutation call
prefer-query-object-syntax Prefer object syntax for useQuery 🔧
query-key Enforce queryKey to be present in useQuery object syntax

Contributing

Check out CONTRIBUTING.md for information on how to contribute to the project.

Attributions

Big thanks to Testing Library team for the code inspiration.