From 165e04a02ef12c11e9713cc70b8d507c9b24b512 Mon Sep 17 00:00:00 2001 From: Arturas Date: Sat, 21 Jan 2023 19:26:02 +0000 Subject: [PATCH] chore: Minor code cleanup --- src/lib/data/opts-list-item.mts | 2 +- src/lib/util/export-modal.mts | 5 +++-- .../get-from-registry-or-log.mts | 18 ------------------ .../media-item/media-edit-base.tsx | 2 +- src/ui/pages/import-export-page.tsx | 5 +++-- .../workflows-dashboard/render-node-media.tsx | 2 +- types/melvor/game/combat.d.ts | 2 ++ types/melvor/game/core.d.ts | 2 ++ types/melvor/game/item.d.ts | 2 ++ types/melvor/game/misc.d.ts | 2 ++ types/melvor/game/skilling.d.ts | 2 ++ types/melvor/game/toon.d.ts | 2 ++ types/melvor/mod.d.ts | 2 ++ types/melvor/ui.d.ts | 2 ++ 14 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 src/lib/util/registry-utils/get-from-registry-or-log.mts diff --git a/src/lib/data/opts-list-item.mts b/src/lib/data/opts-list-item.mts index 3165419..610f732 100644 --- a/src/lib/data/opts-list-item.mts +++ b/src/lib/data/opts-list-item.mts @@ -22,7 +22,7 @@ export default abstract class OptsListItem { /** Option values */ public opts!: Obj; // Gets set in extending classes' constructors - public constructor({opts}: Init) { + protected constructor({opts}: Init) { if (opts) { this.opts = opts; } diff --git a/src/lib/util/export-modal.mts b/src/lib/util/export-modal.mts index 6f948fa..2a909ba 100644 --- a/src/lib/util/export-modal.mts +++ b/src/lib/util/export-modal.mts @@ -11,14 +11,15 @@ export function showExportModal(title: string, contents: any): void { html.textContent = JSON.stringify(contents); html.readOnly = true; - Swal // eslint-disable-line @typescript-eslint/no-floating-promises + Swal .fire({ confirmButtonText: 'OK', html, showCancelButton: false, showConfirmButton: true, title, - }); + }) + .catch(console.error); } /** @return Pasted JSON */ diff --git a/src/lib/util/registry-utils/get-from-registry-or-log.mts b/src/lib/util/registry-utils/get-from-registry-or-log.mts deleted file mode 100644 index 5636215..0000000 --- a/src/lib/util/registry-utils/get-from-registry-or-log.mts +++ /dev/null @@ -1,18 +0,0 @@ -import type {NamespaceRegistry} from 'melvor'; -import {errorLog} from '../log.mjs'; - -/** - * Get the given ID from the registry or log an error - * @param reg The registry - * @param id The item ID - * @param logID Operation identifier for logging - */ -export function getFromRegistryOrLog(reg: NamespaceRegistry, id: string, logID: string): T | undefined { - const out = reg.getObjectByID(id); - if (out) { - return out; - } - - errorLog(`Error getting ${logID} value ${id} from registry: not registered`); -} - diff --git a/src/option-types/media-item/media-edit-base.tsx b/src/option-types/media-item/media-edit-base.tsx index 45918ef..d664bd4 100644 --- a/src/option-types/media-item/media-edit-base.tsx +++ b/src/option-types/media-item/media-edit-base.tsx @@ -50,7 +50,7 @@ function RenderBtn({icon = true, value, onChange}: Bt return ( - {icon && } + {icon && {'Icon'}/} {value.name} ); diff --git a/src/ui/pages/import-export-page.tsx b/src/ui/pages/import-export-page.tsx index d2d3c43..570f160 100644 --- a/src/ui/pages/import-export-page.tsx +++ b/src/ui/pages/import-export-page.tsx @@ -106,11 +106,12 @@ function ExportAll(): VNode { } function alertDone() { - Swal // eslint-disable-line @typescript-eslint/no-floating-promises + Swal .fire({ confirmButtonText: 'OK', showCancelButton: false, showConfirmButton: true, text: 'Done!', - }); + }) + .catch(console.error); } diff --git a/src/ui/pages/workflows-dashboard/render-node-media.tsx b/src/ui/pages/workflows-dashboard/render-node-media.tsx index 53375b5..5d7a6ff 100644 --- a/src/ui/pages/workflows-dashboard/render-node-media.tsx +++ b/src/ui/pages/workflows-dashboard/render-node-media.tsx @@ -9,7 +9,7 @@ export interface RenderNodeMediaProps extends Pick { export function RenderNodeMedia({label, media}: RenderNodeMediaProps): VNode { return ( - + {'Icon'}/ {label} ); diff --git a/types/melvor/game/combat.d.ts b/types/melvor/game/combat.d.ts index 77286c3..a6833a5 100644 --- a/types/melvor/game/combat.d.ts +++ b/types/melvor/game/combat.d.ts @@ -1,3 +1,5 @@ +// noinspection JSUnusedGlobalSymbols + import {BaseSpell, NamespacedObject} from './core'; import {Skill} from './skilling'; import type {Character} from './toon'; diff --git a/types/melvor/game/core.d.ts b/types/melvor/game/core.d.ts index 6592b24..641710f 100644 --- a/types/melvor/game/core.d.ts +++ b/types/melvor/game/core.d.ts @@ -1,3 +1,5 @@ +// noinspection JSUnusedGlobalSymbols + import {ActivePrayer, CombatArea, CombatSpell, Dungeon, Pet, PetManager, SlayerArea, SpecialAttack} from 'melvor'; import type {Monster} from './combat'; import {Attack, AttackStyle} from './combat'; diff --git a/types/melvor/game/item.d.ts b/types/melvor/game/item.d.ts index 8b49ffc..dee9644 100644 --- a/types/melvor/game/item.d.ts +++ b/types/melvor/game/item.d.ts @@ -1,3 +1,5 @@ +// noinspection JSUnusedGlobalSymbols + import type {PotionReuseTarget} from './misc'; import type {EquipSlotType} from './toon'; diff --git a/types/melvor/game/misc.d.ts b/types/melvor/game/misc.d.ts index 0a86c4d..0dd3191 100644 --- a/types/melvor/game/misc.d.ts +++ b/types/melvor/game/misc.d.ts @@ -1,3 +1,5 @@ +// noinspection JSUnusedGlobalSymbols + import {CombatArea, Dungeon, Enemy, Monster} from 'melvor/game/combat'; import type {NamespaceRegistry} from './core'; import type {Item, PotionItem} from './item'; diff --git a/types/melvor/game/skilling.d.ts b/types/melvor/game/skilling.d.ts index 3bc5394..2af64fa 100644 --- a/types/melvor/game/skilling.d.ts +++ b/types/melvor/game/skilling.d.ts @@ -1,3 +1,5 @@ +// noinspection JSUnusedGlobalSymbols + import type {BaseSpell, Game, NamespaceRegistry, RuneRequirement} from './core'; import type {Item} from './item'; import type {ItemCost, ShopPurchase} from './misc'; diff --git a/types/melvor/game/toon.d.ts b/types/melvor/game/toon.d.ts index a81ee4b..e184a80 100644 --- a/types/melvor/game/toon.d.ts +++ b/types/melvor/game/toon.d.ts @@ -1,3 +1,5 @@ +// noinspection JSUnusedGlobalSymbols + import {AttackStyle, AttackTypeID, CombatSpell, FoodItem, NamespacedObject} from 'melvor'; import type {EquipmentItem, Item} from './item'; diff --git a/types/melvor/mod.d.ts b/types/melvor/mod.d.ts index 57a99b1..2c62651 100644 --- a/types/melvor/mod.d.ts +++ b/types/melvor/mod.d.ts @@ -1,3 +1,5 @@ +// noinspection JSUnusedGlobalSymbols + import type {Class, InstanceOf} from 'mod-util/class'; export interface ModContext { diff --git a/types/melvor/ui.d.ts b/types/melvor/ui.d.ts index 7d32d88..5d0e670 100644 --- a/types/melvor/ui.d.ts +++ b/types/melvor/ui.d.ts @@ -1,3 +1,5 @@ +// noinspection JSUnusedGlobalSymbols + export interface SidebarContext { category(id: string, config?: CategoryConfig, builder?: (cat: Category) => void): Category; }