Skip to content

Commit

Permalink
Fix Biome errors
Browse files Browse the repository at this point in the history
- Add file extensions
- Ignore a `noConsole` rule in logging method
  • Loading branch information
yndajas committed Oct 18, 2024
1 parent 76ea436 commit d37178d
Show file tree
Hide file tree
Showing 27 changed files with 93 additions and 82 deletions.
32 changes: 16 additions & 16 deletions client/index.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion client/utils/adminUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderRoundResetButton } from "./domManipulationUtils/roundReset";
import { renderRoundResetButton } from "./domManipulationUtils/roundReset.ts";

const konamiCode: KeyboardEvent["key"][] = [
"ArrowUp",
Expand Down
8 changes: 4 additions & 4 deletions client/utils/domManipulationUtils/answer.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions client/utils/domManipulationUtils/bonusPoints.ts
Original file line number Diff line number Diff line change
@@ -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 ||=
Expand Down
8 changes: 4 additions & 4 deletions client/utils/domManipulationUtils/colourCheckboxes.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions client/utils/domManipulationUtils/connectionStatus.ts
Original file line number Diff line number Diff line change
@@ -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 ||=
Expand Down
4 changes: 2 additions & 2 deletions client/utils/domManipulationUtils/countdown.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions client/utils/domManipulationUtils/playerList.ts
Original file line number Diff line number Diff line change
@@ -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<HTMLUListElement>("player-list");
Expand Down
6 changes: 3 additions & 3 deletions client/utils/domManipulationUtils/playerName.ts
Original file line number Diff line number Diff line change
@@ -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<HTMLDivElement>("player-name");
Expand Down
6 changes: 3 additions & 3 deletions client/utils/domManipulationUtils/question.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
8 changes: 4 additions & 4 deletions client/utils/domManipulationUtils/roundReset.ts
Original file line number Diff line number Diff line change
@@ -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 ||=
Expand Down
4 changes: 2 additions & 2 deletions client/utils/domManipulationUtils/startButton.ts
Original file line number Diff line number Diff line change
@@ -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 ||=
Expand Down
4 changes: 2 additions & 2 deletions client/utils/domManipulationUtils/unjoinableMessage.ts
Original file line number Diff line number Diff line change
@@ -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<NameFormElement>("name-form");
Expand Down
4 changes: 2 additions & 2 deletions client/utils/socketUtils.ts
Original file line number Diff line number Diff line change
@@ -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<ClientboundSocketServerEvents, ServerboundSocketServerEvents>,
Expand Down
4 changes: 2 additions & 2 deletions e2e/app.test.ts
Original file line number Diff line number Diff line change
@@ -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[] = [];
Expand Down
4 changes: 2 additions & 2 deletions server/@types/events.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion server/machines/lobby.test.ts
Original file line number Diff line number Diff line change
@@ -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" };
Expand Down
2 changes: 1 addition & 1 deletion server/machines/lobby.ts
Original file line number Diff line number Diff line change
@@ -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[],
Expand Down
4 changes: 2 additions & 2 deletions server/machines/round.ts
Original file line number Diff line number Diff line change
@@ -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[],
Expand Down
4 changes: 2 additions & 2 deletions server/machines/turn.ts
Original file line number Diff line number Diff line change
@@ -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[],
Expand Down
8 changes: 4 additions & 4 deletions server/models/lobby.ts
Original file line number Diff line number Diff line change
@@ -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<typeof lobbyMachine>;
Expand Down
14 changes: 7 additions & 7 deletions server/models/round.ts
Original file line number Diff line number Diff line change
@@ -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<typeof roundMachine>;
Expand Down
17 changes: 11 additions & 6 deletions server/socketServer.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions server/utils/loggingUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions server/utils/scoringUtils.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
7 changes: 6 additions & 1 deletion server/utils/scoringUtils.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit d37178d

Please sign in to comment.