Skip to content

Commit e3b0014

Browse files
Fix all ESLint errors and missing return types in shared workspace
Co-authored-by: chrisreddington <[email protected]>
1 parent 963acfc commit e3b0014

File tree

8 files changed

+18
-10
lines changed

8 files changed

+18
-10
lines changed

shared/src/constants/game-constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ export function isValidGameStatus(status: string): status is GameStatus {
8181
/**
8282
* Get difficulty display configuration
8383
*/
84-
export function getDifficultyDisplay(difficulty: Difficulty) {
84+
export function getDifficultyDisplay(difficulty: Difficulty): { emoji: string; label: string } {
8585
return DIFFICULTY_DISPLAY[difficulty]
8686
}

shared/src/games/rock-paper-scissors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class RockPaperScissorsGame implements Game<RPSGameState, RPSMove> {
9595
newRounds[gameState.currentRound] = currentRound;
9696

9797
let newCurrentRound = gameState.currentRound;
98-
let newScores = { ...gameState.scores };
98+
const newScores = { ...gameState.scores };
9999
let newCurrentPlayerId = gameState.currentPlayerId;
100100

101101
// If both players have made their choices, resolve the round

shared/src/storage/game-storage.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { vi } from 'vitest'
22
import * as gameStorage from './game-storage';
33
import * as sqliteStorage from './sqlite-storage';
4-
import type { GameSession, Player } from '../types/game';
4+
import type { GameSession } from '../types/game';
55
import type { TicTacToeGameState, RPSGameState } from '../types/games';
66

77
// Mock sqlite-storage module

shared/src/storage/sqlite-storage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sqlite3 from 'sqlite3'
2-
import { promisify } from 'util'
32
import path from 'path'
43
import type { GameSession } from '../types/game'
54
import type { TicTacToeGameState, RPSGameState } from '../types/games'

shared/src/testing/api-test-utils.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import type { TicTacToeGameState, RPSGameState, TicTacToeMove, RPSMove } from '.
1313
* Generic game mock factory
1414
* Creates a mock game instance with all required methods
1515
*/
16-
export function createGameMock() {
16+
export function createGameMock(): {
17+
getInitialState: ReturnType<typeof vi.fn>;
18+
validateMove: ReturnType<typeof vi.fn>;
19+
applyMove: ReturnType<typeof vi.fn>;
20+
checkGameEnd: ReturnType<typeof vi.fn>;
21+
getValidMoves: ReturnType<typeof vi.fn>;
22+
} {
1723
return {
1824
getInitialState: vi.fn(),
1925
validateMove: vi.fn(),
@@ -95,7 +101,10 @@ export function createMockGameSession<T extends BaseGameState>(gameState: T, gam
95101
* Vitest mock configuration for shared package games
96102
* Use this to create consistent mocks across API route tests
97103
*/
98-
export function createSharedGameMocks(gameClass: string) {
104+
export function createSharedGameMocks(gameClass: string): {
105+
mockImplementation: any;
106+
mockGame: ReturnType<typeof createGameMock>;
107+
} {
99108
const mockGame = createGameMock()
100109

101110
return {
@@ -110,7 +119,7 @@ export function createSharedGameMocks(gameClass: string) {
110119
/**
111120
* Create storage function mocks for a specific game type
112121
*/
113-
export function createStorageMocks(gameType: GameType) {
122+
export function createStorageMocks(gameType: GameType): Record<string, ReturnType<typeof vi.fn>> {
114123
if (gameType === 'tic-tac-toe') {
115124
return {
116125
getTicTacToeGame: vi.fn(),

shared/src/testing/test-database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export async function setupTestDatabase(
5151
}
5252

5353
// Create tables synchronously to ensure they exist before tests run
54-
const createTables = async () => {
54+
const createTables = async (): Promise<void> => {
5555
try {
5656
await createTicTacToeTable()
5757
await createRPSTable()

shared/src/testing/vitest-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { setupTestDatabase, teardownTestDatabase } from './test-database'
1212
* Standard database setup for all packages
1313
* Call this in vitest.setup.ts files to ensure consistent database setup
1414
*/
15-
export function setupStandardTestDatabase() {
15+
export function setupStandardTestDatabase(): void {
1616
// Setup test database before all tests
1717
beforeAll(async () => {
1818
try {

shared/src/types/games.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseGameState, GameMove } from './game';
1+
import { BaseGameState } from './game';
22

33
// Tic-tac-toe specific types
44
export type CellValue = 'X' | 'O' | null;

0 commit comments

Comments
 (0)