eslint.config.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import js from '@eslint/js';
  2. import tseslint from 'typescript-eslint';
  3. import reactHooks from 'eslint-plugin-react-hooks';
  4. import globals from 'globals';
  5. export default [
  6. { ignores: ['node_modules/**', '../web/dist/**'] },
  7. js.configs.recommended,
  8. {
  9. files: ['**/*.js'],
  10. languageOptions: {
  11. ecmaVersion: 2022,
  12. sourceType: 'module',
  13. globals: {
  14. ...globals.browser,
  15. ...globals.node,
  16. },
  17. },
  18. rules: {
  19. 'no-unused-vars': ['warn', {
  20. argsIgnorePattern: '^_',
  21. varsIgnorePattern: '^_',
  22. caughtErrorsIgnorePattern: '^_',
  23. }],
  24. 'no-empty': ['error', { allowEmptyCatch: true }],
  25. 'no-case-declarations': 'off',
  26. },
  27. },
  28. ...tseslint.configs.recommended.map((config) => ({
  29. ...config,
  30. files: ['**/*.{ts,tsx}'],
  31. })),
  32. {
  33. files: ['**/*.{ts,tsx}'],
  34. plugins: {
  35. 'react-hooks': reactHooks,
  36. },
  37. languageOptions: {
  38. ecmaVersion: 2022,
  39. sourceType: 'module',
  40. globals: {
  41. ...globals.browser,
  42. },
  43. },
  44. rules: {
  45. ...reactHooks.configs.recommended.rules,
  46. '@typescript-eslint/no-unused-vars': ['warn', {
  47. argsIgnorePattern: '^_',
  48. varsIgnorePattern: '^_',
  49. caughtErrorsIgnorePattern: '^_',
  50. }],
  51. 'no-empty': ['error', { allowEmptyCatch: true }],
  52. // react-hooks v7 introduces several new rules driven by the React
  53. // Compiler. The migration uses several legitimate patterns those
  54. // rules flag (initial-fetch in useEffect, dirty-check derived
  55. // state, `Date.now()` inside derive helpers, inline arrow event
  56. // handlers, in-place mutation of imported Outbound class
  57. // instances in the OutboundFormModal). We're not running the
  58. // compiler, so the memoization-preservation warnings have no
  59. // effect on runtime — turning them off until the codebase
  60. // stabilises.
  61. 'react-hooks/set-state-in-effect': 'off',
  62. 'react-hooks/purity': 'off',
  63. 'react-hooks/react-compiler': 'off',
  64. 'react-hooks/preserve-manual-memoization': 'off',
  65. 'react-hooks/immutability': 'off',
  66. 'react-hooks/refs': 'off',
  67. },
  68. },
  69. ];