From c63b690d92947b9198179cb23fd250d4c56e2dc1 Mon Sep 17 00:00:00 2001 From: Owen Date: Sun, 1 Oct 2023 17:44:50 +0100 Subject: [PATCH] enforce some more eslint rules --- .eslintrc.json | 15 ++++++++++++++- src/classes/GPS.ts | 7 +++---- src/classes/Nations.ts | 8 ++++++-- src/main.ts | 3 +-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 207e857..3a5b6f6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,6 +23,19 @@ "semi": ["error", "never"], "no-unreachable": ["error"], "no-unexpected-multiline": ["error"], - "prefer-const": "warn" + "prefer-const": "warn", + "no-self-compare": "error", + "no-sparse-arrays": "error", + "spaced-comment": ["warn", "always", { + "markers": [ + "#region", + "#endregion", + "@ts-expect-error" + ] + }], + "comma-spacing": 2, + "comma-style": 2, + "comma-dangle": ["error", "never"], + "camelcase": 2 } } \ No newline at end of file diff --git a/src/classes/GPS.ts b/src/classes/GPS.ts index a0dd5db..7b9aa06 100644 --- a/src/classes/GPS.ts +++ b/src/classes/GPS.ts @@ -66,19 +66,18 @@ class GPS extends Mitt { this.emit('error', { err: "INVALID_LAST_LOC", msg: e.message }) } } - } + } else { this.lastLoc = { x: player.x, z: player.z } try { const routeInfo = await this.findRoute({ x: player.x, - z: player.z, + z: player.z }, route) this.emit('locationUpdate', routeInfo) - } - catch(e: any) { + } catch(e: any) { this.emit('error', { err: "INVALID_LOC", msg: e.message }) } } diff --git a/src/classes/Nations.ts b/src/classes/Nations.ts index 01d21ee..5deef41 100644 --- a/src/classes/Nations.ts +++ b/src/classes/Nations.ts @@ -105,8 +105,12 @@ class Nations implements Base { } readonly joinable = async (townName: string, nationless = true): Promise => { - const town = await this.map.Towns.get(townName) - if (!town || town == "That town does not exist!") return town + let town = null + try { + town = await this.map.Towns.get(townName) + } catch (ignore) { + return new FetchError(`Specified town '${townName}' does not exist!`) + } const nations = await this.all(this.map.getFromCache('towns')) if (!nations) return new FetchError('Error fetching nations! Please try again.') diff --git a/src/main.ts b/src/main.ts index e8f42a3..6287685 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,8 +30,7 @@ async function getServerInfo() { const queue = online < 1 ? 0 : online - auroraCount - novaCount return { queue, ...serverInfo } - } - catch (err: unknown) { + } catch (err: unknown) { throw new Errors.FetchError(`Error fetching server info!\n${err}`) } }