The recommended way to configure for flat config in eslint-plugin-react-hooks@7.0.0 isn't correctly typed with TypeScript and enabled noUncheckedIndexedAccess flag:
import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';
export default defineConfig([
reactHooks.configs.flat.recommended,
]);
Either disabling noUncheckedIndexedAccess or non-null asserting the value with ! works.
Steps To Reproduce
- Clone
https://github.com/ulrichstark/eslint-plugin-react-hooks-type-repro
- Run
npm install
- Run
npx tsc
The current behavior
eslint.config.ts:4:30 - error TS2322: Type 'ReactHooksFlatConfig | undefined' is not assignable to type 'InfiniteArray<ConfigWithExtends>'.
Type 'undefined' is not assignable to type 'InfiniteArray<ConfigWithExtends>'.
4 export default defineConfig([reactHooks.configs.flat.recommended]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in eslint.config.ts:4
The expected behavior
No TypeScript error.
The recommended way to configure for flat config in eslint-plugin-react-hooks@7.0.0 isn't correctly typed with TypeScript and enabled
noUncheckedIndexedAccessflag:Either disabling
noUncheckedIndexedAccessor non-null asserting the value with!works.Steps To Reproduce
https://github.com/ulrichstark/eslint-plugin-react-hooks-type-repronpm installnpx tscThe current behavior
The expected behavior
No TypeScript error.