import js from '@eslint/js' import globals from 'globals' import reactHooks from 'eslint-plugin-react-hooks' import reactRefresh from 'eslint-plugin-react-refresh' import tseslint from 'typescript-eslint' import eslintConfigPrettier from 'eslint-config-prettier' import eslintPluginPrettier from 'eslint-plugin-prettier' import { defineConfig, globalIgnores } from 'eslint/config' export default defineConfig([ globalIgnores(['dist', 'node_modules', 'coverage', 'build']), { files: ['**/*.{ts,tsx}'], extends: [ js.configs.recommended, tseslint.configs.recommended, reactHooks.configs.flat.recommended, reactRefresh.configs.vite, eslintConfigPrettier, ], plugins: { prettier: eslintPluginPrettier, }, languageOptions: { ecmaVersion: 2020, globals: globals.browser, }, rules: { // Prettier integration - show formatting issues as ESLint errors 'prettier/prettier': 'error', // TypeScript specific rules '@typescript-eslint/no-unused-vars': [ 'warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', }, ], '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', // Allow empty interfaces that extend other interfaces (common pattern for component props) '@typescript-eslint/no-empty-object-type': 'off', // React specific rules 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'warn', // Allow setState in effects for initialization patterns (common in React for loading from localStorage) 'react-hooks/set-state-in-effect': 'off', 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], // General rules 'no-console': ['warn', { allow: ['warn', 'error'] }], 'prefer-const': 'error', 'no-var': 'error', }, }, // Configuration for JavaScript files (like config files) { files: ['**/*.{js,mjs,cjs}'], extends: [js.configs.recommended, eslintConfigPrettier], plugins: { prettier: eslintPluginPrettier, }, languageOptions: { ecmaVersion: 2020, globals: { ...globals.node, }, }, rules: { 'prettier/prettier': 'error', }, }, ])