Skip to content

Fix use-before-define, unpin eslint-plugin-react-hooks#144

Merged
keysersoft merged 1 commit into
mainfrom
keysersoft/eslint-react-hooks
May 10, 2026
Merged

Fix use-before-define, unpin eslint-plugin-react-hooks#144
keysersoft merged 1 commit into
mainfrom
keysersoft/eslint-react-hooks

Conversation

@keysersoft
Copy link
Copy Markdown
Contributor

Summary

Closes the technical debt left by PR #142 (the temporary eslint-plugin-react-hooks: 7.0.1 pin in root overrides).

What changed

  • packages/frontend/src/app/connectors/store/page.tsx: moved `handleImportClick` and `doImport` declarations above the `useEffect` that references `handleImportClick`.
  • packages/frontend/src/app/settings/license/page.tsx: moved `loadStatus` declaration above the `useEffect` that references it.
  • package.json: removed the `eslint-plugin-react-hooks: 7.0.1` override. The plugin now follows upstream (resolved to 7.1.x via eslint-config-next).

Why

`eslint-plugin-react-hooks` 7.1.x added a `react-hooks/use-before-define` rule. Both patterns were temporally safe at runtime (effects run after the function exists in scope), but the rule is correct that the order is hostile to readers and prevents React Compiler from analyzing the dependency graph cleanly.

Test plan

  • `npm run lint` in `packages/frontend` → 24 warnings, 0 errors (matches main's pre-bump baseline).
  • `npx tsc --noEmit -p tsconfig.json` in `packages/backend` → exit 0.
  • `npm test` in `packages/backend` → 594 passed, 3 skipped.
  • Manual smoke: hit `/connectors/store?install=hrworks` and verify auto-import still triggers correctly (functional behaviour of moved code is unchanged).

eslint-plugin-react-hooks 7.1.x adds a 'use-before-define' rule that
flagged two pre-existing patterns:
 - connectors/store/page.tsx: useEffect referenced handleImportClick
   before the function was declared.
 - settings/license/page.tsx: useEffect referenced loadStatus before
   the function was declared.

Both cases were temporally safe at runtime (the useEffect only runs
during render, by which point the function exists), but the rule is
correct that the order is hostile to readers and to React Compiler's
analysis. Moving the function declarations above the useEffects
satisfies the rule.

Removes the temporary 7.0.1 pin from the root overrides — the rxjs
override is enough to keep the workspace deduped, and react-hooks is
now free to follow upstream.
@keysersoft keysersoft force-pushed the keysersoft/eslint-react-hooks branch from f8beb27 to 8929276 Compare May 10, 2026 10:50
@keysersoft keysersoft merged commit c3de9e5 into main May 10, 2026
10 checks passed
@keysersoft keysersoft deleted the keysersoft/eslint-react-hooks branch May 10, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant