eslint.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import js from '@eslint/js'
  2. import globals from 'globals'
  3. import reactHooks from 'eslint-plugin-react-hooks'
  4. import reactRefresh from 'eslint-plugin-react-refresh'
  5. import tseslint from 'typescript-eslint'
  6. import { defineConfig, globalIgnores } from 'eslint/config'
  7. export default defineConfig([
  8. globalIgnores(['dist']),
  9. {
  10. files: ['**/*.{ts,tsx}'],
  11. extends: [
  12. js.configs.recommended,
  13. tseslint.configs.recommended,
  14. reactHooks.configs.flat.recommended,
  15. reactRefresh.configs.vite,
  16. ],
  17. languageOptions: {
  18. ecmaVersion: 2020,
  19. globals: globals.browser,
  20. },
  21. rules: {
  22. // Keep core React Hooks rules
  23. 'react-hooks/rules-of-hooks': 'error',
  24. 'react-hooks/exhaustive-deps': 'warn',
  25. // Disable React Compiler rules (too strict for non-compiler codebases)
  26. 'react-hooks/static-components': 'off',
  27. 'react-hooks/set-state-in-effect': 'off',
  28. 'react-hooks/purity': 'off',
  29. 'react-hooks/immutability': 'off',
  30. 'react-hooks/preserve-manual-memoization': 'off',
  31. 'react-hooks/refs': 'off',
  32. },
  33. },
  34. // Relaxed rules for test files
  35. {
  36. files: ['**/__tests__/**/*.{ts,tsx}', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'],
  37. rules: {
  38. '@typescript-eslint/no-explicit-any': 'off',
  39. '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
  40. 'react-refresh/only-export-components': 'off',
  41. },
  42. },
  43. // Files that legitimately export non-components (contexts, hooks, utilities)
  44. {
  45. files: [
  46. '**/contexts/**/*.{ts,tsx}',
  47. '**/hooks/**/*.{ts,tsx}',
  48. '**/components/IconPicker.tsx',
  49. '**/components/Layout.tsx',
  50. '**/components/HMSErrorModal.tsx',
  51. ],
  52. rules: {
  53. 'react-refresh/only-export-components': 'off',
  54. },
  55. },
  56. ])