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
2 changes: 1 addition & 1 deletion backend/__tests__/__integration__/dal/result.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function createDummyData(
charStats: [0, 0, 0, 0],
acc: 0,
mode: "time",
mode2: "10" as never,
mode2: "10",
quoteLength: 1,
timestamp,
restartCount: 0,
Expand Down
2 changes: 1 addition & 1 deletion backend/__tests__/__integration__/dal/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ describe("UserDal", () => {
maxLength: 50,
lastResultTimestamp: 0,
hourOffset: -1,
} as any,
},
xp: 42,
inventory: {
badges: [{ id: 23 }, { id: 5 }],
Expand Down
2 changes: 1 addition & 1 deletion backend/__tests__/api/controllers/quotes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe("QuotesController", () => {

beforeEach(() => {
addQuoteMock.mockClear();
addQuoteMock.mockResolvedValue({} as any);
addQuoteMock.mockResolvedValue({});

verifyCaptchaMock.mockClear();
verifyCaptchaMock.mockResolvedValue(true);
Expand Down
3 changes: 1 addition & 2 deletions backend/__tests__/api/controllers/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import GeorgeQueue from "../../../src/queues/george-queue";
import * as DiscordUtils from "../../../src/utils/discord";
import * as Captcha from "../../../src/utils/captcha";
import * as FirebaseAdmin from "../../../src/init/firebase-admin";
import { FirebaseError } from "firebase-admin";
import * as ApeKeysDal from "../../../src/dal/ape-keys";
import * as LogDal from "../../../src/dal/logs";
import { ObjectId } from "mongodb";
Expand Down Expand Up @@ -1439,7 +1438,7 @@ describe("user controller test", () => {
});
it("should fail for unknown error", async () => {
//GIVEN
authUpdateEmailMock.mockRejectedValue({} as FirebaseError);
authUpdateEmailMock.mockRejectedValue({});

//WHEN
await mockApp
Expand Down
2 changes: 1 addition & 1 deletion backend/__tests__/middlewares/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("middlewares/auth", () => {
throw error;
}
return "Next function called";
}) as unknown as NextFunction;
});
});

afterEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
"@vitest/coverage-v8": "4.1.5",
"concurrently": "8.2.2",
"openapi3-ts": "2.0.2",
"oxlint": "1.68.0",
"oxlint-tsgolint": "0.23.0",
"oxlint": "1.73.0",
"oxlint-tsgolint": "0.24.0",
"readline-sync": "1.4.10",
"supertest": "7.1.4",
"testcontainers": "11.11.0",
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/controllers/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function createResult(
charStats: [131, 0, 0, 0],
acc: random(80, 100),
language: "english",
mode: mode as Mode,
mode: mode,
mode2: mode2 as unknown as never,
timestamp: timestamp.valueOf(),
testDuration: testDuration,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ function getRelevantUserInfo(user: UserDAL.DBUser): RelevantUserInfo {
"ips",
"testActivity",
"suspicious",
]) as RelevantUserInfo;
]);
}

export async function getUser(req: MonkeyRequest): Promise<GetUserResponse> {
Expand Down
5 changes: 1 addition & 4 deletions backend/src/api/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { getLiveConfiguration } from "../../init/configuration";
import Logger from "../../utils/logger";
import { createExpressEndpoints, initServer } from "@ts-rest/express";
import { ZodIssue } from "zod";
import { MonkeyValidationError } from "@monkeytype/contracts/util/api";
import { authenticateTsRestRequest } from "../../middlewares/auth";
import { rateLimitRequest } from "../../middlewares/rate-limit";
import { verifyPermissions } from "../../middlewares/permission";
Expand Down Expand Up @@ -111,9 +110,7 @@ function applyTsRestApiRoutes(app: IRouter): void {
return;
}

res
.status(422)
.json({ message, validationErrors } as MonkeyValidationError);
res.status(422).json({ message, validationErrors });
},
globalMiddleware: [
authenticateTsRestRequest(),
Expand Down
6 changes: 3 additions & 3 deletions frontend/__tests__/components/common/AnimatedModal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { render } from "@solidjs/testing-library";
import { describe, it, expect, vi, beforeEach } from "vitest";

import { AnimatedModal } from "../../../src/ts/components/common/AnimatedModal";
import { hideModal, ModalId, showModal } from "../../../src/ts/states/modals";
import { hideModal, showModal } from "../../../src/ts/states/modals";

describe("AnimatedModal", () => {
beforeEach(() => {
showModal("Support" as ModalId);
showModal("Support");
vi.clearAllMocks();

// Mock dialog methods that don't exist in jsdom
Expand Down Expand Up @@ -60,7 +60,7 @@ describe("AnimatedModal", () => {
});

it("doesnt render children if not open", () => {
hideModal("Support" as ModalId);
hideModal("Support");
const { modalDiv } = renderModal({});

expect(modalDiv).not.toBeInTheDocument();
Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/controllers/preset-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe("PresetController", () => {
...partialPreset,
} as any;
dbGetSnapshotMock.mockReturnValue({} as any);
getPresetMock.mockReturnValue(preset as any);
getPresetMock.mockReturnValue(preset);
return preset;
};
});
Expand Down
6 changes: 3 additions & 3 deletions frontend/__tests__/test/events/data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ describe("data.ts", () => {
// simulate forceReleaseAllKeys passing indexed codes directly
logTestEvent("keyup", 1030, {
code: "NoCode0",
} as KeyupEventData);
});
logTestEvent("keyup", 1040, {
code: "NoCode1",
} as KeyupEventData);
});

const events = getAllTestEvents();
expect(events).toHaveLength(4);
Expand All @@ -239,7 +239,7 @@ describe("data.ts", () => {
it("rejects indexed NoCode keyup with no matching keydown", () => {
logTestEvent("keyup", 1010, {
code: "NoCode0",
} as KeyupEventData);
});

expect(getAllTestEvents()).toHaveLength(0);
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/__tests__/test/events/stats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ describe("stats.ts", () => {
charIndex: 3,
inputType: "deleteWordBackward",
inputValue: "=",
} as InputEventData);
});

// second Ctrl+Backspace: Firefox ate sentinel + "=" → goToPreviousWord;
// clearedNextWord marks word 1 (= wordIndex + 1) as abandoned
Expand All @@ -854,7 +854,7 @@ describe("stats.ts", () => {
inputType: "deleteWordBackward",
inputValue: "",
clearedNextWord: true,
} as InputEventData);
});

logTestEvent("timer", 5000, timer("end", 4));

Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
"madge": "8.0.0",
"magic-string": "0.30.17",
"normalize.css": "8.0.1",
"oxlint": "1.68.0",
"oxlint-tsgolint": "0.23.0",
"oxlint": "1.73.0",
"oxlint-tsgolint": "0.24.0",
"postcss": "8.5.15",
"sass": "1.70.0",
"solid-devtools": "0.34.5",
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/ts/collections/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ const inboxCollection = createCollection(
queryFn: async () => {
const addStatus = (item: MonkeyMail): InboxItem => ({
...item,
status: (item.rewards.length > 0 && !item.read
? "unclaimed"
: item.read
? "read"
: "unread") as InboxItem["status"],
status:
item.rewards.length > 0 && !item.read
? "unclaimed"
: item.read
? "read"
: "unread",
});

const response = await Ape.users.getInbox();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/commandline/commandline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ async function showCommands(): Promise<void> {
}
}

return { ...command, isActive } as CommandWithIsActive;
return { ...command, isActive };
});

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function NotificationItem(props: { notification: Notification }): JSXElement {
icon: `fa-${props.notification.customIcon}`,
fixedWidth: true,
} as FaProps)
: ({ icon: config().icon } as FaProps);
: { icon: config().icon };

const title = (): string => props.notification.customTitle ?? config().title;

Expand Down
6 changes: 4 additions & 2 deletions frontend/src/ts/components/modals/QuoteSubmitModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ export function QuoteSubmitModal(): JSXElement {
text: g.replace(/_/g, " "),
}));

const language = removeLanguageSize(Config.language) as string;

const form = createForm(() => ({
defaultValues: {
text: "",
source: "",
language: removeLanguageSize(Config.language) as string,
language,
captcha: "",
},
onSubmit: async ({ value }) => {
Expand Down Expand Up @@ -76,7 +78,7 @@ export function QuoteSubmitModal(): JSXElement {
defaultValues: {
text: "",
source: "",
language: removeLanguageSize(Config.language) as string,
language: removeLanguageSize(Config.language),
captcha: "",
},
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ts/components/modals/SimpleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ function getValidators(
// oxlint-disable-next-line typescript/no-unsafe-argument
validators.onChange = fromSchema(schema, {
convert,
}) as SyncValidator;
});
} else if (required) {
validators.onChange = fieldMandatory() as SyncValidator;
validators.onChange = fieldMandatory();
}

if (isValid !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function CustomBackground(): JSXElement {
accept="image/*"
class="hidden"
onChange={async (e) => {
const fileInput = e.target as HTMLInputElement;
const fileInput = e.target;
const file = fileInput.files?.[0];

if (!file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function FontFamily(): JSXElement {
accept="font/woff,font/woff2,font/ttf,font/otf"
class="hidden"
onChange={async (e) => {
const fileInput = e.target as HTMLInputElement;
const fileInput = e.target;
const file = fileInput.files?.[0];

if (!file) {
Expand Down Expand Up @@ -126,10 +126,7 @@ export function FontFamily(): JSXElement {
<div class="grid grid-cols-[repeat(auto-fit,minmax(13.5rem,1fr))] gap-2">
<For each={getOptions(ConfigSchema.shape.fontFamily)?.sort()}>
{(option) => {
const optionsMeta = configMetadata.fontFamily
.optionsMetadata as
| Record<string, { displayString?: string }>
| undefined;
const optionsMeta = configMetadata.fontFamily.optionsMetadata;
const match = optionsMeta?.[String(option)];
const displayString =
match?.displayString ?? String(option).replace(/_/g, " ");
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/ts/config/setters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ConfigSchemas from "@monkeytype/schemas/configs";
import { ZodType as ZodSchema } from "zod";
import { saveToLocalStorage } from "../config/persistence";
import { configMetadata, ConfigMetadataObject } from "./metadata";
import { configMetadata } from "./metadata";
import { isConfigValueValid } from "./validation";
import { configEvent } from "../events/config";
import { showNoticeNotification } from "../states/notifications";
Expand All @@ -24,7 +24,7 @@ export function setConfig<T extends keyof ConfigSchemas.Config>(
partOfFullConfigChange?: boolean;
},
): boolean {
const metadata = configMetadata[key] as ConfigMetadataObject[T];
const metadata = configMetadata[key];
if (metadata === undefined) {
throw new Error(`Config metadata for key "${key}" is not defined.`);
}
Expand Down Expand Up @@ -129,7 +129,7 @@ export function setConfig<T extends keyof ConfigSchemas.Config>(
key: key,
newValue: value,
nosave: options?.nosave ?? false,
previousValue: previousValue as ConfigSchemas.Config[T],
previousValue: previousValue,
});

if (!options?.partOfFullConfigChange) {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/ts/config/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
Config as ConfigSchema,
ConfigValue,
FunboxName,
PartialConfig,
} from "@monkeytype/schemas/configs";
Expand All @@ -22,7 +21,7 @@ function mergeWithDefaultConfig(config: PartialConfig): ConfigSchema {
const defaultConfig = getDefaultConfig();
const mergedConfig = {} as ConfigSchema;
for (const key of typedKeys(defaultConfig)) {
const newValue = config[key] ?? (defaultConfig[key] as ConfigValue);
const newValue = config[key] ?? defaultConfig[key];
//@ts-expect-error cant be bothered to deal with this
mergedConfig[key] = newValue;
}
Expand Down
11 changes: 4 additions & 7 deletions frontend/src/ts/constants/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2327,10 +2327,7 @@ export const themes: Record<ThemeName, Theme> = {
export type ThemeWithName = Theme & { name: ThemeName };
export const ThemesList: ThemeWithName[] = Object.keys(themes)
.sort()
.map(
(it) =>
({
...themes[it as ThemeName],
name: it as ThemeName,
}) as Theme & { name: ThemeName },
);
.map((it) => ({
...themes[it as ThemeName],
name: it as ThemeName,
}));
2 changes: 1 addition & 1 deletion frontend/src/ts/controllers/badge-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function getHTMLById(
noBalloon = false,
showUnknown = false,
): string {
const badge = badges[id] as UserBadge | undefined;
const badge = badges[id];

if (!badge && !showUnknown) {
return "";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/controllers/quotes-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const quoteController = new QuotesController();

configEvent.subscribe(({ key, newValue }) => {
if (key === "quoteLength") {
quoteController.updateQuoteQueue(newValue as number[]);
quoteController.updateQuoteQueue(newValue);
}
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/controllers/sound-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ function extractScaleSounds(
{
preview: createPreviewScale(config.validNotes),
meta: { ...defaultScaleData },
} as ScaleMeta,
},
];
}),
);
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/ts/controllers/theme-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@ export async function randomizeTheme(): Promise<void> {
let colorsOverride: CustomThemeColors | undefined;

if (Config.randomTheme === "custom") {
const theme = CustomThemes.__nonReactive.getCustomTheme(
randomTheme as string,
);
const theme = CustomThemes.__nonReactive.getCustomTheme(randomTheme);
colorsOverride = theme?.colors;
randomTheme = "custom";
}
Expand All @@ -231,8 +229,7 @@ export async function randomizeTheme(): Promise<void> {
let name = randomTheme.replace(/_/g, " ");
if (Config.randomTheme === "custom") {
name = (
CustomThemes.__nonReactive.getCustomTheme(randomTheme as string)
?.name ?? "custom"
CustomThemes.__nonReactive.getCustomTheme(randomTheme)?.name ?? "custom"
).replace(/_/g, " ");
}
showNoticeNotification(name);
Expand Down
Loading
Loading