import type { Linter } from 'eslint';
import reactPlugin from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';

const reactFlat = reactPlugin.configs.flat as Record<string, Linter.Config>;

export const reactConfig = defineConfig(
  {
    files: ['**/*.ts', '**/*.tsx'],
    ...reactFlat.recommended,
    ...reactFlat['jsx-runtime'],
    languageOptions: {
      ...reactFlat.recommended?.languageOptions,
      ...reactFlat['jsx-runtime']?.languageOptions,
      globals: {
        React: 'writable',
      },
    },
  },
  reactHooks.configs.flat['recommended-latest']!,
);
