Replace script-order globals shared between board.js, game.js and drag.js
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- eslint, javascript, node.js
- Ambito
- developer-experience, frontend
Direzione di ricerca
Read docs/ARCHITECTURE.md and .github/CONTRIBUTING.md, then trace the shared state and window accessors in js/board.js, js/game.js, and js/drag.js alongside the globals in eslint.config.js. Start by checking the test bootstrap work in related issue #40 and the existing tests in tests/. Run npm test and npm run lint; done means board rendering no longer reads game variables, missing drag dependencies raise errors, and the per-file globals list shrinks or disappears.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The seven scripts share one global scope and depend on load order. board.js and game.js read each other's variables, drag.js reaches both through window.* behind typeof guards, and eslint.config.js hand-lists the cross-file globals for every file.
Where
js/board.js:184(readsmoveHistoryfromgame.js),js/game.js:109(readsselectedSquareandpossibleMovesfromboard.js)js/game.js:908-921,js/board.js:252-266(window getters)js/drag.js:97-115,js/drag.js:230-232,js/drag.js:256eslint.config.js:35-155package.json:5("type": "module"while every file uses CommonJS exports)
Impact
Adding or moving a function means editing the source, the ESLint globals list and each test preamble. The typeof guards in drag.js turn a wiring mistake into a silent no-op (a drop that does nothing). The globals list is already stale: drag.js is granted handleBoardClick, which it does not use.
Suggested fix
- Move the shared test bootstrap into one helper (#40); no production change.
- Break the cycle: pass
lastMoveintoupdateBoardVisuals, and giveselectedSquareandpossibleMovesone owning module with accessors. - Replace the
window.*getters with one explicit namespace object and drop thetypeofguards. - Optionally convert to ES modules, which removes the per-file globals lists. ES modules do not load from
file://, so decide first whether openingindex.htmldirectly must keep working.
Acceptance criteria
-
board.jsrenders without readinggame.jsvariables - A missing dependency in
drag.jsraises an error instead of doing nothing - The per-file globals in
eslint.config.jsshrink or disappear
Getting started
- Relevant files:
js/board.js,js/game.js,js/drag.js,eslint.config.js,tests/ - 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/board.js|window-globals
- Lingua principale
- JavaScript
- Stelle
- 4
- Fork
- 2
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TMHSDigital/Static_Chess
-
enhancement good first issue severity: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TMHSDigital/Static_Chess#53 ·
-
documentation good first issue severity: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
TMHSDigital/Static_Chess#49 ·
-
documentation good first issue severity: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
TMHSDigital/Static_Chess#48 ·
-
documentation severity: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TMHSDigital/Static_Chess#47 ·
-
documentation good first issue severity: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
TMHSDigital/Static_Chess#46 ·
Tutte le issue di TMHSDigital/Static_Chess
Issue simili
-
good first issue tests
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
1️⃣ phase/under-investigation flaky/confirmed flaky/needs-decision type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
growilabs/growi#12246 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
TMHSDigital/Free-Game-Dev-Assets#301 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100