Commit 6fb5fcb
chore(eslint): wire up flat config + fix one real ref-in-render bug
Pre-this-commit, ``npm run lint`` had been failing silently with
"ESLint couldn't find an eslint.config.(js|mjs|cjs) file" — the
project shipped eslint v9 + eslint-plugin-react-hooks +
eslint-plugin-react-refresh as devDependencies but no config file,
so lint had been a no-op for an unknown amount of time.
frontend/eslint.config.js (new)
-------------------------------
Flat-config wiring for ESLint 9. Pulls in:
- js.configs.recommended
- eslint-plugin-react-hooks v7 recommended ruleset (which now
includes exhaustive-deps + the new React-Compiler advisory rules)
- eslint-plugin-react-refresh's only-export-components rule
- vitest globals scoped to ``tests/**``
Tunings applied (all explained in inline comments):
- ``no-unused-vars`` ignores PascalCase identifiers because the
bare rule doesn't track JSX usage (`<Foo />`) and would
false-positive every component import. The dedicated
``react/jsx-uses-vars`` rule would do this properly but pulling
in eslint-plugin-react for one rule is overkill; the regex
covers our patterns.
- ``no-empty`` allows empty catch blocks — we have a few that
intentionally swallow malformed-localStorage parses.
- The four new react-hooks v7 React-Compiler advisory rules
(set-state-in-effect, purity, refs, preserve-manual-memoization)
demoted from error to warn. They flag patterns the compiler
can't optimize, not patterns that are currently buggy. Fix
when touching the surrounding code, not as a sweep.
Real bug fixed
--------------
hooks/useMotionAlerts.jsx — was assigning ``camerasRef.current = cameras``
*during render*, which violates React's purity rules and breaks under
React Compiler / Strict Mode double-renders. Moved the assignment into
``useEffect(() => { camerasRef.current = cameras }, [cameras])`` so
it runs after commit, which is what the SSE callback consumers expected
in the first place. No observable behaviour change for users (the
callback still always sees the post-commit cameras map).
Verification
------------
npm run lint — 0 errors, 26 warnings (was 163 problems / unable to run)
npm test — 37/37 passing
npm run build — clean (436ms)
The 26 remaining warnings are all advisory (exhaustive-deps where
adding the missing dep would cause unnecessary re-renders, the four
React-Compiler rules listed above, and react-refresh/only-export-components
on the four hook+context files where the standard fix is a structural
file split). Each is documented in the lint output with a clear path
to resolution; we'll burn them down opportunistically.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent eefbddf commit 6fb5fcb
2 files changed
Lines changed: 124 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
0 commit comments