diff --git a/eslint.config.mjs b/eslint.config.mjs index fc4474642d..f7c68f40b2 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -14,6 +14,7 @@ import lingui from 'eslint-plugin-lingui' import reactCompiler from 'eslint-plugin-react-compiler' import bskyInternal from 'eslint-plugin-bsky-internal' import globals from 'globals' +import pluginQuery from '@tanstack/eslint-plugin-query' import tsParser from '@typescript-eslint/parser' export default defineConfig( @@ -65,6 +66,9 @@ export default defineConfig( lingui, 'react-compiler': reactCompiler, 'bsky-internal': bskyInternal, + // @ts-expect-error - not sure why + '@tanstack/query': pluginQuery, + }, languageOptions: { ecmaVersion: 'latest', @@ -255,6 +259,25 @@ export default defineConfig( 'no-sparse-arrays': 'off', 'no-fallthrough': 'off', 'no-control-regex': 'off', + + /** + * React Query + */ + '@tanstack/query/no-rest-destructuring': 'error', + '@tanstack/query/stable-query-client': 'error', + '@tanstack/query/no-unstable-deps': 'error', + '@tanstack/query/infinite-query-property-order': 'error', + '@tanstack/query/no-void-query-fn': 'error', + '@tanstack/query/mutation-property-order': 'error', + '@tanstack/query/prefer-query-options': 'off', + '@tanstack/query/exhaustive-deps': [ + 'off', // consider changing to warn, but very noisy + { + 'allowlist': { + 'variables': ['agent', 'ax', 'queryClient', 'moderationOpts'], + } + } + ], }, }, diff --git a/package.json b/package.json index 36f7ec6152..a90c867e85 100644 --- a/package.json +++ b/package.json @@ -248,6 +248,7 @@ "@react-native/babel-preset": "0.81.5", "@react-native/typescript-config": "^0.81.5", "@sentry/webpack-plugin": "^3.2.2", + "@tanstack/eslint-plugin-query": "^5.96.1", "@testing-library/react-native": "^13.2.0", "@types/jest": "29.5.14", "@types/lodash.chunk": "^4.2.7", diff --git a/yarn.lock b/yarn.lock index 4a5d8dc52e..147693ca03 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5102,6 +5102,13 @@ dependencies: "@sinonjs/commons" "^3.0.0" +"@tanstack/eslint-plugin-query@^5.96.1": + version "5.96.1" + resolved "https://registry.yarnpkg.com/@tanstack/eslint-plugin-query/-/eslint-plugin-query-5.96.1.tgz#b8028ea06b3444c631c512fc3fae992288d9998b" + integrity sha512-BDJU+Q+zESjarSSFmbzpCBh+1wDxwW+DyQlvwIukF24MHYOoRPH4ouJRTlDdbp3BnIkeylZaHHSgIvxY9lgI/g== + dependencies: + "@typescript-eslint/utils" "^8.48.0" + "@tanstack/query-async-storage-persister@^5.95.2": version "5.95.2" resolved "https://registry.yarnpkg.com/@tanstack/query-async-storage-persister/-/query-async-storage-persister-5.95.2.tgz#0c7ed1c8013823e2d5abbb8d55bc0e9305abf7e0" @@ -5691,7 +5698,7 @@ tinyglobby "^0.2.15" ts-api-utils "^2.5.0" -"@typescript-eslint/utils@8.58.0", "@typescript-eslint/utils@^8.57.2": +"@typescript-eslint/utils@8.58.0", "@typescript-eslint/utils@^8.48.0", "@typescript-eslint/utils@^8.57.2": version "8.58.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.58.0.tgz#21a74a7963b0d288b719a4121c7dd555adaab3c3" integrity sha512-RfeSqcFeHMHlAWzt4TBjWOAtoW9lnsAGiP3GbaX9uVgTYYrMbVnGONEfUCiSss+xMHFl+eHZiipmA8WkQ7FuNA==