Fix all lint:js warnings and enforce zero-warning policy#340
Fix all lint:js warnings and enforce zero-warning policy#340
Conversation
- Add missing dependencies to useCallback and useEffect hooks - Convert currentUrl from let variable to useRef in script.js - Add dependency arrays to useCallback calls missing them entirely - Remove ref from useEffect dependency array in totp.js - Set --max-warnings=0 on lint:js to fail on warnings going forward Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to eliminate existing react-hooks/exhaustive-deps lint warnings in the Settings UI and enforce a zero-warning lint policy in CI going forward.
Changes:
- Updates multiple
useEffect/useCallbackdependency arrays to satisfyreact-hooks/exhaustive-deps. - Refactors URL handling in
settings/src/script.jsby replacing a reassignedlet currentUrlwith auseRef. - Updates
lint:jsto fail on any warnings via--max-warnings=0.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| settings/src/script.js | Switches currentUrl to useRef and adjusts navigation/popstate handling deps. |
| settings/src/components/webauthn/register-key.js | Adds missing dependencies to onRegister callback. |
| settings/src/components/webauthn/list-keys.js | Adds missing dependencies to delete callback. |
| settings/src/components/totp.js | Adds deps for setup-method click handlers and adjusts deps in setup form hooks. |
| settings/src/components/svn-password.js | Adds dependency array to password generation callback. |
| settings/src/components/screen-link.js | Adds missing deps for screen navigation click handler. |
| settings/src/components/revalidate-modal.js | Updates effect deps for message listener to avoid stale closures. |
| settings/src/components/numeric-control.js | Adds missing deps to callbacks using index/handlers. |
| settings/src/components/email-address.js | Adds missing deps to save/discard callbacks. |
| settings/src/components/backup-codes.js | Adds missing deps to setup effect and finished handler. |
| settings/src/components/auto-tabbing-input.js | Adds deps to input callbacks (change/paste). |
| settings/package.json | Enforces zero-warning lint policy via --max-warnings=0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
secretKey starts as an empty string and is populated async. If the user switches to manual setup before the API responds, match() returns null and .join() throws. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use refs for userRecord in revalidate-modal.js to avoid re-subscribing message listener on every render - Use replaceState with guard in script.js to prevent duplicate history entries - Use ref for userRecord in backup-codes.js to prevent re-firing generate-backup-codes API call Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The `{ ...userRecord }` spread created a new object identity every
render for no benefit, compounding the instability of useEntityRecord.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
react-hooks/exhaustive-depswarnings across 12 files--max-warnings=0to thelint:jsscript so warnings fail CI going forwardThe main changes:
useCallbackanduseEffectdependency arrayscurrentUrlfrom aletvariable touseRefinscript.js(was being reassigned inside callbacks)useCallbackcalls that were missing them entirelyinputsReffromuseEffectdependency array intotp.js(refs don't change identity)Test plan
npm run lint:jspasses with zero warnings and zero errorsnpm run test:unit -w settings— all JS tests pass🤖 Generated with Claude Code