fix(lint): address 4 oxlint errors on canonical-layer-pr2
- Remove unused filterNewResults import (events batch-add-results legacy path was removed in Phase 4 Task 4). - Replace import() type annotation in sync-tournament-results test with a top-level type import (consistent-type-imports rule). - Hoist tableName helper out of makeFakeDb closure so it's not recreated per call (consistent-function-scoping rule). - eqeqeq: replace `!= null` with explicit null/undefined checks in tournament-identity. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
b2bb13573c
commit
1ecad47ce6
3 changed files with 16 additions and 17 deletions
|
|
@ -33,7 +33,7 @@ export function extractTournamentIdentity(ev: ScoringEventIdentityInput): Tourna
|
||||||
cleanName = trimmed.replace(YEAR_SUFFIX, "").trim();
|
cleanName = trimmed.replace(YEAR_SUFFIX, "").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (year === null && ev.eventDate != null) {
|
if (year === null && ev.eventDate !== null && ev.eventDate !== undefined) {
|
||||||
const iso = ev.eventDate instanceof Date
|
const iso = ev.eventDate instanceof Date
|
||||||
? ev.eventDate.toISOString()
|
? ev.eventDate.toISOString()
|
||||||
: String(ev.eventDate);
|
: String(ev.eventDate);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import {
|
||||||
type CreateEventResultData,
|
type CreateEventResultData,
|
||||||
type UpdateEventResultData,
|
type UpdateEventResultData,
|
||||||
} from "~/models/event-result";
|
} from "~/models/event-result";
|
||||||
import { filterNewResults, findParticipantsWithoutResults } from "./admin.sports-seasons.$id.events.$eventId.helpers";
|
import { findParticipantsWithoutResults } from "./admin.sports-seasons.$id.events.$eventId.helpers";
|
||||||
import { findParticipantResultsBySportsSeasonId } from "~/models/participant-result";
|
import { findParticipantResultsBySportsSeasonId } from "~/models/participant-result";
|
||||||
import {
|
import {
|
||||||
upsertParticipantSeasonResult,
|
upsertParticipantSeasonResult,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||||
|
import type * as DrizzleOrm from "drizzle-orm";
|
||||||
|
|
||||||
vi.mock("~/database/context", () => ({
|
vi.mock("~/database/context", () => ({
|
||||||
database: vi.fn(),
|
database: vi.fn(),
|
||||||
|
|
@ -78,6 +79,18 @@ interface FakeDbState {
|
||||||
* The service passes schema.tournamentResults etc., so we capture the real
|
* The service passes schema.tournamentResults etc., so we capture the real
|
||||||
* schema module and compare by ref.
|
* schema module and compare by ref.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
function tableName(table: any): string {
|
||||||
|
// drizzle-orm PgTable exposes the table name under a symbol. Try a few.
|
||||||
|
const sym = Object.getOwnPropertySymbols(table).find(
|
||||||
|
(s) => s.toString() === "Symbol(drizzle:Name)"
|
||||||
|
);
|
||||||
|
if (sym) return table[sym];
|
||||||
|
// Fallback for our shim: read `.tableName` property if set.
|
||||||
|
return table.tableName;
|
||||||
|
}
|
||||||
|
|
||||||
function makeFakeDb(state: FakeDbState) {
|
function makeFakeDb(state: FakeDbState) {
|
||||||
// We mirror the shape in a lazy way: each predicate function is stored on the
|
// We mirror the shape in a lazy way: each predicate function is stored on the
|
||||||
// call so we can match rows. In practice the service only filters by simple
|
// call so we can match rows. In practice the service only filters by simple
|
||||||
|
|
@ -90,9 +103,6 @@ function makeFakeDb(state: FakeDbState) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function rowsFor(table: any): any[] {
|
function rowsFor(table: any): any[] {
|
||||||
// Table objects are drizzle PgTable objects; we identify them by name.
|
// Table objects are drizzle PgTable objects; we identify them by name.
|
||||||
// drizzle PgTables expose `[Symbol.for("drizzle:Name")]` but simpler: we
|
|
||||||
// just check a known property. Schema tables have `._.name`.
|
|
||||||
// Fallback: we compare string representation.
|
|
||||||
const name = tableName(table);
|
const name = tableName(table);
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "tournament_results":
|
case "tournament_results":
|
||||||
|
|
@ -108,17 +118,6 @@ function makeFakeDb(state: FakeDbState) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
function tableName(table: any): string {
|
|
||||||
// drizzle-orm PgTable exposes the table name under a symbol. Try a few.
|
|
||||||
const sym = Object.getOwnPropertySymbols(table).find(
|
|
||||||
(s) => s.toString() === "Symbol(drizzle:Name)"
|
|
||||||
);
|
|
||||||
if (sym) return table[sym];
|
|
||||||
// Fallback for our shim: read `.tableName` property if set.
|
|
||||||
return table.tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
const db = {
|
const db = {
|
||||||
// ---------- select ----------
|
// ---------- select ----------
|
||||||
select: vi.fn().mockImplementation(() => {
|
select: vi.fn().mockImplementation(() => {
|
||||||
|
|
@ -208,7 +207,7 @@ function makeFakeDb(state: FakeDbState) {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
vi.mock("drizzle-orm", async () => {
|
vi.mock("drizzle-orm", async () => {
|
||||||
const actual = await vi.importActual<typeof import("drizzle-orm")>("drizzle-orm");
|
const actual = await vi.importActual<typeof DrizzleOrm>("drizzle-orm");
|
||||||
return {
|
return {
|
||||||
...actual,
|
...actual,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue