ESLint rules for React Query
npm install eslint-plugin-react-queryCommunity ESLint rules for React Query.
Install the plugin:
``bash`
npm install --save-dev eslint-plugin-react-query
Add react-query to plugins field in your .eslintrc configuration file:
`json`
{
"plugins": ["react-query"],
"rules": {
"react-query/rule-name": "error"
}
}
You can also use recommended rules with this plugin:
`json`
{
"extends": ["plugin:react-query/recommended"]
}
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 | ✅ | |
Check out CONTRIBUTING.md for information on how to contribute to the project.
Big thanks to Testing Library team for the code inspiration.