munch-ease-frontend/refactor-strategy.md
2025-10-18 14:06:24 +11:00

2.1 KiB

Refactor Strategy

This document outlines a pragmatic, step-by-step refactor plan to improve structure, readability, and maintainability. Each step includes a clear outcome and a checkbox to track progress.

Last updated: 2025-10-18

Goals

  • Separate concerns (routing, HTTP/API, mapping/normalization, UI logic)
  • Improve readability and testability
  • Establish light-weight standards (naming, lint/format) without blocking development
  • Keep changes incremental and safe

Phases and Steps

Phase 1 — Routing and Auth (Foundational)

Refactor Strategy (Outstanding Work)

Last updated: 2025-10-18

Only outstanding, actionable steps are listed below. Completed work has been removed for clarity.

1) Linting and rules modernization

  • Evaluate upgrading ESLint and eslint-plugin-vue to latest that fully supports Vue 3 macros and recommended rules.
  • Align rules with Composition API best practices; ensure Prettier remains source of truth.

Acceptance: ESLint upgrade plan decided (or implemented), rules apply cleanly, lint passes.

2) Alerts as a composable (nice-to-have)

  • Replace the simple event bus in src/alert.js with a useAlert composable (reactive queue API) and adapt AlertToast.vue.
  • Provide show({ heading, message, type }) and auto-dismiss with clear-on-click.

Acceptance: AlertToast driven by composable; no global mutable arrays; behavior unchanged.

3) Incremental test coverage

  • Add unit tests for new utilities/composables when added (e.g., useAlert).
  • Consider snapshot tests for components with stable UI fragments (cards, list items).

Acceptance: New logic lands with tests; existing tests stay green.

4) Developer experience

  • Document .env usage with VUE_APP_API_BASE and add a .env.example file.
  • Add Volar as a recommended extension in the project docs (README updated).

Acceptance: Clear env setup; editor help consistent.

5) Optional: Migrate from Vue CLI to Vite

  • If desired, migrate build tooling to Vite for faster dev server and simpler config.
  • Update scripts, configure vitest (already in place), and resolve aliasing.

Acceptance: Dev/build parity maintained; cold/hot start noticeably faster.