From 73169f06dff767020718a5715eba97d3575ba7e1 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 24 Feb 2024 23:47:57 -0500 Subject: Turn on @typescript-eslint/no-unsafe-argument (#728) --- ext/js/input/hotkey-help-controller.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'ext/js/input') diff --git a/ext/js/input/hotkey-help-controller.js b/ext/js/input/hotkey-help-controller.js index dbb430dc..1fa9372f 100644 --- a/ext/js/input/hotkey-help-controller.js +++ b/ext/js/input/hotkey-help-controller.js @@ -89,10 +89,10 @@ export class HotkeyHelpController { // Private /** - * @param {Map} commandMap + * @returns {Promise} */ - async _setupGlobalCommands(commandMap) { - const commands = await new Promise((resolve, reject) => { + _getAllCommands() { + return new Promise((resolve, reject) => { if (!(isObject(chrome.commands) && typeof chrome.commands.getAll === 'function')) { resolve([]); return; @@ -107,10 +107,17 @@ export class HotkeyHelpController { } }); }); + } + + /** + * @param {Map} commandMap + */ + async _setupGlobalCommands(commandMap) { + const commands = await this._getAllCommands(); commandMap.clear(); for (const {name, shortcut} of commands) { - if (shortcut.length === 0) { continue; } + if (typeof name !== 'string' || typeof shortcut !== 'string' || shortcut.length === 0) { continue; } const {key, modifiers} = this._hotkeyUtil.convertCommandToInput(shortcut); commandMap.set(name, this._hotkeyUtil.getInputDisplayValue(key, modifiers)); } -- cgit v1.2.3