From 669ba2fd36dd6d3a52380fd1c8ae8e903d653fe7 Mon Sep 17 00:00:00 2001 From: ceruleandeep Date: Thu, 21 Nov 2024 21:24:16 +1100 Subject: [PATCH] Unrelated linting --- .../scripts/slash-commands/SlashCommandBrowser.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/public/scripts/slash-commands/SlashCommandBrowser.js b/public/scripts/slash-commands/SlashCommandBrowser.js index 51b0bac1b..6b3cb7816 100644 --- a/public/scripts/slash-commands/SlashCommandBrowser.js +++ b/public/scripts/slash-commands/SlashCommandBrowser.js @@ -1,5 +1,4 @@ import { escapeRegex } from '../utils.js'; -import { SlashCommand } from './SlashCommand.js'; import { SlashCommandParser } from './SlashCommandParser.js'; export class SlashCommandBrowser { @@ -12,7 +11,7 @@ export class SlashCommandBrowser { renderInto(parent) { if (!this.dom) { - const queryRegex = /(?:(?:^|\s+)([^\s"][^\s]*?)(?:\s+|$))|(?:(?:^|\s+)"(.*?)(?:"|$)(?:\s+|$))/; + const queryRegex = /(?:^|\s+)([^\s"]\S*?)(?:\s+|$)|(?:^|\s+)"(.*?)(?:"|$)(?:\s+|$)/; const root = document.createElement('div'); { this.dom = root; const search = document.createElement('div'); { @@ -30,7 +29,7 @@ export class SlashCommandBrowser { this.details?.remove(); this.details = null; let query = inp.value.trim(); - if (query.slice(-1) == '"' && !/(?:^|\s+)"/.test(query)) { + if (query.slice(-1) === '"' && !/(?:^|\s+)"/.test(query)) { query = `"${query}`; } let fuzzyList = []; @@ -59,7 +58,7 @@ export class SlashCommandBrowser { cmd.helpString, ]; const find = ()=>targets.find(t=>(fuzzyList.find(f=>f.test(t)) ?? quotedList.find(q=>t.includes(q))) !== undefined) !== undefined; - if (fuzzyList.length + quotedList.length == 0 || find()) { + if (fuzzyList.length + quotedList.length === 0 || find()) { this.itemMap[cmd.name].classList.remove('isFiltered'); } else { this.itemMap[cmd.name].classList.add('isFiltered'); @@ -78,7 +77,7 @@ export class SlashCommandBrowser { list.classList.add('autoComplete'); this.cmdList = Object .keys(SlashCommandParser.commands) - .filter(key => SlashCommandParser.commands[key].name == key) // exclude aliases + .filter(key => SlashCommandParser.commands[key].name === key) // exclude aliases .sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())) .map(key => SlashCommandParser.commands[key]) ; @@ -97,7 +96,7 @@ export class SlashCommandBrowser { } } } - if (this.details != details) { + if (this.details !== details) { Array.from(list.querySelectorAll('.selected')).forEach(it=>it.classList.remove('selected')); item.classList.add('selected'); this.details?.remove(); @@ -124,7 +123,7 @@ export class SlashCommandBrowser { parent.append(this.dom); this.mo = new MutationObserver(muts=>{ - if (muts.find(mut=>Array.from(mut.removedNodes).find(it=>it == this.dom || it.contains(this.dom)))) { + if (muts.find(mut=>Array.from(mut.removedNodes).find(it=>it === this.dom || it.contains(this.dom)))) { this.mo.disconnect(); window.removeEventListener('keydown', boundHandler); } @@ -136,7 +135,7 @@ export class SlashCommandBrowser { } handleKeyDown(evt) { - if (!evt.shiftKey && !evt.altKey && evt.ctrlKey && evt.key.toLowerCase() == 'f') { + if (!evt.shiftKey && !evt.altKey && evt.ctrlKey && evt.key.toLowerCase() === 'f') { if (!this.dom.closest('body')) return; if (this.dom.closest('.mes') && !this.dom.closest('.last_mes')) return; evt.preventDefault();