Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .eslintrc.json

This file was deleted.

7 changes: 7 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["react", "typescript"],
"env": {
"browser": true,
"es2022": true
}
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"editor.codeActionsOnSave": ["source.organizeImports", "source.fixAll"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "oxc.vscode-oxc",
"editor.formatOnSave": true
}
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@
"ci:publish": "pnpm publish --access public --filter=\\!www --recursive && pnpm changeset tag",
"ci:version": "pnpm changeset version",
"dev": "turbo run dev",
"lint": "eslint . --ext ts,tsx",
"format": "oxfmt --write .",
"lint": "oxlint .",
"test": "turbo run test"
},
"devDependencies": {
"@changesets/cli": "^2.28.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-react-hooks": "^4.6.2",
"prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.2.8",
"oxfmt": "^0.36.0",
"oxlint": "^1.51.0",
"turbo": "^2.5.0",
"typescript": "^5.8.3"
},
Expand Down
22 changes: 13 additions & 9 deletions packages/core/src/clamp.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import { Temporal } from "@js-temporal/polyfill";

export function clamp<
Value extends Temporal.PlainDate | Temporal.PlainDateTime
>(value: Value, minValue?: Value, maxValue?: Value) {
export function clamp<Value extends Temporal.PlainDate | Temporal.PlainDateTime>(
value: Value,
minValue?: Value,
maxValue?: Value,
) {
if (
minValue &&
Temporal[
value instanceof Temporal.PlainDate ? "PlainDate" : "PlainDateTime"
].compare(value, minValue) < 0
Temporal[value instanceof Temporal.PlainDate ? "PlainDate" : "PlainDateTime"].compare(
value,
minValue,
) < 0
) {
return minValue;
}

if (
maxValue &&
Temporal[
value instanceof Temporal.PlainDate ? "PlainDate" : "PlainDateTime"
].compare(value, maxValue) > 0
Temporal[value instanceof Temporal.PlainDate ? "PlainDate" : "PlainDateTime"].compare(
value,
maxValue,
) > 0
) {
return maxValue;
}
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/getCalendarMonthDateRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { getMonthStartDate } from "./getMonthStartDate";

type Value = Temporal.PlainDate | Temporal.PlainDateTime;

export function getCalendarMonthDateRange(
value: Value,
rollover: boolean,
startOfWeek: number
) {
export function getCalendarMonthDateRange(value: Value, rollover: boolean, startOfWeek: number) {
const start = getMonthStartDate(value);
const end = getMonthEndDate(value);

Expand Down
8 changes: 3 additions & 5 deletions packages/core/src/getHours.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Temporal } from "@js-temporal/polyfill";
export function getHours(
value?: Temporal.PlainDateTime,
minValue?: Temporal.PlainDateTime,
maxValue?: Temporal.PlainDateTime
maxValue?: Temporal.PlainDateTime,
) {
const hours: {
hour: number;
Expand All @@ -15,16 +15,14 @@ export function getHours(
!!value &&
!!minValue &&
(Temporal.PlainDate.compare(value, minValue) < 0 ||
(value.toPlainDate().equals(minValue.toPlainDate()) &&
i < minValue.hour));
(value.toPlainDate().equals(minValue.toPlainDate()) && i < minValue.hour));

const isAfterMaxValue =
!isBeforeMinValue &&
!!value &&
!!maxValue &&
(Temporal.PlainDate.compare(value, maxValue) > 0 ||
(value.toPlainDate().equals(maxValue.toPlainDate()) &&
i > maxValue.hour));
(value.toPlainDate().equals(maxValue.toPlainDate()) && i > maxValue.hour));

hours.push({
hour: i,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/getMinutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Temporal } from "@js-temporal/polyfill";
export function getMinutes(
value?: Temporal.PlainDateTime,
minValue?: Temporal.PlainDateTime,
maxValue?: Temporal.PlainDateTime
maxValue?: Temporal.PlainDateTime,
) {
const minutes: {
minute: number;
Expand All @@ -28,7 +28,7 @@ export function getMinutes(
microsecond: 0,
nanosecond: 0,
}),
minValue
minValue,
) <= 0 &&
(value.hour < minValue.hour || minute < minValue.minute)
) {
Expand Down Expand Up @@ -57,7 +57,7 @@ export function getMinutes(
microsecond: 0,
nanosecond: 0,
}),
maxValue
maxValue,
) >= 0 &&
(value.hour > maxValue.hour || minute > maxValue.minute)
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getMonths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getMonths(
locale: Parameters<typeof Intl.DateTimeFormat>[0],
referenceValue: Temporal.PlainDate,
minValue?: Temporal.PlainDate,
maxValue?: Temporal.PlainDate
maxValue?: Temporal.PlainDate,
) {
const longMonthFormatter = new Intl.DateTimeFormat(locale, {
month: "long",
Expand Down
7 changes: 2 additions & 5 deletions packages/core/src/getWeekdays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import { temporalToDate } from "./temporalToDate";

export function getWeekdays(
locale: Parameters<typeof Intl.DateTimeFormat>[0],
startOfWeek: number
startOfWeek: number,
) {
const firstDayOfWeek = getFirstDayOfWeek(
Temporal.Now.plainDateISO(),
startOfWeek
);
const firstDayOfWeek = getFirstDayOfWeek(Temporal.Now.plainDateISO(), startOfWeek);

const longWeekdayFormatter = new Intl.DateTimeFormat(locale, {
weekday: "long",
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/getYears.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Temporal } from "@js-temporal/polyfill";

export function getYears(
minValue: Temporal.PlainDate,
maxValue: Temporal.PlainDate
) {
export function getYears(minValue: Temporal.PlainDate, maxValue: Temporal.PlainDate) {
const years: number[] = [];

for (let i = minValue.year; i < maxValue.year + 1; i += 1) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/temporalToDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export function temporalToDate(value: Value) {
value.hour,
value.minute,
value.second,
value.millisecond
value.millisecond,
);
}
60 changes: 30 additions & 30 deletions packages/core/test/clamp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test("clamp (PlainDate, unbounded)", () => {
year: 2022,
month: 2,
day: 2,
})
}),
);

expect(result instanceof Temporal.PlainDate).toBe(true);
Expand All @@ -19,8 +19,8 @@ test("clamp (PlainDate, unbounded)", () => {
year: 2022,
month: 2,
day: 2,
})
)
}),
),
).toBe(true);
});

Expand All @@ -35,7 +35,7 @@ test("clamp (PlainDate, before min)", () => {
year: 2022,
month: 2,
day: 2,
})
}),
);

expect(result instanceof Temporal.PlainDate).toBe(true);
Expand All @@ -46,8 +46,8 @@ test("clamp (PlainDate, before min)", () => {
year: 2022,
month: 2,
day: 2,
})
)
}),
),
).toBe(true);
});

Expand All @@ -62,7 +62,7 @@ test("clamp (PlainDate, after min)", () => {
year: 2022,
month: 2,
day: 2,
})
}),
);

expect(result instanceof Temporal.PlainDate).toBe(true);
Expand All @@ -73,8 +73,8 @@ test("clamp (PlainDate, after min)", () => {
year: 2022,
month: 2,
day: 3,
})
)
}),
),
).toBe(true);
});

Expand All @@ -90,7 +90,7 @@ test("clamp (PlainDate, before max)", () => {
year: 2022,
month: 2,
day: 4,
})
}),
);

expect(result instanceof Temporal.PlainDate).toBe(true);
Expand All @@ -101,8 +101,8 @@ test("clamp (PlainDate, before max)", () => {
year: 2022,
month: 2,
day: 2,
})
)
}),
),
).toBe(true);
});

Expand All @@ -118,7 +118,7 @@ test("clamp (PlainDate, after max)", () => {
year: 2022,
month: 2,
day: 4,
})
}),
);

expect(result instanceof Temporal.PlainDate).toBe(true);
Expand All @@ -129,8 +129,8 @@ test("clamp (PlainDate, after max)", () => {
year: 2022,
month: 2,
day: 4,
})
)
}),
),
).toBe(true);
});

Expand All @@ -141,7 +141,7 @@ test("clamp (PlainDateTime, unbounded)", () => {
month: 2,
day: 2,
hour: 2,
})
}),
);

expect(result instanceof Temporal.PlainDateTime).toBe(true);
Expand All @@ -153,8 +153,8 @@ test("clamp (PlainDateTime, unbounded)", () => {
month: 2,
day: 2,
hour: 2,
})
)
}),
),
).toBe(true);
});

Expand All @@ -171,7 +171,7 @@ test("clamp (PlainDateTime, before min)", () => {
month: 2,
day: 2,
hour: 2,
})
}),
);

expect(result instanceof Temporal.PlainDateTime).toBe(true);
Expand All @@ -183,8 +183,8 @@ test("clamp (PlainDateTime, before min)", () => {
month: 2,
day: 2,
hour: 2,
})
)
}),
),
).toBe(true);
});

Expand All @@ -201,7 +201,7 @@ test("clamp (PlainDateTime, after min)", () => {
month: 2,
day: 2,
hour: 2,
})
}),
);

expect(result instanceof Temporal.PlainDateTime).toBe(true);
Expand All @@ -213,8 +213,8 @@ test("clamp (PlainDateTime, after min)", () => {
month: 2,
day: 2,
hour: 3,
})
)
}),
),
).toBe(true);
});

Expand All @@ -232,7 +232,7 @@ test("clamp (PlainDateTime, before max)", () => {
month: 2,
day: 2,
hour: 2,
})
}),
);

expect(result instanceof Temporal.PlainDateTime).toBe(true);
Expand All @@ -244,8 +244,8 @@ test("clamp (PlainDateTime, before max)", () => {
month: 2,
day: 2,
hour: 1,
})
)
}),
),
).toBe(true);
});

Expand All @@ -263,7 +263,7 @@ test("clamp (PlainDateTime, after max)", () => {
month: 2,
day: 2,
hour: 2,
})
}),
);

expect(result instanceof Temporal.PlainDateTime).toBe(true);
Expand All @@ -275,7 +275,7 @@ test("clamp (PlainDateTime, after max)", () => {
month: 2,
day: 2,
hour: 2,
})
)
}),
),
).toBe(true);
});
Loading