From fd0935cfcd660901d612b9b146bc136d40d2f02f Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Fri, 6 Dec 2024 03:49:32 +0000 Subject: [PATCH] feat(linter): change `react/rules-of-hooks` category to `pedantic` (#7691) Although this rule is recommended by the React team, it does not report incorrect or wrong code for the `correctness` category. When turned on by default, I find false positive warnings confusing, I cannot tell whether my code is wrong or the rule implementation is wrong - see examples in the affine repo. ``` x eslint-plugin-react-hooks(rules-of-hooks): React Hook "use" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function. ,-[packages/backend/server/src/config/affine.self.ts:80:1] 79 | /* Captcha Plugin Default Config */ 80 | ,-> AFFiNE.use('captcha', { 81 | | turnstile: {}, 82 | | challenge: { 83 | | bits: 20, 84 | | }, 85 | `-> }); 86 | `---- ``` --- crates/oxc_linter/src/rules/react/rules_of_hooks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/react/rules_of_hooks.rs b/crates/oxc_linter/src/rules/react/rules_of_hooks.rs index 6a719a89d..e6eb833f6 100644 --- a/crates/oxc_linter/src/rules/react/rules_of_hooks.rs +++ b/crates/oxc_linter/src/rules/react/rules_of_hooks.rs @@ -104,7 +104,7 @@ declare_oxc_lint!( /// /// RulesOfHooks, - correctness + pedantic ); impl Rule for RulesOfHooks {