From 078fa7a849b84f10ecc57467accfecfdfec1e17f Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Wed, 23 Feb 2022 22:42:09 +0100 Subject: [PATCH] Remove lint plugin for react hooks --- .eslintrc.js | 24 +++++++++++++++++++++++- package.json | 1 - yarn.lock | 10 ---------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a719800..537dd85 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,29 @@ +/** + * @remarks + * Notes on plugins we _don't_ use: + * + * ## plugin:react-hooks + * We don't use the react hooks plugin because it disallows valid use-cases + * such as this: + * + * ```ts + * export default function useValToAtom(val: S): Atom { + * const atom = useMemo(() => { + * return new Atom(val) + * }, []) // <-- we don't _need_ to include `val` here, but the lint rule will require it + * + * useLayoutEffect(() => { + * atom.setState(val) + * }, [val]) // <-- we also know `atom` will never change, but the lint rule doesn't + * + * return atom + * ``` + */ + module.exports = { root: true, plugins: ['unused-imports', 'eslint-plugin-tsdoc'], - extends: ['plugin:react-hooks/recommended'], + extends: [], rules: { 'unused-imports/no-unused-imports': 'warn', 'tsdoc/syntax': 'warn', diff --git a/package.json b/package.json index 4a913ed..445d836 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "eslint": "^7.32.0", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.25.1", - "eslint-plugin-react-hooks": "^4.3.0", "eslint-plugin-tsdoc": "^0.2.14", "eslint-plugin-unused-imports": "^1.1.4", "husky": "^6.0.0", diff --git a/yarn.lock b/yarn.lock index cf9e68b..a035326 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9728,15 +9728,6 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-react-hooks@npm:^4.3.0": - version: 4.3.0 - resolution: "eslint-plugin-react-hooks@npm:4.3.0" - peerDependencies: - eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 - checksum: 0ba1566ba0780bbc75a5921f49188edf232db2085ab32c8d3889592f0db9d6fadc97fcf639775e0101dec6b5409ca3c803ec44213b90c8bacaf0bdf921871c2e - languageName: node - linkType: hard - "eslint-plugin-react@npm:^7.21.5": version: 7.24.0 resolution: "eslint-plugin-react@npm:7.24.0" @@ -20382,7 +20373,6 @@ fsevents@^1.2.7: eslint: ^7.32.0 eslint-plugin-jsx-a11y: ^6.4.1 eslint-plugin-react: ^7.25.1 - eslint-plugin-react-hooks: ^4.3.0 eslint-plugin-tsdoc: ^0.2.14 eslint-plugin-unused-imports: ^1.1.4 husky: ^6.0.0