From 6bf7b0055765c4f2011c9614753d6714dc09be65 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 14 Feb 2024 22:26:29 -0500 Subject: Eslint rule updates (#673) * Install unicorn * Add rules * Fix issues * Install sonarjs * Set up rules * Fix issues * Install eslint-plugin-import and fix import extensions * Simplify permitted error names --- ext/js/language/ja/japanese.js | 2 +- ext/js/language/text-scanner.js | 8 +++----- ext/js/language/translator.js | 12 ++++++------ 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'ext/js/language') diff --git a/ext/js/language/ja/japanese.js b/ext/js/language/ja/japanese.js index a4508040..818daa0b 100644 --- a/ext/js/language/ja/japanese.js +++ b/ext/js/language/ja/japanese.js @@ -92,7 +92,7 @@ const JAPANESE_RANGES = [ [0xffe0, 0xffee] // Currency markers ]; -const SMALL_KANA_SET = new Set(Array.from('ぁぃぅぇぉゃゅょゎァィゥェォャュョヮ')); +const SMALL_KANA_SET = new Set('ぁぃぅぇぉゃゅょゎァィゥェォャュョヮ'); const HALFWIDTH_KATAKANA_MAPPING = new Map([ ['ヲ', 'ヲヺ-'], diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js index 811c7987..1cf346a9 100644 --- a/ext/js/language/text-scanner.js +++ b/ext/js/language/text-scanner.js @@ -1294,11 +1294,9 @@ export class TextScanner extends EventDispatcher { async _searchAtFromMouseMove(x, y, inputInfo) { if (this._pendingLookup) { return; } - if (inputInfo.passive) { - if (!await this._scanTimerWait()) { - // Aborted - return; - } + if (inputInfo.passive && !await this._scanTimerWait()) { + // Aborted + return; } await this._searchAt(x, y, inputInfo); diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 007a7d1e..2ba1ce0d 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -491,11 +491,11 @@ export class Translator { * @returns {number} */ _getNextSubstringLength(searchResolution, currentLength, source) { - if (searchResolution === 'word') { - return source.search(/[^\p{Letter}][\p{Letter}\p{Number}]*$/u); - } else { - return currentLength - 1; - } + return ( + searchResolution === 'word' ? + source.search(/[^\p{Letter}][\p{Letter}\p{Number}]*$/u) : + currentLength - 1 + ); } /** @@ -620,7 +620,7 @@ export class Translator { for (const group of groupedDictionaryEntries) { this._sortTermDictionaryEntriesById(group.dictionaryEntries); } - if (ungroupedDictionaryEntriesMap.size !== 0 || secondarySearchDictionaryMap.size !== 0) { + if (ungroupedDictionaryEntriesMap.size > 0 || secondarySearchDictionaryMap.size > 0) { await this._addSecondaryRelatedDictionaryEntries(groupedDictionaryEntries, ungroupedDictionaryEntriesMap, enabledDictionaryMap, secondarySearchDictionaryMap, tagAggregator); } } -- cgit v1.2.3