Fix oxlint warnings, extract dialog polyfill, deny warnings in gate
All checks were successful
CI / check (push) Successful in 1m38s
CI / build-image (push) Has been skipped

Adds void to floating promise in bestiary-cache.ts, extracts shared
polyfillDialog() helper to eliminate unbound-method warnings in 3 test
files. Adds --deny warnings to oxlint so future warnings fail the
build.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-29 22:38:57 +02:00
parent c295840b7b
commit b6ee4c8c86
7 changed files with 26 additions and 34 deletions

View File

@@ -0,0 +1,16 @@
/**
* jsdom doesn't implement HTMLDialogElement.showModal/close.
* Call this in beforeAll() for tests that render <Dialog>.
*/
export function polyfillDialog(): void {
if (typeof HTMLDialogElement.prototype.showModal !== "function") {
HTMLDialogElement.prototype.showModal = function showModal() {
this.setAttribute("open", "");
};
}
if (typeof HTMLDialogElement.prototype.close !== "function") {
HTMLDialogElement.prototype.close = function close() {
this.removeAttribute("open");
};
}
}

View File

@@ -40,7 +40,7 @@ async function getDb(): Promise<IDBPDatabase | null> {
} }
if (oldVersion < 2 && database.objectStoreNames.contains(STORE_NAME)) { if (oldVersion < 2 && database.objectStoreNames.contains(STORE_NAME)) {
// Clear cached creatures to pick up improved tag processing // Clear cached creatures to pick up improved tag processing
transaction.objectStore(STORE_NAME).clear(); void transaction.objectStore(STORE_NAME).clear();
} }
}, },
}); });

View File

@@ -4,6 +4,7 @@ import "@testing-library/jest-dom/vitest";
import { cleanup, render, screen } from "@testing-library/react"; import { cleanup, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event"; import userEvent from "@testing-library/user-event";
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import { polyfillDialog } from "../../__tests__/polyfill-dialog.js";
import { AllProviders } from "../../__tests__/test-providers.js"; import { AllProviders } from "../../__tests__/test-providers.js";
import { ActionBar } from "../action-bar.js"; import { ActionBar } from "../action-bar.js";
@@ -50,16 +51,7 @@ beforeAll(() => {
dispatchEvent: vi.fn(), dispatchEvent: vi.fn(),
})), })),
}); });
HTMLDialogElement.prototype.showModal = polyfillDialog();
HTMLDialogElement.prototype.showModal ||
function showModal(this: HTMLDialogElement) {
this.setAttribute("open", "");
};
HTMLDialogElement.prototype.close =
HTMLDialogElement.prototype.close ||
function close(this: HTMLDialogElement) {
this.removeAttribute("open");
};
}); });
afterEach(cleanup); afterEach(cleanup);

View File

@@ -4,19 +4,11 @@ import { playerCharacterId } from "@initiative/domain";
import { cleanup, render, screen } from "@testing-library/react"; import { cleanup, render, screen } from "@testing-library/react";
import { userEvent } from "@testing-library/user-event"; import { userEvent } from "@testing-library/user-event";
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import { polyfillDialog } from "../../__tests__/polyfill-dialog.js";
import { CreatePlayerModal } from "../create-player-modal.js"; import { CreatePlayerModal } from "../create-player-modal.js";
beforeAll(() => { beforeAll(() => {
HTMLDialogElement.prototype.showModal = polyfillDialog();
HTMLDialogElement.prototype.showModal ||
function showModal(this: HTMLDialogElement) {
this.setAttribute("open", "");
};
HTMLDialogElement.prototype.close =
HTMLDialogElement.prototype.close ||
function close(this: HTMLDialogElement) {
this.removeAttribute("open");
};
}); });
afterEach(cleanup); afterEach(cleanup);

View File

@@ -2,19 +2,11 @@
import { cleanup, render, screen } from "@testing-library/react"; import { cleanup, render, screen } from "@testing-library/react";
import { userEvent } from "@testing-library/user-event"; import { userEvent } from "@testing-library/user-event";
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import { polyfillDialog } from "../../__tests__/polyfill-dialog.js";
import { Dialog, DialogHeader } from "../ui/dialog.js"; import { Dialog, DialogHeader } from "../ui/dialog.js";
beforeAll(() => { beforeAll(() => {
HTMLDialogElement.prototype.showModal = polyfillDialog();
HTMLDialogElement.prototype.showModal ||
function showModal(this: HTMLDialogElement) {
this.setAttribute("open", "");
};
HTMLDialogElement.prototype.close =
HTMLDialogElement.prototype.close ||
function close(this: HTMLDialogElement) {
this.removeAttribute("open");
};
}); });
afterEach(cleanup); afterEach(cleanup);

View File

@@ -24,6 +24,6 @@ pre-commit:
- name: typecheck - name: typecheck
run: pnpm exec tsc --build run: pnpm exec tsc --build
- name: oxlint - name: oxlint
run: pnpm oxlint run: pnpm oxlint -- --deny warnings
- name: test - name: test
run: pnpm test run: pnpm test

View File

@@ -31,10 +31,10 @@
"knip": "knip", "knip": "knip",
"jscpd": "jscpd", "jscpd": "jscpd",
"jsinspect": "jsinspect -c .jsinspectrc apps/web/src packages/domain/src packages/application/src", "jsinspect": "jsinspect -c .jsinspectrc apps/web/src packages/domain/src packages/application/src",
"oxlint": "oxlint --tsconfig apps/web/tsconfig.json --type-aware", "oxlint": "oxlint --tsconfig apps/web/tsconfig.json --type-aware --deny warnings",
"check:ignores": "node scripts/check-lint-ignores.mjs", "check:ignores": "node scripts/check-lint-ignores.mjs",
"check:classnames": "node scripts/check-cn-classnames.mjs", "check:classnames": "node scripts/check-cn-classnames.mjs",
"check:props": "node scripts/check-component-props.mjs", "check:props": "node scripts/check-component-props.mjs",
"check": "pnpm audit --audit-level=high && knip && biome check . && node scripts/check-lint-ignores.mjs && node scripts/check-cn-classnames.mjs && node scripts/check-component-props.mjs && jscpd && pnpm jsinspect && tsc --build && oxlint --tsconfig apps/web/tsconfig.json --type-aware && vitest run" "check": "pnpm audit --audit-level=high && knip && biome check . && node scripts/check-lint-ignores.mjs && node scripts/check-cn-classnames.mjs && node scripts/check-component-props.mjs && jscpd && pnpm jsinspect && tsc --build && oxlint --tsconfig apps/web/tsconfig.json --type-aware --deny warnings && vitest run"
} }
} }