client: clear the four lint warnings and make warnings fail CI #5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
npm run lintreports four warnings and no errors. CI (#2) passes on warnings, so new ones can creep in unnoticed. Clear them, then make warnings fail.The warnings and the plan
react(set-state-in-effect)—components/ImagePicker.tsx:14,pages/Profile.tsx:29Both components make object URLs for image previews in an effect and put them in state, revoking them on cleanup. That is the right pattern here: an object URL is an external resource whose lifetime must follow the component, which is exactly what effects are for. Moving the creation into
useMemowould break under StrictMode, whose double effect run revokes URLs that a cached memo will not recreate.Plan: extract the pattern into one hook,
useObjectUrls(blobs)(insrc/hooks/), used by both components. Allow the rule inside that hook only, with a comment saying why. The exception lives in one documented place instead of two.react(only-export-components)—pages/Diary.tsx:56postWithImages(upload the picked images, then post the entry) is exported from the page component's file and imported bypages/Notes.tsx. That breaks fast refresh for the file, and it is data-layer code anyway.Plan: move it to
src/matrix/diary.ts, next touploadImageandpostEntry, which it calls; update both imports.eslint(no-unused-vars)—matrix/koto.test.ts:3beforeAllis imported but unused. Plan: remove it.Make warnings fail
Change the
lintscript tooxlint --deny-warnings, so a localnpm run lintand CI agree.Verification
npm run lintreports nothing and exits 0; adding a warning makes it exit non-zero