From bd99d90c0973e90066ddf45b286f6cae3e13ef81 Mon Sep 17 00:00:00 2001 From: jableader Date: Sat, 18 Oct 2025 14:16:34 +1100 Subject: [PATCH] Autoformat --- .env.example | 3 + package.json | 7 +- refactor-strategy.md | 46 ----- src/App.vue | 24 ++- src/components/ActionItem.vue | 5 +- src/components/AlertToast.vue | 80 ++++---- src/components/LoginPage.vue | 65 ++++--- .../ingredients/CompactParsedIngredient.vue | 39 +++- .../ingredients/EditableIngredientsPanel.vue | 95 ++++++---- src/components/ingredients/IngredientLine.vue | 8 +- src/components/meals/DatePicker.vue | 17 +- src/components/meals/EditMealPage.vue | 37 +++- src/components/meals/MealCard.vue | 18 +- src/components/meals/MealPlanPage.vue | 105 ++++++----- src/components/meals/PersonList.vue | 154 ++++++++------- src/components/recipes/EditRecipePage.vue | 113 +++++++---- src/components/recipes/RecipeCard.vue | 14 +- src/components/recipes/RecipeSearchBox.vue | 18 +- .../shopping/CurrentShoppingListPage.vue | 177 ++++++++++-------- src/components/shopping/MealSelectionList.vue | 136 +++++++------- src/components/shopping/MyShoppingPage.vue | 10 +- .../shopping/PurchasedShoppingListPage.vue | 39 ++-- src/components/shopping/ShoppingListItem.vue | 123 ++++++------ tests/useAlert.test.js | 26 +++ 24 files changed, 793 insertions(+), 566 deletions(-) create mode 100644 .env.example delete mode 100644 refactor-strategy.md create mode 100644 tests/useAlert.test.js diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..36bccb0 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +# Base URL for the backend API +# Example: http://localhost:8081 +VUE_APP_API_BASE= diff --git a/package.json b/package.json index 1f55db5..bcf5409 100644 --- a/package.json +++ b/package.json @@ -42,13 +42,16 @@ "vue/setup-compiler-macros": true }, "extends": [ - "plugin:vue/vue3-essential", + "plugin:vue/vue3-recommended", "eslint:recommended" ], "parserOptions": { "parser": "@babel/eslint-parser" }, - "rules": {} + "rules": { + "vue/multi-word-component-names": "off", + "vue/no-mutating-props": "error" + } }, "browserslist": [ "> 1%", diff --git a/refactor-strategy.md b/refactor-strategy.md deleted file mode 100644 index 02456a3..0000000 --- a/refactor-strategy.md +++ /dev/null @@ -1,46 +0,0 @@ -# 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 -- DONE: Replaced the event bus with `useAlert` composable and updated `AlertToast.vue` and callers. -- Follow-up: consider queuing multiple alerts if needed (current behavior shows latest only). - -Acceptance: N/A (completed). Optional enhancement if queuing desired. - -## 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. diff --git a/src/App.vue b/src/App.vue index aa23d13..e96fb13 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,19 +2,31 @@
diff --git a/src/components/ActionItem.vue b/src/components/ActionItem.vue index 1b0658b..7b52849 100644 --- a/src/components/ActionItem.vue +++ b/src/components/ActionItem.vue @@ -2,7 +2,10 @@

{{ title }}

- +
diff --git a/src/components/AlertToast.vue b/src/components/AlertToast.vue index 55cc821..b309b1d 100644 --- a/src/components/AlertToast.vue +++ b/src/components/AlertToast.vue @@ -1,13 +1,55 @@ + + - - diff --git a/src/components/LoginPage.vue b/src/components/LoginPage.vue index d46a4b1..bd04b3f 100644 --- a/src/components/LoginPage.vue +++ b/src/components/LoginPage.vue @@ -2,8 +2,15 @@

Login Page

+ + - - diff --git a/src/components/ingredients/CompactParsedIngredient.vue b/src/components/ingredients/CompactParsedIngredient.vue index e7fa783..5976e56 100644 --- a/src/components/ingredients/CompactParsedIngredient.vue +++ b/src/components/ingredients/CompactParsedIngredient.vue @@ -1,22 +1,37 @@ + + - - diff --git a/tests/useAlert.test.js b/tests/useAlert.test.js new file mode 100644 index 0000000..da94cfc --- /dev/null +++ b/tests/useAlert.test.js @@ -0,0 +1,26 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest' +import { useAlert } from '@/composables/useAlert' + +describe('useAlert', () => { + beforeEach(() => { + vi.useFakeTimers() + }) + + it('shows and clears alerts', () => { + const { current, show, clear } = useAlert() + expect(current.value).toBeNull() + show({ heading: 'Hello', message: 'World', type: 'info' }) + expect(current.value).toMatchObject({ heading: 'Hello', message: 'World', type: 'info' }) + clear() + expect(current.value).toBeNull() + }) + + it('auto-dismisses after scheduleAutoDismiss', () => { + const { current, show, scheduleAutoDismiss } = useAlert() + show({ heading: 'Auto', message: 'Dismiss', type: 'success' }) + scheduleAutoDismiss(5000) + expect(current.value).not.toBeNull() + vi.advanceTimersByTime(5000) + expect(current.value).toBeNull() + }) +})