From ffd4549003740525c9a6652d11a88e02f9e06d53 Mon Sep 17 00:00:00 2001 From: wakamsha Date: Mon, 11 Mar 2024 14:39:59 +0900 Subject: [PATCH 1/2] feat: Implement the rule "react-hooks" --- rules/react-hooks.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 rules/react-hooks.js diff --git a/rules/react-hooks.js b/rules/react-hooks.js new file mode 100644 index 0000000..d538d01 --- /dev/null +++ b/rules/react-hooks.js @@ -0,0 +1,8 @@ +module.exports = { + plugins: ['react-hooks'], + + rules: { + 'react-hooks/exhaustive-deps': ['error'], + 'react-hooks/rules-of-hooks': ['error'], + }, +}; From c673a50f14e97cfe2735bd0d1dae8211b25636c3 Mon Sep 17 00:00:00 2001 From: wakamsha Date: Mon, 11 Mar 2024 14:45:16 +0900 Subject: [PATCH 2/2] add comments --- rules/react-hooks.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules/react-hooks.js b/rules/react-hooks.js index d538d01..33c6d2e 100644 --- a/rules/react-hooks.js +++ b/rules/react-hooks.js @@ -2,7 +2,12 @@ module.exports = { plugins: ['react-hooks'], rules: { + // Verify the list of the dependencies for Hooks like useEffect and similar. + // https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js 'react-hooks/exhaustive-deps': ['error'], + + // Enforce Rules of Hooks. + // https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js 'react-hooks/rules-of-hooks': ['error'], }, };