eslint.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. // Las reglas del React Compiler que react-hooks v7 activa en `recommended`
  23. // (purity, set-state-in-effect, refs, static-components, use-memo, immutability…)
  24. // NO aplican: este proyecto no compila con el React Compiler y el código
  25. // legacy usa los patrones clásicos (animaciones con setState en effect,
  26. // Math.random en render para decoración, refs-espejo de estado).
  27. // Refactorizarlas para silenciarlas sería riesgo de regresión sin ganancia.
  28. // REMOVE IF: se adopta el React Compiler. Ver
  29. // https://react.dev/learn/react-compiler/rules
  30. 'react-hooks/purity': 'off',
  31. 'react-hooks/set-state-in-effect': 'off',
  32. 'react-hooks/set-state-in-render': 'off',
  33. 'react-hooks/refs': 'off',
  34. 'react-hooks/static-components': 'off',
  35. 'react-hooks/preserve-manual-memoization': 'off',
  36. 'react-hooks/use-memo': 'off',
  37. 'react-hooks/immutability': 'off',
  38. 'react-hooks/globals': 'off',
  39. 'react-hooks/error-boundaries': 'off',
  40. 'react-hooks/config': 'off',
  41. 'react-hooks/gating': 'off',
  42. 'react-hooks/unsupported-syntax': 'off',
  43. 'react-hooks/incompatible-library': 'off',
  44. // Fast Refresh (regla de DX, no de corrección): los ficheros de shadcn/ui
  45. // y los contextos exportan variantes cva / hooks junto al componente,
  46. // patrón estándar que la regla no distingue.
  47. 'react-refresh/only-export-components': 'off',
  48. },
  49. },
  50. ])