chore(frontend): adopt the React Compiler lint rules from eslint-plugin-react-hooks v7 (#182) #540
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/182-react-compiler-lint"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #182. Second engineering lane of v4.4.0 (#535 phase 0): the rules go on before the rebuild writes new components.
Re-measured first. The July probe found 12 sites; against today's main the full preset finds 40 across 22 files (34
set-state-in-effect, 2purity, 1refs, 1immutability, 1preserve-manual-memoization, 1exhaustive-depswarning). Two facts about the rule shaped the fixes: it reports one site per effect, so every synchronous write in a flagged effect had to go; and it does not treatawaitas deferring, so anasynchelper called from an effect is flagged even when every write follows anawait.The fix, applied uniformly. About 24 of the 34 were one shape: a
loading/stale/ "unknown" flag an effect raised on its way past. Each now stores what the data in hand was fetched for and derives the flag during render (loading = loadedFor !== key). The rest:ElapsedTimerreads the clock once in a state initialiser instead of during render;GeneratorPanelsyncs its ref in an effect;SessionShelf's pointer listeners come off through oneAbortControllerper gesture instead of a handler removing itself by a not-yet-initialised name;WikiArticle's memo gets a dependency the compiler can verify. Noeslint-disableanywhere; two pre-existing ones became unnecessary and were removed. No test file was modified.One user-visible change, deliberate.
WikiDraftReview's stat-block autosave indicator set "Saved" and then wiped it on the next render, so the autosave looked like it had done nothing. Deriving the indicator makes "Saved" stick until the next edit. It has its own**Fixed**entry. The body autosave indicator in the same file has the same defect, was not flagged (the rule bails on it), and needs a real refactor of the autosave path: filed as #539 for the wiki lane of the rebuild.Config.
recommended-latestrather thanrecommended: in v7 both are flat configs of the same shape and the former is a strict superset (addsvoid-use-memo); the source is clean under both.exhaustive-depsrestated atwarn. The comment no longer claims the preset is excluded and says the compiler-on-the-build question is a separate decision this change does not make.Verification (Docker, node 22): eslint 0 errors, 0 warnings; 64 files, 799 tests pass (unchanged); build ok; the 23 touched-file test files run twice more with no flakes. A byte scan of every changed file confirmed no stray NUL bytes (an editor artefact the lane caught and fixed).
Small behavioural improvements beyond the headline, each noted in the code: an aborted read no longer marks a page "loaded" (
JoinCampaign,WikiArticle), a stale search error no longer shows while a newer term is in flight (WikiSearch), the proposals badge no longer blanks during a re-read (CampaignStoryline), and a retry keeps the old error on screen until the retry lands rather than flickering (SessionDetail).🤖 Generated with Claude Code
db7dee1f1790a36b2e4590a36b2e45ebc3154c5f