From 05f384c0277e325bb716e6f852c4c48e7db83014 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Wed, 6 Sep 2023 12:26:46 -0400 Subject: [PATCH] eslint - add react-query checks Looking at [1], add eslint rules for react-query. The rules are currently set to `error` in order to highlight what "best practices" will be enforced with this change. [1] - https://tanstack.com/query/latest/docs/react/eslint/eslint-plugin-query Signed-off-by: Scott J Dickerson --- .eslintrc.cjs | 4 ++++ package-lock.json | 14 ++++++++++++++ package.json | 1 + 3 files changed, 19 insertions(+) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 99de9230a2..875eac7a3a 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -33,6 +33,7 @@ module.exports = { "@typescript-eslint", "react", "react-hooks", + "@tanstack/query", ], // NOTE: Tweak the rules as needed when bulk fixes get merged @@ -55,6 +56,9 @@ module.exports = { // Allow the "cy-data" property for tackle-ui-test (but should really be "data-cy" w/o this rule) "react/no-unknown-property": ["error", { ignore: ["cy-data"] }], + + "@tanstack/query/exhaustive-deps": "error", + "@tanstack/query/prefer-query-object-syntax": "error", }, settings: { diff --git a/package-lock.json b/package-lock.json index 531622594a..a9887f0efe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-run": "^3.0.1", "@rollup/plugin-typescript": "^11.1.2", + "@tanstack/eslint-plugin-query": "^4.34.1", "@types/jest": "^29.5.4", "@types/node": "^18.14.2", "@typescript-eslint/eslint-plugin": "^6.4.0", @@ -2069,6 +2070,19 @@ "@sinonjs/commons": "^3.0.0" } }, + "node_modules/@tanstack/eslint-plugin-query": { + "version": "4.34.1", + "resolved": "https://registry.npmjs.org/@tanstack/eslint-plugin-query/-/eslint-plugin-query-4.34.1.tgz", + "integrity": "sha512-RflOwyXamuHhuMX5RL6wtKiVw9Hi5Hhiv9gW2/ICVc4omflB+GflrxwvQ+EWRKrSRv3C0YcR0UzRxuiZ4mLq7Q==", + "dev": true, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "node_modules/@tanstack/match-sorter-utils": { "version": "8.8.4", "resolved": "https://registry.npmjs.org/@tanstack/match-sorter-utils/-/match-sorter-utils-8.8.4.tgz", diff --git a/package.json b/package.json index d31cefbc8c..574a135ae3 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-run": "^3.0.1", "@rollup/plugin-typescript": "^11.1.2", + "@tanstack/eslint-plugin-query": "^4.34.1", "@types/jest": "^29.5.4", "@types/node": "^18.14.2", "@typescript-eslint/eslint-plugin": "^6.4.0",