From b584b3eeb49210b8685be2b4b206bc4d51e28414 Mon Sep 17 00:00:00 2001 From: Willian Alves Date: Mon, 2 Sep 2024 21:39:40 -0300 Subject: [PATCH] run deno fmt --- README.md | 12 +++++++++--- db/migrations/remove-unnecessary-keys.ts | 8 +++++--- deno.json | 17 +++-------------- utils/date.ts | 10 +++++----- utils/expenses/factory.ts | 12 +++++------- 5 files changed, 27 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 4337a44..33ab24c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ expense tracker app I always wanted and never found. Make sure to install Deno: https://deno.land/manual/getting_started/installation -Then copy the `.env.example` to `.env` and fill the necessary values. You will need a GitHub and a Google apps available for starting the app with authentication. +Then copy the `.env.example` to `.env` and fill the necessary values. You will +need a GitHub and a Google apps available for starting the app with +authentication. You're good to start the project: @@ -19,6 +21,10 @@ This will watch the project directory and restart as necessary. ## Inspecting the DB -Since I used [deno kv](https://deno.com/kv), I didn't find a proper way of inspecting its data, even if I export it to a sqlite file with the `DENO_KV_PATH` environment variable. +Since I used [deno kv](https://deno.com/kv), I didn't find a proper way of +inspecting its data, even if I export it to a sqlite file with the +`DENO_KV_PATH` environment variable. -I found [kview](https://github.com/kitsonk/kview) which works better than inspecting the sqlite file. So, if you intend to run the project locally and want to inspect any db data, I highly encourage to use kview. +I found [kview](https://github.com/kitsonk/kview) which works better than +inspecting the sqlite file. So, if you intend to run the project locally and +want to inspect any db data, I highly encourage to use kview. diff --git a/db/migrations/remove-unnecessary-keys.ts b/db/migrations/remove-unnecessary-keys.ts index 4d5f200..984aec2 100644 --- a/db/migrations/remove-unnecessary-keys.ts +++ b/db/migrations/remove-unnecessary-keys.ts @@ -36,9 +36,11 @@ for (const index of indexes) { const addOperations = kv.atomic(); - for await (const entry of kv.list({ - prefix: [oldKey], - })) { + for await ( + const entry of kv.list({ + prefix: [oldKey], + }) + ) { const income = entry.value; addOperations.set([newKey, income.userId, income.id], income); } diff --git a/deno.json b/deno.json index 7ef7e90..da236f8 100644 --- a/deno.json +++ b/deno.json @@ -11,17 +11,8 @@ "preview": "deno run -A --unstable-kv main.ts", "update": "deno run -A -r https://fresh.deno.dev/update ." }, - "lint": { - "rules": { - "tags": [ - "fresh", - "recommended" - ] - } - }, - "exclude": [ - "**/_fresh/*" - ], + "lint": { "rules": { "tags": ["fresh", "recommended"] } }, + "exclude": ["**/_fresh/*"], "imports": { "$fresh/": "https://deno.land/x/fresh@1.6.8/", "@/": "./", @@ -54,9 +45,7 @@ }, "deploy": { "project": "a5faed4e-ddaf-4198-9b02-e379b4f89a5b", - "exclude": [ - "**/node_modules" - ], + "exclude": ["**/node_modules"], "include": [], "entrypoint": "main.ts" } diff --git a/utils/date.ts b/utils/date.ts index 534efd4..642d50b 100644 --- a/utils/date.ts +++ b/utils/date.ts @@ -3,7 +3,7 @@ import { activeMonth } from "@/signals/menu.ts"; /** * This function receives a date and returns a string in the format "DD/MM/YYYY" * It returns the BR format by default. Used to display the date in the tables - **/ + */ export const getFormattedDate = (date: Date | string) => { // TODO at some point make this come from user settings return Intl.DateTimeFormat("pt-BR").format(new Date(date)); @@ -15,7 +15,7 @@ export const getFormattedDate = (date: Date | string) => { * * @param {Date} [date] - (optional) Expense or income date to be formatted * @returns string - **/ + */ export const formDate = (date?: Date) => { if (!date) { const d = new Date(); @@ -34,7 +34,7 @@ export const formDate = (date?: Date) => { /** * This function returns the date of today in an object with the year, month and day - **/ + */ export const today = () => { const date = new Date(); return stripDate(date); @@ -42,7 +42,7 @@ export const today = () => { /** * This function receives a date and returns an object with the year, month and day - **/ + */ export const stripDate = (date: Date) => { const year = date.getFullYear(); const month = date.getMonth() + 1; @@ -54,7 +54,7 @@ export const stripDate = (date: Date) => { /** * This function receives a date and returns the number of days in that month * This is a hack. Returning the day 0 will get the last day of the previous month - **/ + */ export const daysInMonth = (month: number, year: number) => { return new Date(year, month, 0).getDate(); }; diff --git a/utils/expenses/factory.ts b/utils/expenses/factory.ts index 8fef23b..97a7131 100644 --- a/utils/expenses/factory.ts +++ b/utils/expenses/factory.ts @@ -99,12 +99,10 @@ export default class ExpenseInputFactory { } private getInstallmentDate(installment: number) { - return installment === 1 - ? new Date(this.data.paymentDate) - : new Date( - new Date(this.data.paymentDate).setMonth( - new Date(this.data.paymentDate).getMonth() + installment - 1, - ), - ); + return installment === 1 ? new Date(this.data.paymentDate) : new Date( + new Date(this.data.paymentDate).setMonth( + new Date(this.data.paymentDate).getMonth() + installment - 1, + ), + ); } }