From 2c6b5a77e17f0a5c478cf8e4a05bb7089955c7a4 Mon Sep 17 00:00:00 2001 From: Kageetai Date: Tue, 30 Jan 2024 14:16:20 +0100 Subject: [PATCH] use @typescript-eslint/recommended-type-checked and fix two errors from it --- .eslintrc.cjs | 6 +++++- src/game.ts | 10 ++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 8630ca9..587193b 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,10 +1,14 @@ module.exports = { extends: [ "eslint:recommended", - "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-type-checked", "plugin:prettier/recommended", ], parser: "@typescript-eslint/parser", + parserOptions: { + project: true, + tsconfigRootDir: __dirname, + }, plugins: ["@typescript-eslint"], root: true, }; diff --git a/src/game.ts b/src/game.ts index 718aed9..be52bd5 100644 --- a/src/game.ts +++ b/src/game.ts @@ -103,9 +103,8 @@ function drawActors() { asciiDisplay[player.y][player.x] = player.hp; // draw the enemies - for (const a in enemyList) { - if (enemyList[a] != null && enemyList[a].hp > 0) - asciiDisplay[enemyList[a].y][enemyList[a].x] = "e"; + for (const a of enemyList) { + if (a != null && a.hp > 0) asciiDisplay[a.y][a.x] = "e"; } } @@ -182,9 +181,8 @@ export function onKeyUp(event: DirectionalEvent) { // enemies act every time the player does if (acted) - for (const enemy in enemyList) { - const e = enemyList[enemy]; - if (e != null) aiAct(e); + for (const enemy of enemyList) { + if (enemy != null) aiAct(enemy); } // draw actors in new positions