From 4b57d36bb4f94a9127cbf8b3b3d8e687f6a25134 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 6 Feb 2019 10:36:13 +0100 Subject: [PATCH 1/2] feat: add recommended config eslint rule --- packages/eslint-plugin-react-hooks/README.md | 11 +++++++++++ packages/eslint-plugin-react-hooks/src/index.js | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/eslint-plugin-react-hooks/README.md b/packages/eslint-plugin-react-hooks/README.md index 2fc149a7e35..0f7d86a826f 100644 --- a/packages/eslint-plugin-react-hooks/README.md +++ b/packages/eslint-plugin-react-hooks/README.md @@ -34,6 +34,17 @@ Then add it to your ESLint configuration: } ``` +Or use the recommended config: + +```js +{ + "extends": [ + // ... + "plugin:react-hooks/recommended" + ] +} +``` + ## Valid and Invalid Examples Please refer to the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html) documentation and the [Hooks FAQ](https://reactjs.org/docs/hooks-faq.html#what-exactly-do-the-lint-rules-enforce) to learn more about this rule. diff --git a/packages/eslint-plugin-react-hooks/src/index.js b/packages/eslint-plugin-react-hooks/src/index.js index 606a6dff4e2..4458f5dbd9b 100644 --- a/packages/eslint-plugin-react-hooks/src/index.js +++ b/packages/eslint-plugin-react-hooks/src/index.js @@ -10,6 +10,15 @@ import RuleOfHooks from './RulesOfHooks'; import ExhaustiveDeps from './ExhaustiveDeps'; +export const configs = { + recommended: { + plugins: ['react-hooks'], + rules: { + 'react-hooks/rules-of-hooks': 'error', + }, + }, +}; + export const rules = { 'rules-of-hooks': RuleOfHooks, 'exhaustive-deps': ExhaustiveDeps, From 65b466da188a24a23d8bc6313c113abcb57ab238 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 8 Sep 2019 19:55:19 +0200 Subject: [PATCH 2/2] add exhaustive-deps to recommended as well --- packages/eslint-plugin-react-hooks/src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-plugin-react-hooks/src/index.js b/packages/eslint-plugin-react-hooks/src/index.js index 4458f5dbd9b..dca7b5c559e 100644 --- a/packages/eslint-plugin-react-hooks/src/index.js +++ b/packages/eslint-plugin-react-hooks/src/index.js @@ -15,6 +15,7 @@ export const configs = { plugins: ['react-hooks'], rules: { 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', }, }, };