From 2a16fb5532301b5b37ed7ae322473092bbf49315 Mon Sep 17 00:00:00 2001 From: Adrian de la Rosa Date: Wed, 29 Apr 2026 22:46:01 +0200 Subject: [PATCH] refactor: import shared types from @echecs/tournament (#18) --- package.json | 3 ++- pnpm-lock.yaml | 9 +++++++++ src/__tests__/index.spec.ts | 2 +- src/cut1.ts | 4 ++-- src/index.ts | 4 ++-- src/types.ts | 22 ---------------------- src/utilities.ts | 2 +- 7 files changed, 17 insertions(+), 29 deletions(-) delete mode 100644 src/types.ts diff --git a/package.json b/package.json index 8887b99..818b068 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ }, "description": "Progressive score tiebreak for chess tournaments following FIDE rules. Zero dependencies.", "devDependencies": { + "@echecs/tournament": "^2.1.2", "@eslint/js": "^10.0.1", "@typescript-eslint/parser": "^8.57.0", "@vitest/coverage-v8": "^4.1.0", @@ -18,8 +19,8 @@ "lint-staged": "^16.4.0", "prettier": "^3.8.1", "tsdown": "^0.21.4", - "typescript": "^6.0.2", "typedoc": "^0.28.17", + "typescript": "^6.0.2", "typescript-eslint": "^8.57.0", "vitest": "^4.1.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e79285d..e4e3570 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: devDependencies: + '@echecs/tournament': + specifier: ^2.1.2 + version: 2.1.2 '@eslint/js': specifier: ^10.0.1 version: 10.0.1(eslint@10.2.1) @@ -104,6 +107,10 @@ packages: resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==} engines: {node: '>=18'} + '@echecs/tournament@2.1.2': + resolution: {integrity: sha512-DYq8Nbc1Dq15ZpQMKWziGmfyxd4RC0jIgWsbVRLM6/q+sPKPjSPxiBtRC8+u5gPr0lKaK5eoZKs295I/W60akA==} + engines: {node: '>=20'} + '@emnapi/core@1.10.0': resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==} @@ -1692,6 +1699,8 @@ snapshots: '@bcoe/v8-coverage@1.0.2': {} + '@echecs/tournament@2.1.2': {} + '@emnapi/core@1.10.0': dependencies: '@emnapi/wasi-threads': 1.2.1 diff --git a/src/__tests__/index.spec.ts b/src/__tests__/index.spec.ts index 039d978..e1f3f18 100644 --- a/src/__tests__/index.spec.ts +++ b/src/__tests__/index.spec.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest'; import { progressiveCut1 } from '../cut1.js'; import { progressive } from '../index.js'; -import type { Game } from '../types.js'; +import type { Game } from '@echecs/tournament'; // 4 players, 3 rounds: // Round 1: A(W) 1-0 B, C(W) 0-1 D diff --git a/src/cut1.ts b/src/cut1.ts index b9fd72f..430d5ec 100644 --- a/src/cut1.ts +++ b/src/cut1.ts @@ -1,6 +1,6 @@ import { playerResult } from './utilities.js'; -import type { Game } from './types.js'; +import type { Game } from '@echecs/tournament'; function progressiveCut1(player: string, games: Game[][]): number { let cumulative = 0; @@ -14,4 +14,4 @@ function progressiveCut1(player: string, games: Game[][]): number { export { progressiveCut1, progressiveCut1 as tiebreak }; -export type { Game, GameKind, Player, Result } from './types.js'; +export type { Game, GameKind, Player, Result } from '@echecs/tournament'; diff --git a/src/index.ts b/src/index.ts index e1eb32e..2373aa8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { playerResult } from './utilities.js'; -import type { Game } from './types.js'; +import type { Game } from '@echecs/tournament'; function progressive(player: string, games: Game[][]): number { let cumulative = 0; @@ -14,4 +14,4 @@ function progressive(player: string, games: Game[][]): number { export { progressive, progressive as tiebreak }; -export type { Game, GameKind, Player, Result } from './types.js'; +export type { Game, GameKind, Player, Result } from '@echecs/tournament'; diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index 382d2e0..0000000 --- a/src/types.ts +++ /dev/null @@ -1,22 +0,0 @@ -type GameKind = - | 'forfeit-loss' - | 'forfeit-win' - | 'full-bye' - | 'half-bye' - | 'pairing-bye' - | 'zero-bye'; - -type Result = 0 | 0.5 | 1; - -interface Game { - black: string; - kind?: GameKind; - result: Result; - white: string; -} - -interface Player { - id: string; -} - -export type { Game, GameKind, Player, Result }; diff --git a/src/utilities.ts b/src/utilities.ts index 2323e0a..4b8923d 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -1,4 +1,4 @@ -import type { Game } from './types.js'; +import type { Game } from '@echecs/tournament'; function gamesForPlayer(player: string, games: Game[][]): Game[] { return games.flat().filter((g) => g.white === player || g.black === player);