eslint.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. // src/lib/vendor holds third-party build output copied in verbatim. Linting
  9. // it produces findings we must not act on -- editing vendored code makes it
  10. // impossible to re-copy on the next upstream release.
  11. globalIgnores(['dist', 'coverage', 'src/lib/vendor']),
  12. {
  13. files: ['**/*.{ts,tsx}'],
  14. extends: [
  15. js.configs.recommended,
  16. tseslint.configs.recommended,
  17. reactHooks.configs.flat.recommended,
  18. reactRefresh.configs.vite,
  19. ],
  20. languageOptions: {
  21. ecmaVersion: 2020,
  22. globals: globals.browser,
  23. },
  24. rules: {
  25. // Keep core React Hooks rules
  26. 'react-hooks/rules-of-hooks': 'error',
  27. 'react-hooks/exhaustive-deps': 'warn',
  28. // Disable React Compiler rules (too strict for non-compiler codebases)
  29. 'react-hooks/static-components': 'off',
  30. 'react-hooks/set-state-in-effect': 'off',
  31. 'react-hooks/purity': 'off',
  32. 'react-hooks/immutability': 'off',
  33. 'react-hooks/preserve-manual-memoization': 'off',
  34. 'react-hooks/refs': 'off',
  35. },
  36. },
  37. // Relaxed rules for test files
  38. {
  39. files: ['**/__tests__/**/*.{ts,tsx}', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'],
  40. rules: {
  41. '@typescript-eslint/no-explicit-any': 'off',
  42. '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
  43. 'react-refresh/only-export-components': 'off',
  44. },
  45. },
  46. // Files that legitimately export non-components (contexts, hooks, utilities)
  47. {
  48. files: [
  49. '**/contexts/**/*.{ts,tsx}',
  50. '**/hooks/**/*.{ts,tsx}',
  51. '**/components/IconPicker.tsx',
  52. '**/components/Layout.tsx',
  53. '**/components/HMSErrorModal.tsx',
  54. ],
  55. rules: {
  56. 'react-refresh/only-export-components': 'off',
  57. },
  58. },
  59. ])