diff --git a/client/index.ts b/client/index.ts index 82c31720..26ade6e9 100644 --- a/client/index.ts +++ b/client/index.ts @@ -1,40 +1,40 @@ import { type Socket, io } from "socket.io-client"; -import type { Answer, Player } from "../server/@types/entities"; +import type { Answer, Player } from "../server/@types/entities.d.ts"; import type { ClientboundSocketServerEvents, ServerboundSocketServerEvents, -} from "../server/@types/events"; -import { addAdminModeListener } from "./utils/adminUtils"; -import type { NameFormElement } from "./utils/domManipulationUtils"; -import { renderBonusPoints } from "./utils/domManipulationUtils/bonusPoints"; -import { renderColourCheckboxes } from "./utils/domManipulationUtils/colourCheckboxes"; +} from "../server/@types/events.d.ts"; +import { addAdminModeListener } from "./utils/adminUtils.ts"; +import { renderBonusPoints } from "./utils/domManipulationUtils/bonusPoints.ts"; +import { renderColourCheckboxes } from "./utils/domManipulationUtils/colourCheckboxes.ts"; import { renderConnectedIndicator, renderDisconnectedIndicator, -} from "./utils/domManipulationUtils/connectionStatus"; +} from "./utils/domManipulationUtils/connectionStatus.ts"; import { type CountdownOptions, derenderCountdown, renderCountdown, -} from "./utils/domManipulationUtils/countdown"; +} from "./utils/domManipulationUtils/countdown.ts"; +import type { NameFormElement } from "./utils/domManipulationUtils/index.ts"; import { renderPlayerList, renderPlayerListWithScores, -} from "./utils/domManipulationUtils/playerList"; +} from "./utils/domManipulationUtils/playerList.ts"; import { derenderPlayerNameForm, renderPlayerName, resetPlayerNameFormValue, -} from "./utils/domManipulationUtils/playerName"; -import { renderQuestion } from "./utils/domManipulationUtils/question"; -import { resetRound } from "./utils/domManipulationUtils/roundReset"; +} from "./utils/domManipulationUtils/playerName.ts"; +import { renderQuestion } from "./utils/domManipulationUtils/question.ts"; +import { resetRound } from "./utils/domManipulationUtils/roundReset.ts"; import { derenderStartButton, renderStartButton, -} from "./utils/domManipulationUtils/startButton"; -import { renderUnjoinableMessage } from "./utils/domManipulationUtils/unjoinableMessage"; -import { getElementById } from "./utils/getElementById"; -import { addPlayer, emitAnswersPost } from "./utils/socketUtils"; +} from "./utils/domManipulationUtils/startButton.ts"; +import { renderUnjoinableMessage } from "./utils/domManipulationUtils/unjoinableMessage.ts"; +import { getElementById } from "./utils/getElementById.ts"; +import { addPlayer, emitAnswersPost } from "./utils/socketUtils.ts"; const generateSocketUrl = (): string => { const location = window.location; diff --git a/client/utils/adminUtils.ts b/client/utils/adminUtils.ts index a91a963d..f64cc09d 100644 --- a/client/utils/adminUtils.ts +++ b/client/utils/adminUtils.ts @@ -1,4 +1,4 @@ -import { renderRoundResetButton } from "./domManipulationUtils/roundReset"; +import { renderRoundResetButton } from "./domManipulationUtils/roundReset.ts"; const konamiCode: KeyboardEvent["key"][] = [ "ArrowUp", diff --git a/client/utils/domManipulationUtils/answer.ts b/client/utils/domManipulationUtils/answer.ts index 61bec4b9..d06d7b68 100644 --- a/client/utils/domManipulationUtils/answer.ts +++ b/client/utils/domManipulationUtils/answer.ts @@ -1,7 +1,7 @@ -import { htmlElements } from "."; -import type { Answer, Colour } from "../../../server/@types/entities"; -import { getElementById } from "../getElementById"; -import { derenderColourCheckboxes } from "./colourCheckboxes"; +import type { Answer, Colour } from "../../../server/@types/entities.d.ts"; +import { getElementById } from "../getElementById.ts"; +import { derenderColourCheckboxes } from "./colourCheckboxes.ts"; +import { htmlElements } from "./index.ts"; const submitAnswer = async ( emitAnswersPostWrapper: (colours: Answer["colours"]) => void, diff --git a/client/utils/domManipulationUtils/bonusPoints.ts b/client/utils/domManipulationUtils/bonusPoints.ts index e68cb32a..ed918c51 100644 --- a/client/utils/domManipulationUtils/bonusPoints.ts +++ b/client/utils/domManipulationUtils/bonusPoints.ts @@ -1,5 +1,5 @@ -import { htmlElements } from "."; -import { getElementById } from "../getElementById"; +import { getElementById } from "../getElementById.ts"; +import { htmlElements } from "./index.ts"; const renderBonusPoints = (bonusPoints: number): void => { htmlElements.bonusPoints ||= diff --git a/client/utils/domManipulationUtils/colourCheckboxes.ts b/client/utils/domManipulationUtils/colourCheckboxes.ts index 43e12218..f2adaf7d 100644 --- a/client/utils/domManipulationUtils/colourCheckboxes.ts +++ b/client/utils/domManipulationUtils/colourCheckboxes.ts @@ -1,7 +1,7 @@ -import { htmlElements } from "."; -import type { Answer } from "../../../server/@types/entities"; -import { getElementById } from "../getElementById"; -import { submitAnswer } from "./answer"; +import type { Answer } from "../../../server/@types/entities.d.ts"; +import { getElementById } from "../getElementById.ts"; +import { submitAnswer } from "./answer.ts"; +import { htmlElements } from "./index.ts"; const renderColourCheckboxes = ( emitAnswersPostWrapper: (colours: Answer["colours"]) => void, diff --git a/client/utils/domManipulationUtils/connectionStatus.ts b/client/utils/domManipulationUtils/connectionStatus.ts index 0fdea269..99af9990 100644 --- a/client/utils/domManipulationUtils/connectionStatus.ts +++ b/client/utils/domManipulationUtils/connectionStatus.ts @@ -1,5 +1,5 @@ -import { htmlElements } from "."; -import { getElementById } from "../getElementById"; +import { getElementById } from "../getElementById.ts"; +import { htmlElements } from "./index.ts"; const renderConnectedIndicator = (): void => { htmlElements.connectionStatus ||= diff --git a/client/utils/domManipulationUtils/countdown.ts b/client/utils/domManipulationUtils/countdown.ts index 6c260eb3..2db8154a 100644 --- a/client/utils/domManipulationUtils/countdown.ts +++ b/client/utils/domManipulationUtils/countdown.ts @@ -1,5 +1,5 @@ -import { htmlElements } from "."; -import { getElementById } from "../getElementById"; +import { getElementById } from "../getElementById.ts"; +import { htmlElements } from "./index.ts"; type CountdownOptions = { durationMs: number; diff --git a/client/utils/domManipulationUtils/playerList.ts b/client/utils/domManipulationUtils/playerList.ts index 6df86165..be5ea3bc 100644 --- a/client/utils/domManipulationUtils/playerList.ts +++ b/client/utils/domManipulationUtils/playerList.ts @@ -1,6 +1,6 @@ -import { htmlElements } from "."; -import type { Player, PlayerScore } from "../../../server/@types/entities"; -import { getElementById } from "../getElementById"; +import type { Player, PlayerScore } from "../../../server/@types/entities.d.ts"; +import { getElementById } from "../getElementById.ts"; +import { htmlElements } from "./index.ts"; const renderPlayerList = (playerNames: Player["name"][]): void => { htmlElements.playerList ||= getElementById("player-list"); diff --git a/client/utils/domManipulationUtils/playerName.ts b/client/utils/domManipulationUtils/playerName.ts index 67546401..fe285ebc 100644 --- a/client/utils/domManipulationUtils/playerName.ts +++ b/client/utils/domManipulationUtils/playerName.ts @@ -1,6 +1,6 @@ -import { type NameFormElement, htmlElements } from "."; -import type { Player } from "../../../server/@types/entities"; -import { getElementById } from "../getElementById"; +import type { Player } from "../../../server/@types/entities.d.ts"; +import { getElementById } from "../getElementById.ts"; +import { type NameFormElement, htmlElements } from "./index.ts"; const renderPlayerName = (currentPlayer: Player): void => { htmlElements.playerName ||= getElementById("player-name"); diff --git a/client/utils/domManipulationUtils/question.ts b/client/utils/domManipulationUtils/question.ts index 86454c45..1831b43c 100644 --- a/client/utils/domManipulationUtils/question.ts +++ b/client/utils/domManipulationUtils/question.ts @@ -1,6 +1,6 @@ -import { htmlElements } from "."; -import type { Question } from "../../../server/@types/entities"; -import { getElementById } from "../getElementById"; +import type { Question } from "../../../server/@types/entities.d.ts"; +import { getElementById } from "../getElementById.ts"; +import { htmlElements } from "./index.ts"; const renderQuestion = (question: Question): void => { htmlElements.question ||= getElementById("question"); diff --git a/client/utils/domManipulationUtils/roundReset.ts b/client/utils/domManipulationUtils/roundReset.ts index 687f5db6..f34d24a1 100644 --- a/client/utils/domManipulationUtils/roundReset.ts +++ b/client/utils/domManipulationUtils/roundReset.ts @@ -1,7 +1,7 @@ -import { htmlElements } from "."; -import type { Player } from "../../../server/@types/entities"; -import { getElementById } from "../getElementById"; -import { renderStartButton } from "./startButton"; +import type { Player } from "../../../server/@types/entities.d.ts"; +import { getElementById } from "../getElementById.ts"; +import { htmlElements } from "./index.ts"; +import { renderStartButton } from "./startButton.ts"; const renderRoundResetButton = (): void => { htmlElements.roundResetButton ||= diff --git a/client/utils/domManipulationUtils/startButton.ts b/client/utils/domManipulationUtils/startButton.ts index fc35a672..2e54a094 100644 --- a/client/utils/domManipulationUtils/startButton.ts +++ b/client/utils/domManipulationUtils/startButton.ts @@ -1,5 +1,5 @@ -import { htmlElements } from "."; -import { getElementById } from "../getElementById"; +import { getElementById } from "../getElementById.ts"; +import { htmlElements } from "./index.ts"; const renderStartButton = (): void => { htmlElements.startButton ||= diff --git a/client/utils/domManipulationUtils/unjoinableMessage.ts b/client/utils/domManipulationUtils/unjoinableMessage.ts index c64dc39b..a3f1aeba 100644 --- a/client/utils/domManipulationUtils/unjoinableMessage.ts +++ b/client/utils/domManipulationUtils/unjoinableMessage.ts @@ -1,5 +1,5 @@ -import { type NameFormElement, htmlElements } from "."; -import { getElementById } from "../getElementById"; +import { getElementById } from "../getElementById.ts"; +import { type NameFormElement, htmlElements } from "./index.ts"; const renderUnjoinableMessage = (): void => { htmlElements.playerNameForm ||= getElementById("name-form"); diff --git a/client/utils/socketUtils.ts b/client/utils/socketUtils.ts index 2b534814..a25a889d 100644 --- a/client/utils/socketUtils.ts +++ b/client/utils/socketUtils.ts @@ -1,9 +1,9 @@ import type { Socket } from "socket.io-client"; -import type { Answer } from "../../server/@types/entities"; +import type { Answer } from "../../server/@types/entities.d.ts"; import type { ClientboundSocketServerEvents, ServerboundSocketServerEvents, -} from "../../server/@types/events"; +} from "../../server/@types/events.d.ts"; const addPlayer = ( socket: Socket, diff --git a/e2e/app.test.ts b/e2e/app.test.ts index 51be63ce..099ebdd8 100644 --- a/e2e/app.test.ts +++ b/e2e/app.test.ts @@ -1,6 +1,6 @@ import { type BrowserContext, type Page, expect, test } from "@playwright/test"; -import { konamiCode } from "../client/utils/adminUtils"; -import type { Colour, Player } from "../server/@types/entities"; +import { konamiCode } from "../client/utils/adminUtils.ts"; +import type { Colour, Player } from "../server/@types/entities.d.ts"; const joinedPlayerNames: Player["name"][] = []; let playersPages: Page[] = []; diff --git a/server/@types/events.d.ts b/server/@types/events.d.ts index a429c5d5..473e9766 100644 --- a/server/@types/events.d.ts +++ b/server/@types/events.d.ts @@ -1,5 +1,5 @@ -import type { CountdownOptions } from "../../client/utils/domManipulationUtils/countdown"; -import type { Colour, Player, PlayerScore, Question } from "./entities"; +import type { CountdownOptions } from "../../client/utils/domManipulationUtils/countdown.ts"; +import type { Colour, Player, PlayerScore, Question } from "./entities.d.ts"; export interface ClientboundSocketServerEvents { "answers:post": (playerId: string, colours: string[]) => void; diff --git a/server/index.ts b/server/index.ts index 225c517f..26fd3983 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,7 +1,7 @@ import http from "node:http"; import handler from "serve-handler"; -import { SocketServer } from "./socketServer"; -import { logWithTime } from "./utils/loggingUtils"; +import { SocketServer } from "./socketServer.ts"; +import { logWithTime } from "./utils/loggingUtils.ts"; const httpServer = http.createServer((request, response) => { return handler(request, response, { diff --git a/server/machines/lobby.test.ts b/server/machines/lobby.test.ts index 10604be6..959ea260 100644 --- a/server/machines/lobby.test.ts +++ b/server/machines/lobby.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect, it } from "bun:test"; import type { Actor } from "xstate"; import { createActor, getNextSnapshot } from "xstate"; -import { lobbyMachine } from "./lobby"; +import { lobbyMachine } from "./lobby.ts"; describe("lobbyMachine states", () => { const player1 = { name: "a name", socketId: "id" }; diff --git a/server/machines/lobby.ts b/server/machines/lobby.ts index e2c9ec1e..56002617 100644 --- a/server/machines/lobby.ts +++ b/server/machines/lobby.ts @@ -1,5 +1,5 @@ import { assign, setup } from "xstate"; -import type { Player } from "../@types/entities"; +import type { Player } from "../@types/entities.d.ts"; const context = { players: [] as Player[], diff --git a/server/machines/round.ts b/server/machines/round.ts index d55b80fc..9fee390f 100644 --- a/server/machines/round.ts +++ b/server/machines/round.ts @@ -1,7 +1,7 @@ import { assign, setup } from "xstate"; -import type { Player, PlayerScore, Question } from "../@types/entities"; +import type { Player, PlayerScore, Question } from "../@types/entities.d.ts"; import questions from "../data/questions.json"; -import type { getUpdatedPlayerScoresAndBonusPoints } from "../utils/scoringUtils"; +import type { getUpdatedPlayerScoresAndBonusPoints } from "../utils/scoringUtils.ts"; const context = { questions: questions as Question[], diff --git a/server/machines/turn.ts b/server/machines/turn.ts index cebe5c55..e7732f5a 100644 --- a/server/machines/turn.ts +++ b/server/machines/turn.ts @@ -1,6 +1,6 @@ import { assign, setup } from "xstate"; -import type { Answer, Player, Question } from "../@types/entities"; -import { getCorrectSocketIdsFromAnswers } from "../utils/scoringUtils"; +import type { Answer, Player, Question } from "../@types/entities.d.ts"; +import { getCorrectSocketIdsFromAnswers } from "../utils/scoringUtils.ts"; const context = { answers: [] as Answer[], diff --git a/server/models/lobby.ts b/server/models/lobby.ts index 8800c5b4..bc1e2a3d 100644 --- a/server/models/lobby.ts +++ b/server/models/lobby.ts @@ -1,9 +1,9 @@ import type { Socket } from "socket.io"; import { type Actor, createActor } from "xstate"; -import type { Player } from "../@types/entities"; -import { lobbyMachine } from "../machines/lobby"; -import type { SocketServer } from "../socketServer"; -import { machineLogger } from "../utils/loggingUtils"; +import type { Player } from "../@types/entities.d.ts"; +import { lobbyMachine } from "../machines/lobby.ts"; +import type { SocketServer } from "../socketServer.ts"; +import { machineLogger } from "../utils/loggingUtils.ts"; class Lobby { machine: Actor; diff --git a/server/models/round.ts b/server/models/round.ts index 342d09e5..7b2b0ce0 100644 --- a/server/models/round.ts +++ b/server/models/round.ts @@ -1,11 +1,11 @@ import { type Actor, type InspectionEvent, createActor } from "xstate"; -import type { Answer, Player, Question } from "../@types/entities"; -import { betweenTurnsCountdownMs, roundMachine } from "../machines/round"; -import { turnMachine } from "../machines/turn"; -import { turnEndCountdownMs } from "../machines/turn"; -import type { SocketServer } from "../socketServer"; -import { machineLogger } from "../utils/loggingUtils"; -import { getUpdatedPlayerScoresAndBonusPoints } from "../utils/scoringUtils"; +import type { Answer, Player, Question } from "../@types/entities.d.ts"; +import { betweenTurnsCountdownMs, roundMachine } from "../machines/round.ts"; +import { turnMachine } from "../machines/turn.ts"; +import { turnEndCountdownMs } from "../machines/turn.ts"; +import type { SocketServer } from "../socketServer.ts"; +import { machineLogger } from "../utils/loggingUtils.ts"; +import { getUpdatedPlayerScoresAndBonusPoints } from "../utils/scoringUtils.ts"; class Round { machine: Actor; diff --git a/server/socketServer.ts b/server/socketServer.ts index 03c70111..075a27b0 100644 --- a/server/socketServer.ts +++ b/server/socketServer.ts @@ -1,14 +1,19 @@ import type { Server as HttpServer } from "node:http"; import { Server } from "socket.io"; -import type { CountdownOptions } from "../client/utils/domManipulationUtils/countdown"; -import type { Colour, Player, PlayerScore, Question } from "./@types/entities"; +import type { CountdownOptions } from "../client/utils/domManipulationUtils/countdown.ts"; +import type { + Colour, + Player, + PlayerScore, + Question, +} from "./@types/entities.d.ts"; import type { ClientboundSocketServerEvents, ServerboundSocketServerEvents, -} from "./@types/events"; -import { Lobby } from "./models/lobby"; -import { Round } from "./models/round"; -import { logWithTime } from "./utils/loggingUtils"; +} from "./@types/events.d.ts"; +import { Lobby } from "./models/lobby.ts"; +import { Round } from "./models/round.ts"; +import { logWithTime } from "./utils/loggingUtils.ts"; export class SocketServer { lobby: Lobby; diff --git a/server/utils/loggingUtils.ts b/server/utils/loggingUtils.ts index 590c398d..18645e7c 100644 --- a/server/utils/loggingUtils.ts +++ b/server/utils/loggingUtils.ts @@ -35,6 +35,7 @@ const logWithTime = ( fractionalSecondDigits: 3, }); + // biome-ignore lint/suspicious/noConsole: this is a logging method console.info( [`\n${currentTime} ${inlineString}`, subsequentLinesString] .filter((string) => string) diff --git a/server/utils/scoringUtils.test.ts b/server/utils/scoringUtils.test.ts index bf29f1ff..8c03897a 100644 --- a/server/utils/scoringUtils.test.ts +++ b/server/utils/scoringUtils.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from "bun:test"; -import type { Colour, Player, PlayerScore } from "../@types/entities"; +import type { Colour, Player, PlayerScore } from "../@types/entities.d.ts"; import { getCorrectSocketIdsFromAnswers, getUpdatedPlayerScoresAndBonusPoints, -} from "./scoringUtils"; +} from "./scoringUtils.ts"; describe("scoringUtils", () => { describe("getCorrectSocketIdsFromAnswers", () => { diff --git a/server/utils/scoringUtils.ts b/server/utils/scoringUtils.ts index f48e2dbb..a834cc30 100644 --- a/server/utils/scoringUtils.ts +++ b/server/utils/scoringUtils.ts @@ -1,4 +1,9 @@ -import type { Answer, Player, PlayerScore, Question } from "../@types/entities"; +import type { + Answer, + Player, + PlayerScore, + Question, +} from "../@types/entities.d.ts"; const allCorrect = ( totalPlayerCount: number,