Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzyCzech committed Dec 9, 2024
1 parent ad36a21 commit 31aca5f
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 105 deletions.
16 changes: 3 additions & 13 deletions biome.json
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,10 +19,5 @@
"noParameterAssign": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
16 changes: 4 additions & 12 deletions lib/easter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand All @@ -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());
}

/**
Expand All @@ -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());
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down
15 changes: 2 additions & 13 deletions lib/get-meta.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
19 changes: 3 additions & 16 deletions lib/holidays.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -30,11 +24,7 @@ const holidays: Record<string, string> = {
*/
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;
}

/**
Expand Down Expand Up @@ -73,10 +63,7 @@ export function getPublicHolidaysList(year: number): Map<string, string> {
list.set(goodFriday.toISODate() ?? "", getEasterDayName(goodFriday) ?? "");

const easterMonday = getEasterMonday(year);
list.set(
easterMonday.toISODate() ?? "",
getEasterDayName(easterMonday) ?? "",
);
list.set(easterMonday.toISODate() ?? "", getEasterDayName(easterMonday) ?? "");

return list;
}
4 changes: 1 addition & 3 deletions lib/significant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ const significant = data as Record<string, SignificantDay>;
* 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")];
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist/*"
"files": ["dist/*"
],
"dependencies": {
"easter-date": "0.0.20",
Expand Down
15 changes: 3 additions & 12 deletions test/holidays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
64 changes: 30 additions & 34 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"
]
}
"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/**/*"]
}

0 comments on commit 31aca5f

Please sign in to comment.