Skip to content

Commit 6b84604

Browse files
Merge pull request #8 from chrisreddington/copilot/fix-7
Fix ESLint Errors in Shared Library Workspace
2 parents ca4d8a3 + d91b6bc commit 6b84604

File tree

11 files changed

+29
-21
lines changed

11 files changed

+29
-21
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/mcp-api-client.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import type { GameSession } from '../types/game'
2-
import type { TicTacToeGameState, RPSGameState } from '../types/games'
1+
import type { GameSession, Player } from '../types/game'
2+
import type { TicTacToeGameState, RPSGameState, TicTacToeMove, RPSMove } from '../types/games'
33
import { httpGet, httpPost, WEB_API_BASE } from '../utils/http-client'
44

55
// MCP-specific API functions that make HTTP calls to web app
66
export async function getTicTacToeGameForMCP(gameId: string): Promise<GameSession<TicTacToeGameState> | undefined> {
77
try {
88
// Get all games and find the one we want
99
const games = await httpGet(`${WEB_API_BASE}/api/games/tic-tac-toe`)
10-
return games.find((game: any) => game.gameState?.id === gameId)
10+
return games.find((game: GameSession<TicTacToeGameState>) => game.gameState?.id === gameId)
1111
} catch (error) {
1212
console.error('Error fetching tic-tac-toe game via API:', error)
1313
return undefined
1414
}
1515
}
1616

17-
export async function createTicTacToeGameForMCP(players: any[]): Promise<GameSession<TicTacToeGameState>> {
17+
export async function createTicTacToeGameForMCP(players: Player[]): Promise<GameSession<TicTacToeGameState>> {
1818
try {
1919
const playerName = players.find(p => !p.isAI)?.name || 'Player'
2020
return await httpPost(`${WEB_API_BASE}/api/games/tic-tac-toe`, { playerName })
@@ -24,7 +24,7 @@ export async function createTicTacToeGameForMCP(players: any[]): Promise<GameSes
2424
}
2525
}
2626

27-
export async function makeTicTacToeMove(gameId: string, move: any, playerId: string): Promise<GameSession<TicTacToeGameState>> {
27+
export async function makeTicTacToeMove(gameId: string, move: TicTacToeMove, playerId: string): Promise<GameSession<TicTacToeGameState>> {
2828
try {
2929
return await httpPost(`${WEB_API_BASE}/api/games/tic-tac-toe/${gameId}/move`, { move, playerId })
3030
} catch (error) {
@@ -36,14 +36,14 @@ export async function makeTicTacToeMove(gameId: string, move: any, playerId: str
3636
export async function getRPSGameForMCP(gameId: string): Promise<GameSession<RPSGameState> | undefined> {
3737
try {
3838
const games = await httpGet(`${WEB_API_BASE}/api/games/rock-paper-scissors/mcp`)
39-
return games.find((game: any) => game.gameState?.id === gameId)
39+
return games.find((game: GameSession<RPSGameState>) => game.gameState?.id === gameId)
4040
} catch (error) {
4141
console.error('Error fetching RPS game via API:', error)
4242
return undefined
4343
}
4444
}
4545

46-
export async function makeRPSMove(gameId: string, move: any, playerId: string): Promise<GameSession<RPSGameState>> {
46+
export async function makeRPSMove(gameId: string, move: RPSMove, playerId: string): Promise<GameSession<RPSGameState>> {
4747
try {
4848
return await httpPost(`${WEB_API_BASE}/api/games/rock-paper-scissors/${gameId}/move`, { move, playerId })
4949
} catch (error) {

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: Record<string, unknown>;
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/game.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface BaseGameState {
1919
updatedAt: Date;
2020
}
2121

22-
export interface GameMove<T = any> {
22+
export interface GameMove<T = unknown> {
2323
playerId: PlayerId;
2424
move: T;
2525
timestamp: Date;
@@ -36,7 +36,7 @@ export interface Game<TGameState extends BaseGameState, TMove> {
3636
applyMove(gameState: TGameState, move: TMove, playerId: PlayerId): TGameState;
3737
checkGameEnd(gameState: TGameState): GameResult | null;
3838
getValidMoves(gameState: TGameState, playerId: PlayerId): TMove[];
39-
getInitialState(players: Player[], options?: any): TGameState;
39+
getInitialState(players: Player[], options?: Record<string, unknown>): TGameState;
4040
}
4141

4242
// Generic game session for API communication

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)