From 31aca5fcb69d54634ebfabe4518590cc757e9c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20O=C5=BEana?= Date: Mon, 9 Dec 2024 10:24:00 +0100 Subject: [PATCH] Reformat code --- biome.json | 16 +++--------- lib/easter.ts | 16 +++--------- lib/get-meta.ts | 15 ++--------- lib/holidays.ts | 19 +++----------- lib/significant.ts | 4 +-- package.json | 3 +-- test/holidays.ts | 15 +++-------- tsconfig.json | 64 ++++++++++++++++++++++------------------------ 8 files changed, 47 insertions(+), 105 deletions(-) diff --git a/biome.json b/biome.json index 45d0f28..7e042cd 100644 --- a/biome.json +++ b/biome.json @@ -1,17 +1,12 @@ { "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json", - "vcs": { - "enabled": false, - "clientKind": "git", - "useIgnoreFile": false - }, "files": { - "ignoreUnknown": false, - "include": ["lib/**/*.*", "test/**/*.*", "package.json"] + "ignore": ["dist/**/*.*", "package.json"] }, "formatter": { "enabled": true, - "indentStyle": "tab" + "indentStyle": "tab", + "lineWidth": 240 }, "organizeImports": { "enabled": true @@ -24,10 +19,5 @@ "noParameterAssign": "off" } } - }, - "javascript": { - "formatter": { - "quoteStyle": "double" - } } } diff --git a/lib/easter.ts b/lib/easter.ts index 3aa79b7..98f7ba6 100644 --- a/lib/easter.ts +++ b/lib/easter.ts @@ -14,9 +14,7 @@ export function getEasterMonday(year: number): DateTime { * @param date */ export function isEasterMonday(date: DateTime | Date): boolean { - return EasterDate.isEasterMonday( - date instanceof Date ? date : date.toJSDate(), - ); + return EasterDate.isEasterMonday(date instanceof Date ? date : date.toJSDate()); } /** @@ -41,9 +39,7 @@ export function getEasterSunday(year: number): DateTime { * @param date */ export function isEasterSunday(date: DateTime | Date): boolean { - return EasterDate.isEasterSunday( - date instanceof Date ? date : date.toJSDate(), - ); + return EasterDate.isEasterSunday(date instanceof Date ? date : date.toJSDate()); } /** @@ -59,9 +55,7 @@ export function getHolySaturday(year: number): DateTime { * @param date */ export function isHolySaturday(date: DateTime | Date): boolean { - return EasterDate.isHolySaturday( - date instanceof Date ? date : date.toJSDate(), - ); + return EasterDate.isHolySaturday(date instanceof Date ? date : date.toJSDate()); } /** @@ -105,9 +99,7 @@ export function isHolyWeek(date: DateTime | Date): boolean { return false; } - return interval.start && interval.end - ? interval.start <= date && date <= interval.end - : false; + return interval.start && interval.end ? interval.start <= date && date <= interval.end : false; } /** diff --git a/lib/get-meta.ts b/lib/get-meta.ts index 52a2cc2..876549b 100644 --- a/lib/get-meta.ts +++ b/lib/get-meta.ts @@ -1,19 +1,8 @@ import { DateTime } from "luxon"; -import { - getEasterDayName, - isEasterMonday, - isEasterSunday, - isGoodFriday, - isHolySaturday, - isHolyWeek, -} from "./easter.js"; +import { getEasterDayName, isEasterMonday, isEasterSunday, isGoodFriday, isHolySaturday, isHolyWeek } from "./easter.js"; import { getPublicHoliday, isPublicHoliday } from "./holidays.js"; import { areShopsOpen, getShopsStatus } from "./shops.js"; -import { - type SignificantDay, - getSignificantDay, - isSignificantDay, -} from "./significant.js"; +import { type SignificantDay, getSignificantDay, isSignificantDay } from "./significant.js"; export type EasterMetadata = { name: string | undefined; diff --git a/lib/holidays.ts b/lib/holidays.ts index 5606962..244f6ee 100644 --- a/lib/holidays.ts +++ b/lib/holidays.ts @@ -1,11 +1,5 @@ import { DateTime } from "luxon"; -import { - getEasterDayName, - getEasterMonday, - getGoodFriday, - isEasterMonday, - isGoodFriday, -} from "./easter.js"; +import { getEasterDayName, getEasterMonday, getGoodFriday, isEasterMonday, isGoodFriday } from "./easter.js"; /** * Zákon č. 245/2000 Sb., o státních svátcích a národních svátcích České republiky @@ -30,11 +24,7 @@ const holidays: Record = { */ export function isPublicHoliday(date: DateTime | Date): boolean { date = date instanceof Date ? DateTime.fromJSDate(date) : date; - return ( - isEasterMonday(date) || - isGoodFriday(date) || - date.toFormat("ddMM") in holidays - ); + return isEasterMonday(date) || isGoodFriday(date) || date.toFormat("ddMM") in holidays; } /** @@ -73,10 +63,7 @@ export function getPublicHolidaysList(year: number): Map { list.set(goodFriday.toISODate() ?? "", getEasterDayName(goodFriday) ?? ""); const easterMonday = getEasterMonday(year); - list.set( - easterMonday.toISODate() ?? "", - getEasterDayName(easterMonday) ?? "", - ); + list.set(easterMonday.toISODate() ?? "", getEasterDayName(easterMonday) ?? ""); return list; } diff --git a/lib/significant.ts b/lib/significant.ts index 194f8db..a1c235a 100644 --- a/lib/significant.ts +++ b/lib/significant.ts @@ -19,9 +19,7 @@ const significant = data as Record; * Returns the significant day for the given date. * @param date */ -export function getSignificantDay( - date: DateTime | Date, -): SignificantDay | undefined { +export function getSignificantDay(date: DateTime | Date): SignificantDay | undefined { date = date instanceof Date ? DateTime.fromJSDate(date) : date; return significant[date.toFormat("ddMM")]; } diff --git a/package.json b/package.json index 05f9547..6e501fd 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,7 @@ }, "main": "dist/index.js", "types": "dist/index.d.ts", - "files": [ - "dist/*" + "files": ["dist/*" ], "dependencies": { "easter-date": "0.0.20", diff --git a/test/holidays.ts b/test/holidays.ts index 9b60d70..e225db2 100644 --- a/test/holidays.ts +++ b/test/holidays.ts @@ -3,18 +3,9 @@ import { DateTime } from "luxon"; import { getPublicHoliday, getPublicHolidaysList } from "../lib"; test("Selected czech holidays", (t) => { - t.is( - getPublicHoliday(DateTime.fromISO("2024-01-01")), - "Den obnovy samostatného českého státu", - ); - t.is( - getPublicHoliday(DateTime.fromISO("2024-11-17")), - "Den boje za svobodu a demokracii (1939 a 1989)", - ); - t.is( - getPublicHoliday(DateTime.fromISO("2024-12-26")), - "Druhý svátek vánoční", - ); + t.is(getPublicHoliday(DateTime.fromISO("2024-01-01")), "Den obnovy samostatného českého státu"); + t.is(getPublicHoliday(DateTime.fromISO("2024-11-17")), "Den boje za svobodu a demokracii (1939 a 1989)"); + t.is(getPublicHoliday(DateTime.fromISO("2024-12-26")), "Druhý svátek vánoční"); }); test("Easter Monday is holiday", (t) => { diff --git a/tsconfig.json b/tsconfig.json index 84bbf40..fdc6abd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,35 +1,31 @@ { - "compilerOptions": { - "outDir": "dist", - "module": "esnext", - "moduleResolution": "node", - "moduleDetection": "force", - "allowSyntheticDefaultImports" : true, - "target": "es2022", - "lib": [ - "ES2022" - ], - "resolveJsonModule": true, - // ESM doesn't yet support JSON modules. - "jsx": "react", - "declaration": true, - "newLine": "lf", - "stripInternal": true, - "strict": true, - "noImplicitReturns": true, - "noImplicitOverride": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedIndexedAccess": true, - "noPropertyAccessFromIndexSignature": false, - "noEmitOnError": true, - "useDefineForClassFields": true, - "forceConsistentCasingInFileNames": true, - "skipLibCheck": true, - "isolatedModules": true - }, - "include": [ - "lib/**/*" - ] -} \ No newline at end of file + "compilerOptions": { + "outDir": "dist", + "module": "esnext", + "moduleResolution": "node", + "moduleDetection": "force", + "allowSyntheticDefaultImports": true, + "target": "es2022", + "lib": ["ES2022"], + "resolveJsonModule": true, + // ESM doesn't yet support JSON modules. + "jsx": "react", + "declaration": true, + "newLine": "lf", + "stripInternal": true, + "strict": true, + "noImplicitReturns": true, + "noImplicitOverride": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + "noPropertyAccessFromIndexSignature": false, + "noEmitOnError": true, + "useDefineForClassFields": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "isolatedModules": true + }, + "include": ["lib/**/*"] +}