Repository navigation
Closed
Labels
severity: mediumEdge-case bugs or meaningful maintainability costtech-debtRefactoring and maintainability
Description
Summary
Several functions and files are unused or duplicated, and the copies no longer agree. The unused copies are the ones a contributor is likely to find first and edit.
Where
js/game.js:800-840(generateNotation, unused),js/utils.js:132-173(formatSAN, unused),js/game.js:845-906(the live formatter)js/game.js:472-487,js/game.js:525-540,js/game.js:865-874(three copies of the path-obstruction walk)js/game.js:561-574(isKingInCheckandisKingInCheckWithPositions)js/game.js:363-378(pawn guards that cannot fire) andjs/game.js:386-394(en passant added again)js/board.js:210-219(delegateBoardClick, unused)js/utils.js:206-208(getOppositeColor, unused while the same expression is inlined six times ingame.js)js/ai.js,js/promotion.js(not loaded byindex.html:65-71;js/main.js:100-110checks for them).eslintrc.cjs,package.json:15(eslint-config-prettier)
Details
formatSANreadsmove.isCaptureandmove.isKingsideCastling, fieldsmakeMovenever sets.ChessAI._getAllLegalMovesreturns[], sofindBestMovealways resolvesnull.- ESLint 9 reads
eslint.config.jsand ignores.eslintrc.cjs. That legacy file extendsplugin:prettier/recommended, a plugin that is not a dependency, andeslint-config-prettieris declared but never imported. - SAN disambiguation keeps the last matching piece instead of considering all candidates (
js/game.js:878-882): with white rooks on a1, a5 and h3, Ra1-a3 is writtenRa1a3instead ofR1a3.
Impact
A notation or rules fix has several candidate places and most do nothing. Two ESLint configs with different settings invite edits to the wrong one.
Suggested fix
Small changes, each reviewable alone, with SAN tests added first:
- Delete
generateNotationandformatSAN - Give
isPathObstructeda board parameter and delete the other two copies - Fold
isKingInCheckWithPositionsintoisKingInCheck - Keep one en passant branch and delete the unreachable pawn guards
- Delete
delegateBoardClick; use or deletegetOppositeColor - Delete
.eslintrc.cjs; removeeslint-config-prettieror import it as the last entry ofeslint.config.js - Mark
ai.jsandpromotion.jsas not shipped, or remove them until the features are built - Compute SAN disambiguation over all candidate pieces
Acceptance criteria
- No unused exported functions remain in
js/ - One ESLint config
- Lint and tests pass
Getting started
- Relevant files:
js/game.js,js/utils.js,js/board.js,js/ai.js,js/promotion.js,.eslintrc.cjs,package.json - How to run tests:
npm install, thennpm testandnpm run lint - Related docs:
docs/ARCHITECTURE.md,.github/CONTRIBUTING.md
Filed by repo-audit/full-audit at 8a2c86c. Severity: medium. Effort: M. audit-key: tech-debt|js/game.js|generateNotation
Metadata
Metadata
Assignees
Labels
severity: mediumEdge-case bugs or meaningful maintainability costtech-debtRefactoring and maintainability
Activity
Synthesize sound effects; remove dead and duplicated code; group Depe…
Make the board one tab stop and announce moves to screen readers
TMHSDigital commentedon Nov 13, 2026
Everything on this list is done except one item, which now belongs to another issue:
delegateBoardClick,getOppositeColor, the legacy ESLint config andeslint-config-prettier: removed.promotion.js: rewritten, loaded and in use since 2bfb75f.ai.js: still an unloaded skeleton. It stays until the AI opponent is built or dropped, which is tracked in Make the AI opponent skeleton playable (single-player mode) #54.Closing this one.