Skip to content

Commit 7c840a3

Browse files
committed
Update dependencies build test processes.
1 parent fb07ff0 commit 7c840a3

24 files changed

+3687
-4837
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 20
1413
- 22
14+
- 24
1515

1616
os:
1717
- ubuntu-latest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ __generated__/
4848

4949
# ignore distribution folder
5050
dist/
51-
lib/
51+
build/
5252

5353
# NYC output
5454
.nyc_output

eslint.config.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// @ts-check
2+
import eslint from "@eslint/js";
3+
import tseslint from "typescript-eslint";
4+
5+
export default tseslint.config(
6+
{ ignores: ["build/*"] },
7+
{
8+
files: ["rollup.config.ts", "lib/**/*.ts", "tests/**/*.ts"],
9+
languageOptions: {
10+
parserOptions: {
11+
projectService: true,
12+
tsconfigRootDir: import.meta.dirname,
13+
},
14+
},
15+
extends: [
16+
eslint.configs.recommended,
17+
tseslint.configs.strictTypeChecked,
18+
tseslint.configs.stylisticTypeChecked,
19+
{
20+
rules: {
21+
"functional/no-mixed-types": ["off"],
22+
"@typescript-eslint/restrict-template-expressions": [
23+
"error",
24+
{ allowNumber: true },
25+
],
26+
},
27+
},
28+
],
29+
},
30+
);
File renamed without changes.
File renamed without changes.

src/format.ts renamed to lib/format.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DateTime, Interval } from "luxon";
22
import { BroadcastTimeZone, StringInterval } from "./types";
3-
import { IfValid } from "./helpers";
43
import { BroadcastCalendar } from "./calendar";
4+
import { IfValid } from "./helpers";
55

66
export const makeFormatter =
77
(format: string) =>
@@ -16,22 +16,22 @@ export function formatToISOWithoutTZ<IsValid extends boolean>(
1616
return datetime.toISO({
1717
includeOffset: false,
1818
suppressMilliseconds: true,
19-
});
19+
}) as IfValid<IsValid, string>;
2020
}
2121

2222
export function formatToSQLWithoutTZ<IsValid extends boolean>(
2323
datetime: DateTime<IsValid>,
2424
) {
2525
return datetime.toSQL({
2626
includeOffset: false,
27-
});
27+
}) as IfValid<IsValid, string>;
2828
}
2929

3030
export function formatBroadcastDateInterval<IsValid extends boolean>(
3131
interval: Interval<IsValid>,
3232
format = toISODate,
3333
): IfValid<IsValid, StringInterval> {
34-
if (!interval.start || !interval.end) {
34+
if (!interval.isValid || !interval.start || !interval.end) {
3535
return null as IfValid<IsValid, StringInterval>;
3636
}
3737

@@ -53,16 +53,20 @@ export function formatBroadcastCalendar<IsValid extends boolean>({
5353
weekInterval,
5454
}: BroadcastCalendar<IsValid>) {
5555
return {
56-
date: date.toISODate(),
56+
date: date.toISODate() as IfValid<IsValid, string>,
5757
year,
5858
yearInterval: yearInterval && formatBroadcastDateInterval(yearInterval),
5959
quarter,
6060
quarterInterval:
6161
quarterInterval && formatBroadcastDateInterval(quarterInterval),
6262
monthInterval: monthInterval && formatBroadcastDateInterval(monthInterval),
6363
week,
64-
weekInterval: weekInterval && formatBroadcastDateInterval(weekInterval),
64+
weekInterval: formatBroadcastDateInterval(weekInterval),
6565
weekKey,
66-
weekDay: date.toFormat("EEEE"),
66+
weekDay: date.toFormat("EEEE") as IfValid<
67+
IsValid,
68+
string,
69+
"Invalide DateTime"
70+
>,
6771
};
6872
}

src/helpers.ts renamed to lib/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { DateTime } from "luxon";
22

3+
export type DefaultInvalidType = null;
4+
35
export type IfValid<
46
ThisIsValid extends boolean,
57
ValidType,
68
InvalidType = DefaultInvalidType,
79
> = ThisIsValid extends true ? ValidType : InvalidType;
810

9-
export type DefaultInvalidType = null;
10-
1111
export function isValid(
1212
date: DateTime | null | undefined,
1313
): date is DateTime<true> {
File renamed without changes.

0 commit comments

Comments
 (0)