Skip to content

Chore/quality baseline#2

Open
jiaiqi wants to merge 4 commits into
ChaoyLin:mainfrom
jiaiqi:chore/quality-baseline
Open

Chore/quality baseline#2
jiaiqi wants to merge 4 commits into
ChaoyLin:mainfrom
jiaiqi:chore/quality-baseline

Conversation

@jiaiqi

@jiaiqi jiaiqi commented Jun 28, 2026

Copy link
Copy Markdown

No description provided.

贾琦 added 4 commits June 28, 2026 13:49
- Add ESLint 9 flat config (eslint.config.mjs) for TS + React hooks
  - Existing-debt rules (any/unused-vars/react-compiler heuristics) set to
    warn so current code passes; zero-violation safety rules stay error
  - no-undef disabled for TS (TypeScript already covers it)
- Add lint / lint:fix scripts and eslint devDependencies
- Add .github/workflows/ci.yml running typecheck + lint on PR and main push
- Apply safe autofixes (let->const, as const); restore stale eslint-disable
  directives with current rule name (no-require-imports)

Baseline: 0 errors, ~1540 warnings (tracked debt). typecheck + lint pass.
- Add Vitest 4 with dedicated vitest.config.ts (node env, tests/ dir)
- Add test / test:watch scripts; wire 'npm test' into CI workflow
- 55 tests covering pure, deterministic logic:
  - exportDateRange: preset ranges, leap-day boundary, date parsing
    validation, legacy config migration (7d/30d/90d), serialize round-trip
  - LRUCache: LRU eviction order, recency on get, update semantics
  - pathUtils: expandHomePath (~, ~/, ~\, edge cases)

All green: typecheck + lint + test.
Previously the app had no general-purpose logger: ~500 console.* calls
went to stdout/stderr (invisible in packaged builds) and the log:debug
IPC channel was exposed in preload but had no main-process handler.

- Add electron-log with a logger service (electron/services/logger.ts):
  - rotating file log at {userData}/logs/main.log (5MB cap)
  - redirect main-process console.* to the log file (zero call-site edits)
  - catch uncaughtException / unhandledRejection (no dialog)
  - log app lifecycle and process-crash events
- Initialize logger early in main.ts; implement the missing log:debug
  handler so renderer errors are persisted
- Forward renderer window.onerror / unhandledrejection from main.tsx
- Externalize electron-log in the main-process vite build

Privacy: logs stay entirely on the user's machine; no network upload
(consistent with the app's no-data-leaves-device policy). Verified with
typecheck + lint + test + vite build.
Move version/track logic out of main.ts into electron/utils/updateTrack.ts
(pure, no electron deps) and add 23 unit tests:
- inferUpdateTrackFromVersion: stable/preview/dev detection from version
- normalizeUpdateTrack, getUpdaterFeedUrlByTrack
- compareVersions / isVersionNewer: semver core + prerelease ordering

main.ts now imports these; behavior preserved (isRemoteVersionNewer keeps
its autoUpdater fast-path and uses isVersionNewer only as fallback).

Verified: typecheck + lint + test (78) + vite build all green.
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