// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
import storybook from 'eslint-plugin-storybook';

import js from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
   {
      ignores: ['build/**', 'node_modules/**', '.react-router/**', 'coverage/**'],
   },
   {
      files: ['**/*.{ts,tsx}'],
      extends: [
         js.configs.recommended,
         ...tseslint.configs.recommended,
         ...tseslint.configs.stylistic,
      ],
      languageOptions: {
         ecmaVersion: 'latest',
         sourceType: 'module',
         globals: {
            ...globals.browser,
            ...globals.node,
         },
         parserOptions: {
            ecmaFeatures: {
               jsx: true,
            },
         },
      },
      plugins: {
         'react-hooks': reactHooks,
      },
      rules: {
         ...reactHooks.configs.recommended.rules,
         'no-empty-pattern': 'off',
         '@typescript-eslint/no-unused-vars': [
            'warn',
            {
               argsIgnorePattern: '^_',
               varsIgnorePattern: '^_',
               caughtErrorsIgnorePattern: '^_',
            },
         ],
      },
   },
   prettierConfig,
   storybook.configs['flat/recommended'],
);
