Skip to content

Commit 7fd15ac

Browse files
committed
[lint] improve type safety on flat config
1 parent 4b3e662 commit 7fd15ac

File tree

1 file changed

+11
-12
lines changed
  • packages/eslint-plugin-react-hooks/src

1 file changed

+11
-12
lines changed

packages/eslint-plugin-react-hooks/src/index.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ const recommendedLatestRuleConfigs: Linter.RulesRecord = {
5757

5858
const plugins = ['react-hooks'];
5959

60-
type ReactHooksFlatConfig = {
61-
plugins: {react: any};
62-
rules: Linter.RulesRecord;
63-
};
64-
6560
const configs = {
6661
recommended: {
6762
plugins,
@@ -71,7 +66,7 @@ const configs = {
7166
plugins,
7267
rules: recommendedLatestRuleConfigs,
7368
},
74-
flat: {} as Record<string, ReactHooksFlatConfig>,
69+
flat: {} as typeof flatConfigs,
7570
};
7671

7772
const plugin = {
@@ -83,15 +78,19 @@ const plugin = {
8378
configs,
8479
};
8580

86-
Object.assign(configs.flat, {
81+
const pluginUnknown: unknown = plugin;
82+
83+
const flatConfigs = {
8784
'recommended-latest': {
88-
plugins: {'react-hooks': plugin},
89-
rules: configs['recommended-latest'].rules,
85+
plugins: {'react-hooks': pluginUnknown},
86+
rules: recommendedLatestRuleConfigs,
9087
},
9188
recommended: {
92-
plugins: {'react-hooks': plugin},
93-
rules: configs.recommended.rules,
89+
plugins: {'react-hooks': pluginUnknown},
90+
rules: recommendedRuleConfigs,
9491
},
95-
});
92+
};
93+
94+
configs.flat = flatConfigs;
9695

9796
export default plugin;

0 commit comments

Comments
 (0)