The frontend had no JS/TS linter — only svelte-check. Add flat-config ESLint (typescript-eslint
+ eslint-plugin-svelte) and Prettier (tabs/single-quote, matching the existing style).
Rules encode "catch bugs, not enforce taste":
- svelte/require-each-key KEPT — it is the exact bug class as the feed mis-tap fix. Fixed every
flagged block: keyed activeFilters, filteredUsers, stagedFiles (by previewUrl), captionTags,
admin tabs/jobs/users, the export-viewer suggestions/filters/comments, and the static skeleton
loops.
- svelte/prefer-svelte-reactivity KEPT — inline-disabled only the verified-safe sites (a local
freq Map in a $derived.by, throwaway URLSearchParams query builders), with a reason each.
- svelte/no-navigation-without-resolve OFF — wants resolve() around every goto()/href; taste, not
a bug, and pure churn.
- svelte/no-unused-svelte-ignore OFF — those comments are consumed by svelte-check, which ESLint
can't see, so it wrongly calls them unused; removing them would reintroduce a11y warnings.
- no-explicit-any OFF for *.test.ts only (partial fixtures legitimately use any).
Real code fixes beyond keys: removed a dead jobLabel(), an unused ViewerComment import and unused
catch binding, an unused scroll-lock arg, and replaced an empty interface with a type alias.
Then `prettier --write` (54 files). Formatting only. Verified: eslint clean, svelte-check 0 errors,
vitest 46 passed, vite build succeeds.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.7 KiB
Markdown
36 lines
1.7 KiB
Markdown
# `lib/` conventions
|
|
|
|
Short rules. The patterns we already follow as of v0.16 — write new code that fits.
|
|
|
|
**One store per cross-cutting concern.** A single `*-store.ts` file owns each one:
|
|
|
|
- `auth.ts` — JWT / PIN in `localStorage`, `isAuthenticated` writable
|
|
- `ui-store.ts` — bottom-nav visibility, upload-sheet open state, FAB badge count
|
|
- `data-mode-store.ts` — Saver vs Original media-loading preference
|
|
- `privacy-note-store.ts` — admin-configured Datenschutzhinweis text
|
|
- `quota-store.ts` — live per-user storage snapshot
|
|
- `upload-queue.ts` — IndexedDB-persisted upload queue + processing state
|
|
|
|
Don't import these into other stores unless strictly necessary; let pages compose them.
|
|
|
|
**DTOs mirror Rust types.** All TS interfaces live in `types.ts`. Each one carries a
|
|
`// mirrors backend/src/path::TypeName` comment so the two stay searchable. If you add
|
|
a Rust DTO, add the TS twin in the same PR.
|
|
|
|
**Gestures via Svelte actions in `actions/`.** Long-press, double-tap, future swipe —
|
|
each is a `use:` action that fires a CustomEvent. Components stay free of gesture
|
|
plumbing.
|
|
|
|
**Reusable bottom sheets via `ContextSheet.svelte`.** Pass an `actions: ContextAction[]`
|
|
array. Any page that needs a long-press / kebab context menu uses the same primitive.
|
|
|
|
**SSE relays are listed in `sse.ts::KNOWN_EVENTS`.** New server event → add one entry
|
|
to that array, that's it.
|
|
|
|
**Diashow transitions live in `diashow/transitions/`.** Each is a Svelte component
|
|
plus one entry in `transitions/index.ts`. Adding a new animation is two-line work; no
|
|
diashow code needs to change.
|
|
|
|
**No new global stores** beyond the list above unless the new concept is genuinely
|
|
app-wide. Page state belongs in the page.
|