Skip to content

Commit 1b49b4b

Browse files
snowyukittyBaseMaxjbampton
authored
Restore Biome checks for JavaScript sources (#567)
* Fix Biome checks for JavaScript sources * Reduce complexity in touched functions * Use explicit classic-script global for playSound * Encapsulate playSound implementation * Simplify layered sound dispatch --------- Co-authored-by: snowyukitty <270071858+snowyukitty@users.noreply.github.com> Co-authored-by: Seyyed Ali Mohammadiyeh (Max Base) <MaxBaseCode@Gmail.Com> Co-authored-by: John Bampton <jbampton@users.noreply.github.com>
1 parent 5b7f746 commit 1b49b4b

8 files changed

Lines changed: 98 additions & 80 deletions

File tree

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ repos:
113113
hooks:
114114
- id: biome-check
115115
name: run biome-check
116-
description: Run Biome linter and formatter for JSON files
116+
description: Run Biome linter and formatter for JSON and JavaScript files
117117
additional_dependencies: ["@biomejs/biome"]
118118

119119
- repo: https://github.com/igorshubovych/markdownlint-cli

‎biome.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
33
"files": {
4-
"includes": ["**/*.json"]
4+
"includes": ["**/*.json", "src/assets/js/**/*.js"]
55
},
66
"linter": {
77
"enabled": true,

‎src/assets/js/games/code-breaker.js‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Theme-aware: reads the current dark/light mode at startup.
1414
*/
1515

16+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
1617
const CodeBreaker = (() => {
1718
const GAME_ID = "code-breaker";
1819
const TILE_SPEED_BASE = 180;
@@ -75,7 +76,7 @@ const CodeBreaker = (() => {
7576
},
7677
scene: {
7778
create: function () {
78-
_onSceneCreate(this, skills, devName, theme, W, H);
79+
_onSceneCreate(this, skills, theme, W, H);
7980
},
8081
update: function () {
8182
_onSceneUpdate(this);
@@ -91,7 +92,7 @@ const CodeBreaker = (() => {
9192

9293
// ─── Scene ───────────────────────────────────────────────────────────────
9394

94-
function _onSceneCreate(scene, skills, devName, theme, W, H) {
95+
function _onSceneCreate(scene, skills, theme, W, H) {
9596
// State stored on scene object
9697
scene.cb_lives = LIVES;
9798
scene.cb_score = 0;
@@ -138,8 +139,8 @@ const CodeBreaker = (() => {
138139
scene.physics.add.overlap(
139140
scene.cb_catcher,
140141
scene.cb_tiles,
141-
(catcher, tile) => {
142-
_collectTile(scene, tile, theme, W, H);
142+
(_catcher, tile) => {
143+
_collectTile(scene, tile, W, H);
143144
},
144145
);
145146

@@ -163,7 +164,7 @@ const CodeBreaker = (() => {
163164

164165
// Spawn first tile after a short delay
165166
scene.time.delayedCall(500, () => {
166-
_spawnTile(scene, theme, W);
167+
_spawnTile(scene, W);
167168
});
168169
}
169170

@@ -184,7 +185,7 @@ const CodeBreaker = (() => {
184185
const now = scene.time.now;
185186
if (now - scene.cb_lastSpawn > scene.cb_spawnDelay) {
186187
scene.cb_lastSpawn = now;
187-
_spawnTile(scene, getGameTheme(), scene.scale.width);
188+
_spawnTile(scene, scene.scale.width);
188189
}
189190

190191
// Check if any tile fell off the bottom.
@@ -203,7 +204,7 @@ const CodeBreaker = (() => {
203204

204205
// ─── Game logic ──────────────────────────────────────────────────────────
205206

206-
function _spawnTile(scene, theme, W) {
207+
function _spawnTile(scene, W) {
207208
if (!scene.cb_active) return;
208209

209210
const skill =
@@ -264,8 +265,7 @@ const CodeBreaker = (() => {
264265
scene.cb_spawnDelay = Math.max(600, scene.cb_spawnDelay - 20);
265266
}
266267

267-
function _collectTile(scene, tile, theme, W, H) {
268-
const skill = tile.getData("skill");
268+
function _collectTile(scene, tile, W, H) {
269269
const rarity = tile.getData("rarity");
270270
const color = tile.getData("color");
271271

@@ -277,7 +277,7 @@ const CodeBreaker = (() => {
277277
TILE_SPEED_BASE + scene.cb_score * TILE_SPEED_INC,
278278
);
279279

280-
if (scene.cb_scoreText && scene.cb_scoreText.active) {
280+
if (scene.cb_scoreText?.active) {
281281
scene.cb_scoreText.setText("Score: " + scene.cb_score);
282282
}
283283

@@ -316,7 +316,7 @@ const CodeBreaker = (() => {
316316

317317
scene.cb_lives--;
318318

319-
if (scene.cb_livesText && scene.cb_livesText.active) {
319+
if (scene.cb_livesText?.active) {
320320
scene.cb_livesText.setText("❤️".repeat(Math.max(0, scene.cb_lives)));
321321
}
322322

‎src/assets/js/games/config.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
*/
55

66
// CDN URL for the pinned Phaser version used site-wide
7+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
78
const PHASER_CDN_URL =
89
"https://cdnjs.cloudflare.com/ajax/libs/phaser/3.90.0/phaser.min.js";
910

1011
// Rarity order and weights used by Dev Duel scoring
12+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
1113
const RARITY_WEIGHTS = {
1214
common: 1,
1315
uncommon: 2,
@@ -19,6 +21,7 @@ const RARITY_WEIGHTS = {
1921
};
2022

2123
// CSS variable colour names per rarity (matches style.css)
24+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
2225
const RARITY_COLORS = {
2326
common: "#94a3b8",
2427
uncommon: "#10b981",
@@ -30,6 +33,7 @@ const RARITY_COLORS = {
3033
};
3134

3235
// Fallback generic tech skills used when no profile skills are available
36+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
3337
const GENERIC_SKILLS = [
3438
"JavaScript",
3539
"TypeScript",
@@ -57,6 +61,7 @@ const GENERIC_SKILLS = [
5761
* Reads the current site theme from the document root class.
5862
* Returns an object of useful colour strings for Phaser text/backgrounds.
5963
*/
64+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
6065
function getGameTheme() {
6166
const isDark = document.documentElement.classList.contains("dark");
6267
return {
@@ -73,6 +78,7 @@ function getGameTheme() {
7378
* Deterministically assigns a rarity tier to a skill name string.
7479
* Uses a simple hash so the same skill always gets the same rarity.
7580
*/
81+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
7682
function skillRarity(skillName) {
7783
let hash = 0;
7884
for (let i = 0; i < skillName.length; i++) {
@@ -99,6 +105,7 @@ function skillRarity(skillName) {
99105
*
100106
* @param {object} overrides Fields that replace defaults (e.g. width, scene).
101107
*/
108+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
102109
function buildGameConfig(overrides) {
103110
return Object.assign(
104111
{

‎src/assets/js/games/dev-duel.js‎

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ const DevDuel = (() => {
9090
.setOrigin(0.5, 0);
9191

9292
// Cards
93-
_drawCard(scene, challenger, cPower, W * 0.22, H / 2 - 20, theme, false);
94-
_drawCard(scene, opponent, oPower, W * 0.78, H / 2 - 20, theme, true);
93+
_drawCard(scene, challenger, cPower, W * 0.22, H / 2 - 20, theme);
94+
_drawCard(scene, opponent, oPower, W * 0.78, H / 2 - 20, theme);
9595

9696
// VS label
9797
scene.add
@@ -127,11 +127,11 @@ const DevDuel = (() => {
127127

128128
// Animate the battle after a short delay
129129
scene.time.delayedCall(800, () => {
130-
_animateBattle(scene, challenger, opponent, cPower, oPower, W, H, theme);
130+
_animateBattle(scene, challenger, opponent, cPower, oPower, W, H);
131131
});
132132
}
133133

134-
function _drawCard(scene, dev, power, cx, cy, theme, flipSide) {
134+
function _drawCard(scene, dev, power, cx, cy, theme) {
135135
const cardW = 160;
136136
const cardH = 200;
137137
const x = cx - cardW / 2;
@@ -215,7 +215,7 @@ const DevDuel = (() => {
215215
w: barW,
216216
duration: 800,
217217
ease: "Power2",
218-
onUpdate: (tween, target) => {
218+
onUpdate: (_tween, target) => {
219219
fillGfx.clear();
220220
fillGfx.fillStyle(0x38bdf8, 1);
221221
fillGfx.fillRoundedRect(x, y + 14, target.w, 10, 3);
@@ -231,24 +231,15 @@ const DevDuel = (() => {
231231

232232
// ─── Battle animation ─────────────────────────────────────────────────────
233233

234-
function _animateBattle(
235-
scene,
236-
challenger,
237-
opponent,
238-
cPower,
239-
oPower,
240-
W,
241-
H,
242-
theme,
243-
) {
234+
function _animateBattle(scene, challenger, opponent, cPower, oPower, W, H) {
244235
// Flash attacks back and forth
245236
let round = 0;
246237
const maxRounds = 5;
247238

248239
const attackFlash = () => {
249240
if (round >= maxRounds) {
250241
scene.time.delayedCall(400, () => {
251-
_showResult(scene, challenger, opponent, cPower, oPower, W, H, theme);
242+
_showResult(scene, challenger, opponent, cPower, oPower, W, H);
252243
});
253244
return;
254245
}
@@ -280,16 +271,7 @@ const DevDuel = (() => {
280271

281272
// ─── Result screen ────────────────────────────────────────────────────────
282273

283-
function _showResult(
284-
scene,
285-
challenger,
286-
opponent,
287-
cPower,
288-
oPower,
289-
W,
290-
H,
291-
theme,
292-
) {
274+
function _showResult(scene, challenger, opponent, cPower, oPower, W, H) {
293275
const challengerWins = cPower >= oPower;
294276
const winner = challengerWins ? challenger : opponent;
295277

@@ -397,6 +379,7 @@ function getCardData(cardEl) {
397379
*
398380
* @param {HTMLElement} challengerCard The card element that was clicked.
399381
*/
382+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
400383
function startDuelFromCard(challengerCard) {
401384
const allCards = Array.from(
402385
document.querySelectorAll(".user-card[data-name]"),

‎src/assets/js/games/game-manager.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* - Persisting per-game high scores and achievement flags in localStorage
99
*/
1010

11+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
1112
const GameManager = (() => {
1213
/** Active Phaser.Game instances keyed by game id. */
1314
const _instances = {};

‎src/assets/js/games/space-invaders.js‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* GameManager and lazy-loaded alongside the other mini-games.
99
*/
1010

11+
// biome-ignore lint/correctness/noUnusedVariables: Used outside this classic script.
1112
const SpaceInvaders = (() => {
1213
const ALIEN_ROWS = ["👾", "👽", "🛸", "🐙", "👾"];
1314
const GAME_ID = "space-invaders";
@@ -69,22 +70,29 @@ const SpaceInvaders = (() => {
6970
_setupGame(this);
7071
}
7172

72-
function _onUpdate() {
73-
if (!this.si_player || !this.si_player.body) return;
74-
75-
if (this.si_cursors.left.isDown) {
76-
this.si_player.body.setVelocityX(-400);
77-
} else if (this.si_cursors.right.isDown) {
78-
this.si_player.body.setVelocityX(400);
73+
function _updatePlayerVelocity(scene) {
74+
if (scene.si_cursors.left.isDown) {
75+
scene.si_player.body.setVelocityX(-400);
76+
} else if (scene.si_cursors.right.isDown) {
77+
scene.si_player.body.setVelocityX(400);
7978
} else {
80-
this.si_player.body.setVelocityX(0);
79+
scene.si_player.body.setVelocityX(0);
8180
}
81+
}
82+
83+
function _getBullets(scene) {
84+
return scene.si_bullets?.getChildren?.() || [];
85+
}
86+
87+
function _onUpdate() {
88+
if (!this.si_player?.body) return;
8289

90+
_updatePlayerVelocity(this);
8391
if (this.si_cursors.space.isDown) {
8492
_fireBullet(this);
8593
}
8694

87-
const bullets = this.si_bullets?.getChildren?.() || [];
95+
const bullets = _getBullets(this);
8896
bullets.forEach((bullet) => {
8997
if (!bullet.active) return;
9098
if (

0 commit comments

Comments
 (0)