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
6 changes: 2 additions & 4 deletions e2e/utils/compass-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ declare global {
interface Window {
__COMPASS_E2E_TEST__?: boolean;
__COMPASS_E2E_STORE__?: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
dispatch: (action: any) => any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getState: () => any;
dispatch: (action: unknown) => unknown;
getState: () => unknown;
};
__COMPASS_E2E_HOOKS__?: {
setAuthenticated: (value: boolean) => void;
Expand Down
29 changes: 14 additions & 15 deletions packages/backend/src/__tests__/helpers/mock.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function mockGoogleapis() {
function mockSuperTokens() {
const userMetadata = new Map<string, UserMetadata>();

function verifySession(input: {
function verifySession(_input: {
verifySessionOptions?: VerifySessionOptions;
options: APIOptions;
userContext: UserContext;
Expand Down Expand Up @@ -118,10 +118,6 @@ function mockSuperTokens() {
} as SessionContainerInterface;

return next?.();

if (input?.verifySessionOptions?.sessionRequired) {
throw new Error("invalid superToken session");
}
} catch (error) {
if (next) {
next(error);
Expand All @@ -146,12 +142,12 @@ function mockSuperTokens() {
data: Partial<UserMetadata>,
): Promise<{ status: "OK"; metadata: UserMetadata }> {
const existingMetadata = userMetadata.get(userId) ?? {};
const metadata = { ...existingMetadata, ...data };
userMetadata.set(userId, metadata);

return Promise.resolve({
status: "OK",
metadata: userMetadata
.set(userId, { ...existingMetadata, ...data })
.get(userId)!,
metadata,
});
}

Expand Down Expand Up @@ -320,13 +316,16 @@ export function mockEnv(env: Partial<typeof ENV>) {
[keyof typeof env, (typeof env)[keyof typeof env]]
>;

return entries.reduce(
(newEnv, [key, value]) => ({
...newEnv,
[key]: jest.replaceProperty(ENV, key, value),
}),
{} as Record<keyof typeof env, jest.ReplaceProperty<keyof typeof env>>,
);
const newEnv = {} as Record<
keyof typeof env,
jest.ReplaceProperty<keyof typeof env>
>;

for (const [key, value] of entries) {
newEnv[key] = jest.replaceProperty(ENV, key, value);
}

return newEnv;
}

export function mockNodeModules() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { GcalEventRRule } from "@backend/event/classes/gcal.event.rrule";
* @returns A random base32 hex string
*/
export const generateGcalId = (length: number = 16) => {
const allowed = "abcdefghijklmnopqrstuvwxyz".slice(0, 22) + "0123456789"; // a-v and 0-9
const allowed = `${"abcdefghijklmnopqrstuvwxyz".slice(0, 22)}0123456789`; // a-v and 0-9
let id = "";
for (let i = 0; i < length; i++) {
id += allowed.charAt(Math.floor(Math.random() * allowed.length));
Expand Down Expand Up @@ -51,7 +51,7 @@ const mockGcalCoreEvent = (): WithGcalId<
htmlLink: `https://www.google.com/calendar/event?eid=${id}`,
created: faker.date.past().toISOString(),
updated: faker.date.recent().toISOString(),
iCalUID: faker.string.uuid() + "@google.com",
iCalUID: `${faker.string.uuid()}@google.com`,
sequence: 0,
extendedProperties: {
private: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
type MethodOptions,
type StreamMethodOptions,
} from "@googleapis/calendar";
import { type GaxiosPromise, type GaxiosResponse } from "gaxios";
import {
type GaxiosOptions,
type GaxiosPromise,
type GaxiosResponse,
} from "gaxios";
import { Status } from "@core/errors/status.codes";
import {
type gSchema$CalendarList,
Expand Down Expand Up @@ -39,7 +43,7 @@ const createMockGaxiosResponse = <T>(
const url = responseURL || (config.url?.toString() ?? "");

return {
config: config as any,
config: config as GaxiosOptions,
data,
status,
statusText,
Expand All @@ -62,7 +66,7 @@ const createMockGaxiosResponse = <T>(
formData: async () => {
throw new Error("Not implemented");
},
json: async () => data as any,
json: async () => data,
text: async () => JSON.stringify(data),
bytes: async () => {
throw new Error("Not implemented");
Expand All @@ -85,7 +89,7 @@ const generatePaginatedGcalItems = <Item = gSchema$Event>(
pageSize: number,
pageToken?: string,
): Omit<gSchema$Events, "items"> & { items: Item[] } => {
const startIndex = pageToken ? parseInt(pageToken) : 0;
const startIndex = pageToken ? parseInt(pageToken, 10) : 0;
const endIndex = startIndex + pageSize;
const pageEvents = items.slice(startIndex, endIndex);
const hasMore = endIndex < items.length;
Expand Down Expand Up @@ -166,7 +170,7 @@ export const mockGcal = ({
options,
200,
"OK",
params.requestBody!.id!,
id,
),
);
},
Expand Down Expand Up @@ -210,13 +214,17 @@ export const mockGcal = ({
updatedEvent as WithGcalId<gSchema$Event>,
);

if (!updatedEvent.id) {
throw new Error(`Event with id ${eventId} is missing an id`);
}

return Promise.resolve(
createMockGaxiosResponse(
updatedEvent,
options,
200,
"OK",
updatedEvent.id!,
updatedEvent.id,
),
);
},
Expand Down Expand Up @@ -295,7 +303,11 @@ export const mockGcal = ({
throw new Error(`Event with id ${eventId} not found`);
}

const event = events[eventIndex]!;
const event = events[eventIndex];

if (!event) {
throw new Error(`Event with id ${eventId} not found`);
}
const isRecurring = isBaseGCalEvent(event);

events.splice(eventIndex, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe("CalendarService", () => {
updatedCalendarList.forEach((c) => {
const toggled = toggledCalendars.find(({ _id }) => c._id.equals(_id));

expect(c.selected).toBe(toggled ? false : true);
expect(c.selected).toBe(!toggled);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type IncomingMessage, type ServerResponse } from "http";
import morgan from "morgan";
import { type IncomingMessage, type ServerResponse } from "node:http";
import { styleText } from "node:util";

type HttpLogColor = "cyanBright" | "yellow" | "red" | "magentaBright";
Expand Down Expand Up @@ -54,7 +54,7 @@ export const httpLoggingMiddleware = morgan((tokens, req, res) => {
styleText(["bold", statusColor], status),
styleText(["bold", "whiteBright"], get("method", tokens, req, res)),
styleText(["bold", "cyanBright"], get("url", tokens, req, res)),
styleText(["bold", "blueBright"], responseTime + "ms"),
styleText(["bold", "blueBright"], `${responseTime}ms`),
styleText(["bold", "magentaBright"], get("date", tokens, req, res)),
].join(" ");
});
2 changes: 1 addition & 1 deletion packages/backend/src/common/services/gcal/gcal.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const categorizeGcalEvents = (events: gSchema$Event[]) => {
export const getEmailFromUrl = (url: string) => {
const emailMatch = url.match(/\/calendars\/([^/]+)\/events/);

if (emailMatch && emailMatch[1]) {
if (emailMatch?.[1]) {
try {
return decodeURIComponent(emailMatch[1]);
} catch {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/event/services/event.service.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getDeleteByIdFilter = (
return { ...filter, _id };
}

if (!event.recurrence || !event.recurrence.eventId) {
if (!event.recurrence?.eventId) {
throw error(
GenericError.DeveloperError,
"Failed to get Delete Filter (missing recurrence id)",
Expand Down
8 changes: 1 addition & 7 deletions packages/backend/src/event/services/recur/util/recur.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ export const assembleInstances = (
event: Schema_Event_Core,
baseId?: string,
) => {
if (
!event.recurrence ||
!event.recurrence.rule ||
!event.recurrence.rule[0]
) {
if (!event.recurrence?.rule?.[0]) {
throw error(
GenericError.DeveloperError,
"Failed to assemble recurring events",
Expand Down Expand Up @@ -252,10 +248,8 @@ const _getNextStart = (rule: string, startDate: string, endDate: string) => {
switch (rule) {
case RRULE.WEEK:
return dayjs(startDate).startOfNextWeek();
break;
case RRULE.MONTH:
return dayjs(endDate).startOfNextMonth();
break;
default:
throw error(GenericError.DeveloperError, "Failed to get next start");
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/init.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// sort-imports-ignore

import path from "path";
import { createRequire } from "node:module";
import path from "node:path";

type AliasApi = {
addAliases(aliases: Record<string, string>): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("categorizeGcalEvents", () => {

// should be array of string numbers
expect(typeof toDelete[1]).toBe("string");
const parsedToInt = parseInt(toDelete[1] ?? "");
const parsedToInt = parseInt(toDelete[1] ?? "", 10);
expect(typeof parsedToInt).toBe("number");
});
it("finds deleted/cancelled events", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/sync/services/log/sync.logger.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from "fs";
import path from "path";
import { type Schema_Event_Core } from "@core/types/event.types";
import { type gSchema$Event } from "@core/types/gcal";
import dayjs from "@core/util/date/dayjs";
import fs from "node:fs";
import path from "node:path";

interface SyncLogData {
updatedEvents: gSchema$Event[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ export const updateBasePayloadToExpireOneDayAfterFirstInstance = (
);
const untilDate = new Date(firstInstanceStart);
untilDate.setDate(untilDate.getDate() + 1);
const untilDateStr =
untilDate.toISOString().replace(/[-:]/g, "").split(".")[0] + "Z";
const untilDateStr = `${untilDate.toISOString().replace(/[-:]/g, "").split(".")[0]}Z`;

const gBaseWithUntil = {
...gEvents.recurring,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe("GcalSyncProcessor UPSERT: BASE", () => {
/* Act */
const updatedGcalBase = {
...gcalEvents.recurring,
summary: gcalEvents.recurring.summary + " - UPDATED IN GCAL",
summary: `${gcalEvents.recurring.summary} - UPDATED IN GCAL`,
description: "Description adjusted in Gcal",
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("GcalSyncProcessor UPSERT: INSTANCE", () => {

const instance = {
...origInstance,
summary: origTitle + " - Changed in GCal",
summary: `${origTitle} - Changed in GCal`,
};

const instanceTitle = instance.summary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("GcalSyncProcessor UPSERT: STANDALONE", () => {
const origStandalone = gcalEvents.regular;
const updatedStandalone = {
...origStandalone,
summary: origStandalone.summary + " - Changed in GCal",
summary: `${origStandalone.summary} - Changed in GCal`,
};

const origEventsCount = (await getEventsInDb({ user: user._id.toString() }))
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/util/date/dayjs-compass.plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe("monthStrFromZeroIndex", () => {
for (let index = -5; index < 20; index++) {
const validIndex = index >= 0 && index <= 11;
const month = dayjs.monthStrFromZeroIndex(index);
const intMonth = parseInt(month);
const intMonth = parseInt(month, 10);

if (validIndex) expect(intMonth).toStrictEqual(index + 1);

Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/src/commands/build.backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from "@scripts/common/cli.constants";
import { getEnvironmentAnswer, log } from "@scripts/common/cli.utils";
import { $ } from "bun";
import path from "path";
import path from "node:path";

const BACKEND_BUILD = path.join(COMPASS_BUILD_DEV, "backend");

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/common/hooks/useFloatingAtCursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from "@web/common/hooks/useOpenAtCursor";
import { theme } from "@web/common/styles/theme";

const themeSpacing = parseInt(theme.spacing.xs);
const themeSpacing = parseInt(theme.spacing.xs, 10);

const placements: Placement[] = [
"right-start",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/common/utils/datetime/web.date.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const getWeekRangeLabel = (weekStart: Dayjs, weekEnd: Dayjs) => {
const isSameMonth = weekStart.month() === weekEnd.month();
const start = weekStart.format("M.D");
const end = weekEnd.format(isSameMonth ? "D" : "M.D");
const label = start + " - " + end;
const label = `${start} - ${end}`;
return label;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const maxGridZIndex$ = new BehaviorSubject<number>(0);

const borderRingSpace = 2;
const fullWidthFactorThreshold = 1.75;
const themeSpacing = parseInt(theme.spacing.s);
const themeSpacing = parseInt(theme.spacing.s, 10);
const canvas = document.createElement("canvas");
const canvasContext = canvas.getContext("2d");
const selector = `.${CLASS_TIMED_CALENDAR_EVENT}`;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/common/utils/overlap/overlap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const getOverlappingStyles = (
const totalEventsInGroup = event.position.totalEventsInGroup ?? 1;
const order = event.position.horizontalOrder ?? 0;
const index = (totalEventsInGroup ?? 1) - order;
const themeSpacing = parseInt(theme.spacing.s);
const themeSpacing = parseInt(theme.spacing.s, 10);
const spacing = themeSpacing * 3;
const maxWidthDivisor = isOverlapping ? 2 : 1;
const maxContainerWidth = gridWidth - themeSpacing;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/ducks/events/selectors/event.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const selectAllDayEvents = createSelector(
(_id: string) => entities[_id],
);
const _allDayEvents: Schema_GridEvent_NoPosition[] = weekEvents?.filter(
(e: Schema_Event) => e !== undefined && e.isAllDay,
(e: Schema_Event) => e?.isAllDay,
);
const { allDayEvents } = assignEventsToRow(_allDayEvents);
return allDayEvents;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/ducks/events/slices/event.slice.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const cancel = (
action: Action_DeleteEvent,
): void => {
// Handle case where state.value or state.value.data might be undefined/null
if (!state.value || !state.value.data) {
if (!state.value?.data) {
// If state is not initialized, there's nothing to delete
return;
}
Expand Down
Loading
Loading