chore(lint): clear the four lint warnings and fail on warnings #6

Merged
genji1024 merged 3 commits from fix/lint-warnings into main 2026-10-12 03:48:49 +09:00
Collaborator

Closes #5

Changes

  • hooks/useObjectUrl.ts (new): makes an object URL for a blob and revokes it when the blob changes or the component unmounts. This is the one place allowed to set state in an effect, with a comment saying why: an object URL is an external resource that must live and die with the component.
    • components/ImagePicker.tsx: each preview is a small component using the hook. Adding or removing one image no longer recreates every preview URL.
    • pages/Profile.tsx: the new-picture preview uses the hook.
    • Deviation from the plan in #5: the hook takes one blob (useObjectUrl), not a list (useObjectUrls). A list would change identity on every render and need extra care to avoid re-running the effect.
  • postWithImages moved from pages/Diary.tsx to matrix/diary.ts, next to uploadImage and postEntry. Diary and Notes import it from there, and page files export only components again.
  • matrix/koto.test.ts: removed the unused beforeAll import.
  • package.json: lint is now oxlint --deny-warnings, so warnings fail locally and in CI.

Verification

  • lint (no output), typecheck, unit tests and build all pass locally.
  • Adding an unused import makes npm run lint exit 1; removing it brings it back to 0.
  • Not yet checked in a browser. After merging, on the demo:
    • picking images in the diary and notes shows previews; removing one updates the grid
    • a post with images still goes through
    • the new profile picture preview shows, and clears after saving
Closes #5 ## Changes - **`hooks/useObjectUrl.ts` (new)**: makes an object URL for a blob and revokes it when the blob changes or the component unmounts. This is the one place allowed to set state in an effect, with a comment saying why: an object URL is an external resource that must live and die with the component. - **`components/ImagePicker.tsx`**: each preview is a small component using the hook. Adding or removing one image no longer recreates every preview URL. - **`pages/Profile.tsx`**: the new-picture preview uses the hook. - Deviation from the plan in #5: the hook takes one blob (`useObjectUrl`), not a list (`useObjectUrls`). A list would change identity on every render and need extra care to avoid re-running the effect. - **`postWithImages`** moved from `pages/Diary.tsx` to `matrix/diary.ts`, next to `uploadImage` and `postEntry`. Diary and Notes import it from there, and page files export only components again. - **`matrix/koto.test.ts`**: removed the unused `beforeAll` import. - **`package.json`**: `lint` is now `oxlint --deny-warnings`, so warnings fail locally and in CI. ## Verification - lint (no output), typecheck, unit tests and build all pass locally. - Adding an unused import makes `npm run lint` exit 1; removing it brings it back to 0. - Not yet checked in a browser. After merging, on the demo: - [ ] picking images in the diary and notes shows previews; removing one updates the grid - [ ] a post with images still goes through - [ ] the new profile picture preview shows, and clears after saving
- Keep object URL handling in a single, documented place
  - add a hook that makes an object URL and revokes it with the component
  - use it for the image picker's previews and the new profile picture
  - allow setting state in that effect only, explaining why
- Stop remaking every preview when one image is added or removed

Refs #5
- Keep page files exporting only components, so fast refresh works
  - move the upload-then-post helper next to the functions it calls
  - import it from there in the diary and the notes

Refs #5
chore(lint): fail on warnings
All checks were successful
ci / check (pull_request) Successful in 1m13s
ac98e15f99
- Stop new lint warnings from slipping through CI
  - make warnings fail the lint script, locally and in CI
  - drop the last unused import in the tests

Closes #5
genji1024 approved these changes 2026-10-12 03:46:11 +09:00
genji1024 left a comment

LGTM!

LGTM!
genji1024 deleted branch fix/lint-warnings 2026-10-12 03:48:50 +09:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
genji1024/koto!6
No description provided.