whisper-money/resources/js/lib
Víctor Falcón 2a1286e98a
chore(frontend): add orphan component detection and remove dead components (#181)
## 🚪 Why?

### Problem

Dead frontend components were accumulating in the codebase with no
automated way to detect them. Unused code increases maintenance burden,
confuses contributors, and inflates bundle analysis noise. Additionally,
several React hooks had incorrect dependency arrays causing stale
closures or unnecessary re-renders, and an unused variable was left in
the new test file.

## 🔑 What?

### Changes

- Add `resources/js/lib/orphan-components.test.ts` — a Vitest test that
scans every file under `resources/js/components/` and fails if any
component is never imported anywhere in the codebase (supports `@/`
alias imports, relative imports, and barrel `index.*` re-exports)
- Delete 14 orphan components identified by the new test:
-
`accounts/import-balances/import-balance-step-{account,mapping,preview,upload}`
  - `app-mobile-nav`
  - `appearance-dropdown`
  - `dashboard/stat-card`
  - `landing/encryption-video-player`
  - `sync-status-button`
  - `transactions/date-header`
  - `ui/{icon,input-group,navigation-menu,placeholder-pattern}`
- Restore `ui/avatar.tsx` which was incorrectly included in the deletion
(it is imported via relative path in `user-info.tsx`)
- Fix ESLint warnings across 5 files:
- `orphan-components.test.ts` — remove unused `componentDir` variable in
`importStrings()`
- `transaction-list.tsx` — remove `categories`, `accounts`, `banks`,
`automationRules` from `useCallback` deps (none referenced in callback
body)
- `amount-input.tsx` — add missing `locale` dep to `useEffect` (used in
`formatCurrency`)
- `use-dashboard-data.ts` — wrap `fetchData` in `useCallback([locale])`
and add to `useEffect` deps to prevent stale closure on locale
- `dashboard.tsx` — wrap `netWorthEvolution` fallback in
`useMemo([props.netWorthEvolution])` to stabilise the reference passed
to the downstream `useMemo`

##  Verification

### Tests

The new test runs as part of `bun run test` (Vitest), already executed
in the `linter` CI job. All 48 tests pass:

```
✓ resources/js/lib/chart-calculations.test.ts (32 tests)
✓ resources/js/lib/file-parser.test.ts (15 tests)
✓ resources/js/lib/orphan-components.test.ts (1 test)
```

`bun run lint` and `bun run build` now exit clean.

Going forward, any new component added to `resources/js/components/`
that is not imported anywhere will fail CI automatically.
2026-03-02 12:43:27 +01:00
..
balance-import-config-storage.ts fix: add SSR guards to localStorage/sessionStorage access 2025-12-08 18:19:20 +01:00
chart-calculations.test.ts feat: add multiple chart view modes for net worth evolution (#37) 2025-12-30 07:22:19 +01:00
chart-calculations.ts feat: add multiple chart view modes for net worth evolution (#37) 2025-12-30 07:22:19 +01:00
crypto.ts Add some toast notifications 2025-11-11 11:39:28 +00:00
debug.ts fix: make useIsMobile hook and utility functions SSR-safe 2025-12-08 17:33:54 +01:00
dexie-db.ts Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
file-parser.test.ts Fix: Use locale to disambiguate date format during CSV import (#107) 2026-02-12 09:08:52 +01:00
file-parser.ts Fix: Use locale to disambiguate date format during CSV import (#107) 2026-02-12 09:08:52 +01:00
import-config-storage.ts fix: add SSR guards to localStorage/sessionStorage access 2025-12-08 18:19:20 +01:00
key-storage.ts fix: make encryption key storage SSR-safe to prevent 502 errors 2025-12-08 17:13:45 +01:00
orphan-components.test.ts chore(frontend): add orphan component detection and remove dead components (#181) 2026-03-02 12:43:27 +01:00
posthog.ts feat: Add PostHog (#70) 2026-01-20 10:47:59 +01:00
rule-builder-utils.ts feat(automation-rules): simplify smart rules UI, fix re-evaluation, and localize amounts (#161) 2026-02-28 13:24:57 +00:00
rule-engine.ts feat(automation-rules): simplify smart rules UI, fix re-evaluation, and localize amounts (#161) 2026-02-28 13:24:57 +00:00
sankey-utils.ts feat: Group small expending categories on the Sankey chart 2026-01-11 19:04:20 +01:00
sync-manager.ts chore: Simplify IndexedDB sync by moving to Inertia shared props (#63) 2026-01-19 19:15:26 +01:00
utils.ts Prevent duplicate notes when re-evaluating automation rules 2025-12-04 16:42:54 +01:00