From 4ac176773967a6374fa5e3d084855d3c8bd36ff1 Mon Sep 17 00:00:00 2001 From: Hikari Hayashi Date: Thu, 6 Jun 2024 00:37:25 +0800 Subject: [PATCH] [eslint-plugin-react-hooks] Add flat/recommended config Addresses #28313 --- .../eslint-plugin-react-hooks/src/index.js | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/eslint-plugin-react-hooks/src/index.js b/packages/eslint-plugin-react-hooks/src/index.js index d8ff02e7b144f..628db417c87d7 100644 --- a/packages/eslint-plugin-react-hooks/src/index.js +++ b/packages/eslint-plugin-react-hooks/src/index.js @@ -10,6 +10,11 @@ import RulesOfHooks from './RulesOfHooks'; import ExhaustiveDeps from './ExhaustiveDeps'; +export const rules = { + 'rules-of-hooks': RulesOfHooks, + 'exhaustive-deps': ExhaustiveDeps, +}; + export const configs = { recommended: { plugins: ['react-hooks'], @@ -18,9 +23,15 @@ export const configs = { 'react-hooks/exhaustive-deps': 'warn', }, }, -}; - -export const rules = { - 'rules-of-hooks': RulesOfHooks, - 'exhaustive-deps': ExhaustiveDeps, + 'flat/recommended': { + plugins: { + 'react-hooks': { + rules, + }, + }, + rules: { + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', + }, + }, };