diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-12-16 20:04:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-17 01:04:56 +0000 |
commit | b249627434d3a94420ac4d98c3ce720767e57b43 (patch) | |
tree | ec46e2c020c5a63a5c2babf56376f53e288ed7f2 /ext/js | |
parent | decbc60f7734e739c0e5c41da294f65f9eec92fe (diff) |
Update eslint spacing rules (#366)
* Add space-infix-ops rule
* Add no-multi-spaces
---------
Co-authored-by: Darius Jahandarie <djahandarie@gmail.com>
Diffstat (limited to 'ext/js')
46 files changed, 130 insertions, 95 deletions
diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js index e1f8d8c9..a1bbb217 100644 --- a/ext/js/app/frontend.js +++ b/ext/js/app/frontend.js @@ -41,9 +41,9 @@ export class Frontend { parentPopupId, parentFrameId, useProxyPopup, - canUseWindowPopup=true, + canUseWindowPopup = true, allowRootFramePopupProxy, - childrenSupported=true, + childrenSupported = true, hotkeyHandler }) { /** @type {import('frontend').PageType} */ @@ -106,6 +106,7 @@ export class Frontend { /** @type {?import('settings').OptionsContext} */ this._optionsContextOverride = null; + /* eslint-disable no-multi-spaces */ /** @type {import('core').MessageHandlerMap} */ this._runtimeMessageHandlers = new Map(/** @type {import('core').MessageHandlerArray} */ ([ ['Frontend.requestReadyBroadcast', {async: false, handler: this._onMessageRequestFrontendReadyBroadcast.bind(this)}], @@ -117,6 +118,7 @@ export class Frontend { ['scanSelectedText', this._onActionScanSelectedText.bind(this)], ['scanTextAtCaret', this._onActionScanTextAtCaret.bind(this)] ]); + /* eslint-enable no-multi-spaces */ } /** @@ -174,6 +176,7 @@ export class Frontend { this._textScanner.on('clear', this._onTextScannerClear.bind(this)); this._textScanner.on('searched', this._onSearched.bind(this)); + /* eslint-disable no-multi-spaces */ yomitan.crossFrame.registerHandlers([ ['Frontend.closePopup', {async: false, handler: this._onApiClosePopup.bind(this)}], ['Frontend.copySelection', {async: false, handler: this._onApiCopySelection.bind(this)}], @@ -181,6 +184,7 @@ export class Frontend { ['Frontend.getPopupInfo', {async: false, handler: this._onApiGetPopupInfo.bind(this)}], ['Frontend.getPageInfo', {async: false, handler: this._onApiGetPageInfo.bind(this)}] ]); + /* eslint-enable no-multi-spaces */ this._prepareSiteSpecific(); this._updateContentScale(); diff --git a/ext/js/app/popup-factory.js b/ext/js/app/popup-factory.js index 6fa50796..41984841 100644 --- a/ext/js/app/popup-factory.js +++ b/ext/js/app/popup-factory.js @@ -47,6 +47,7 @@ export class PopupFactory { */ prepare() { this._frameOffsetForwarder.prepare(); + /* eslint-disable no-multi-spaces */ yomitan.crossFrame.registerHandlers([ ['PopupFactory.getOrCreatePopup', {async: true, handler: this._onApiGetOrCreatePopup.bind(this)}], ['PopupFactory.setOptionsContext', {async: true, handler: this._onApiSetOptionsContext.bind(this)}], @@ -64,6 +65,7 @@ export class PopupFactory { ['PopupFactory.getFrameSize', {async: true, handler: this._onApiGetFrameSize.bind(this)}], ['PopupFactory.setFrameSize', {async: true, handler: this._onApiSetFrameSize.bind(this)}] ]); + /* eslint-enable no-multi-spaces */ } /** @@ -72,12 +74,12 @@ export class PopupFactory { * @returns {Promise<import('popup').PopupAny>} */ async getOrCreatePopup({ - frameId=null, - id=null, - parentPopupId=null, - depth=null, - popupWindow=false, - childrenSupported=false + frameId = null, + id = null, + parentPopupId = null, + depth = null, + popupWindow = false, + childrenSupported = false }) { // Find by existing id if (id !== null) { diff --git a/ext/js/app/popup.js b/ext/js/app/popup.js index 7419785b..a2aa204a 100644 --- a/ext/js/app/popup.js +++ b/ext/js/app/popup.js @@ -718,7 +718,7 @@ export class Popup extends EventDispatcher { * @param {string} action * @param {import('core').SerializableObject} params */ - _invokeWindow(action, params={}) { + _invokeWindow(action, params = {}) { const contentWindow = this._frame.contentWindow; if (this._frameClient === null || !this._frameClient.isConnected() || contentWindow === null) { return; } diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 3eefed53..749c81a6 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -147,6 +147,7 @@ export class Backend { /** @type {PermissionsUtil} */ this._permissionsUtil = new PermissionsUtil(); + /* eslint-disable no-multi-spaces */ /** @type {import('backend').MessageHandlerMap} */ this._messageHandlers = new Map(/** @type {import('backend').MessageHandlerMapInit} */ ([ ['requestBackendReadySignal', {async: false, contentScript: true, handler: this._onApiRequestBackendReadySignal.bind(this)}], @@ -193,6 +194,7 @@ export class Backend { ['loadExtensionScripts', {async: true, contentScript: true, handler: this._onApiLoadExtensionScripts.bind(this)}], ['openCrossFramePort', {async: false, contentScript: true, handler: this._onApiOpenCrossFramePort.bind(this)}] ])); + /* eslint-enable no-multi-spaces */ /** @type {import('backend').MessageHandlerWithProgressMap} */ this._messageHandlersWithProgress = new Map(/** @type {import('backend').MessageHandlerWithProgressMapInit} */ ([ // Empty @@ -201,10 +203,10 @@ export class Backend { /** @type {Map<string, (params?: import('core').SerializableObject) => void>} */ this._commandHandlers = new Map(/** @type {[name: string, handler: (params?: import('core').SerializableObject) => void][]} */ ([ ['toggleTextScanning', this._onCommandToggleTextScanning.bind(this)], - ['openInfoPage', this._onCommandOpenInfoPage.bind(this)], - ['openSettingsPage', this._onCommandOpenSettingsPage.bind(this)], - ['openSearchPage', this._onCommandOpenSearchPage.bind(this)], - ['openPopupWindow', this._onCommandOpenPopupWindow.bind(this)] + ['openInfoPage', this._onCommandOpenInfoPage.bind(this)], + ['openSettingsPage', this._onCommandOpenSettingsPage.bind(this)], + ['openSearchPage', this._onCommandOpenSearchPage.bind(this)], + ['openPopupWindow', this._onCommandOpenPopupWindow.bind(this)] ])); } @@ -805,7 +807,7 @@ export class Backend { } /** @type {import('api').Handler<import('api').GetOrCreateSearchPopupDetails, import('api').GetOrCreateSearchPopupResult>} */ - async _onApiGetOrCreateSearchPopup({focus=false, text}) { + async _onApiGetOrCreateSearchPopup({focus = false, text}) { const {tab, created} = await this._getOrCreateSearchPopup(); if (focus === true || (focus === 'ifCreated' && created)) { await this._focusTab(tab); @@ -1979,7 +1981,7 @@ export class Backend { * @param {?number} [timeout=null] * @returns {Promise<void>} */ - _waitUntilTabFrameIsReady(tabId, frameId, timeout=null) { + _waitUntilTabFrameIsReady(tabId, frameId, timeout = null) { return new Promise((resolve, reject) => { /** @type {?import('core').Timeout} */ let timer = null; diff --git a/ext/js/background/offscreen.js b/ext/js/background/offscreen.js index 4b57514d..85b6847b 100644 --- a/ext/js/background/offscreen.js +++ b/ext/js/background/offscreen.js @@ -50,6 +50,7 @@ export class Offscreen { richContentPasteTargetSelector: '#clipboard-rich-content-paste-target' }); + /* eslint-disable no-multi-spaces */ /** @type {import('offscreen').MessageHandlerMap} */ const messageHandlers = new Map([ ['clipboardGetTextOffscreen', {async: true, handler: this._getTextHandler.bind(this)}], @@ -65,6 +66,7 @@ export class Offscreen { ['getTermFrequenciesOffscreen', {async: true, handler: this._getTermFrequenciesHandler.bind(this)}], ['clearDatabaseCachesOffscreen', {async: false, handler: this._clearDatabaseCachesHandler.bind(this)}] ]); + /* eslint-enable no-multi-spaces */ /** @type {import('offscreen').MessageHandlerMap<string>} */ this._messageHandlers = messageHandlers; diff --git a/ext/js/background/profile-conditions-util.js b/ext/js/background/profile-conditions-util.js index ceade070..b1bbe1d5 100644 --- a/ext/js/background/profile-conditions-util.js +++ b/ext/js/background/profile-conditions-util.js @@ -34,11 +34,11 @@ export class ProfileConditionsUtil { 'popupLevel', { operators: new Map(/** @type {import('profile-conditions-util').OperatorMapArray} */ ([ - ['equal', this._createSchemaPopupLevelEqual.bind(this)], - ['notEqual', this._createSchemaPopupLevelNotEqual.bind(this)], - ['lessThan', this._createSchemaPopupLevelLessThan.bind(this)], - ['greaterThan', this._createSchemaPopupLevelGreaterThan.bind(this)], - ['lessThanOrEqual', this._createSchemaPopupLevelLessThanOrEqual.bind(this)], + ['equal', this._createSchemaPopupLevelEqual.bind(this)], + ['notEqual', this._createSchemaPopupLevelNotEqual.bind(this)], + ['lessThan', this._createSchemaPopupLevelLessThan.bind(this)], + ['greaterThan', this._createSchemaPopupLevelGreaterThan.bind(this)], + ['lessThanOrEqual', this._createSchemaPopupLevelLessThanOrEqual.bind(this)], ['greaterThanOrEqual', this._createSchemaPopupLevelGreaterThanOrEqual.bind(this)] ])) } diff --git a/ext/js/comm/anki-connect.js b/ext/js/comm/anki-connect.js index 7ff8d0e1..bd9a69a2 100644 --- a/ext/js/comm/anki-connect.js +++ b/ext/js/comm/anki-connect.js @@ -318,7 +318,7 @@ export class AnkiConnect { * @param {?string[]} actions A list of actions to check for * @returns {Promise<import('anki').ApiReflectResult>} Information about the APIs. */ - async apiReflect(scopes, actions=null) { + async apiReflect(scopes, actions = null) { const result = await this._invoke('apiReflect', {scopes, actions}); if (!(typeof result === 'object' && result !== null)) { throw this._createUnexpectedResultError('object', result); diff --git a/ext/js/comm/api.js b/ext/js/comm/api.js index 26218595..35a66d9e 100644 --- a/ext/js/comm/api.js +++ b/ext/js/comm/api.js @@ -482,7 +482,7 @@ export class API { * @param {number} [timeout] * @returns {Promise<TReturn>} */ - _invokeWithProgress(action, params, onProgress0, timeout=5000) { + _invokeWithProgress(action, params, onProgress0, timeout = 5000) { return new Promise((resolve, reject) => { /** @type {?chrome.runtime.Port} */ let port = null; @@ -554,7 +554,7 @@ export class API { * @param {import('core').SerializableObject} [params] * @returns {Promise<TReturn>} */ - _invoke(action, params={}) { + _invoke(action, params = {}) { const data = {action, params}; return new Promise((resolve, reject) => { try { diff --git a/ext/js/comm/clipboard-reader.js b/ext/js/comm/clipboard-reader.js index 364e31a3..a6d1c068 100644 --- a/ext/js/comm/clipboard-reader.js +++ b/ext/js/comm/clipboard-reader.js @@ -26,7 +26,7 @@ export class ClipboardReader { * Creates a new instances of a clipboard reader. * @param {{document: ?Document, pasteTargetSelector: ?string, richContentPasteTargetSelector: ?string}} details Details about how to set up the instance. */ - constructor({document=null, pasteTargetSelector=null, richContentPasteTargetSelector=null}) { + constructor({document = null, pasteTargetSelector = null, richContentPasteTargetSelector = null}) { /** @type {?Document} */ this._document = document; /** @type {?import('environment').Browser} */ diff --git a/ext/js/comm/frame-ancestry-handler.js b/ext/js/comm/frame-ancestry-handler.js index e4d08f28..b91046bc 100644 --- a/ext/js/comm/frame-ancestry-handler.js +++ b/ext/js/comm/frame-ancestry-handler.js @@ -109,7 +109,7 @@ export class FrameAncestryHandler { * @param {number} [timeout] * @returns {Promise<number[]>} */ - _getFrameAncestryInfo(timeout=5000) { + _getFrameAncestryInfo(timeout = 5000) { return new Promise((resolve, reject) => { const targetWindow = window.parent; if (window === targetWindow) { diff --git a/ext/js/comm/frame-client.js b/ext/js/comm/frame-client.js index 8aa8c6d6..b07bb796 100644 --- a/ext/js/comm/frame-client.js +++ b/ext/js/comm/frame-client.js @@ -41,7 +41,7 @@ export class FrameClient { * @param {import('frame-client').SetupFrameFunction} setupFrame * @param {number} [timeout] */ - async connect(frame, targetOrigin, hostFrameId, setupFrame, timeout=10000) { + async connect(frame, targetOrigin, hostFrameId, setupFrame, timeout = 10000) { const {secret, token, frameId} = await this._connectInternal(frame, targetOrigin, hostFrameId, setupFrame, timeout); this._secret = secret; this._token = token; diff --git a/ext/js/core.js b/ext/js/core.js index 14d0ef56..5c0c964b 100644 --- a/ext/js/core.js +++ b/ext/js/core.js @@ -600,7 +600,7 @@ export class DynamicProperty extends EventDispatcher { * @returns {import('core').TokenString} A string token which can be passed to the clearOverride function * to remove the override. */ - setOverride(value, priority=0) { + setOverride(value, priority = 0) { const overridesCount = this._overrides.length; let i = 0; for (; i < overridesCount; ++i) { @@ -670,7 +670,7 @@ export class Logger extends EventDispatcher { * Other values will be logged at a non-error level. * @param {?import('log').LogContext} [context] An optional context object for the error which should typically include a `url` field. */ - log(error, level, context=null) { + log(error, level, context = null) { if (typeof context !== 'object' || context === null) { context = {url: location.href}; } @@ -745,7 +745,7 @@ export class Logger extends EventDispatcher { * @param {unknown} error The error to log. This is typically an `Error` or `Error`-like object. * @param {?import('log').LogContext} context An optional context object for the error which should typically include a `url` field. */ - warn(error, context=null) { + warn(error, context = null) { this.log(error, 'warn', context); } @@ -754,7 +754,7 @@ export class Logger extends EventDispatcher { * @param {unknown} error The error to log. This is typically an `Error` or `Error`-like object. * @param {?import('log').LogContext} context An optional context object for the error which should typically include a `url` field. */ - error(error, context=null) { + error(error, context = null) { this.log(error, 'error', context); } } diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index 4920db39..864bd2d4 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -51,15 +51,15 @@ export class AnkiNoteBuilder { deckName, modelName, fields, - tags=[], - requirements=[], - checkForDuplicates=true, - duplicateScope='collection', - duplicateScopeCheckAllModels=false, - resultOutputMode='split', - glossaryLayoutMode='default', - compactTags=false, - mediaOptions=null + tags = [], + requirements = [], + checkForDuplicates = true, + duplicateScope = 'collection', + duplicateScopeCheckAllModels = false, + resultOutputMode = 'split', + glossaryLayoutMode = 'default', + compactTags = false, + mediaOptions = null }) { let duplicateScopeDeckName = null; let duplicateScopeCheckChildren = false; @@ -130,9 +130,9 @@ export class AnkiNoteBuilder { dictionaryEntry, mode, context, - resultOutputMode='split', - glossaryLayoutMode='default', - compactTags=false, + resultOutputMode = 'split', + glossaryLayoutMode = 'default', + compactTags = false, marker }) { const commonData = this._createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, void 0); diff --git a/ext/js/data/database.js b/ext/js/data/database.js index 026945ca..8b9e7354 100644 --- a/ext/js/data/database.js +++ b/ext/js/data/database.js @@ -265,7 +265,7 @@ export class Database { * @param {?(completedCount: number, totalCount: number) => void} onProgress * @returns {Promise<void>} */ - bulkDelete(objectStoreName, indexName, query, filterKeys=null, onProgress=null) { + bulkDelete(objectStoreName, indexName, query, filterKeys = null, onProgress = null) { return new Promise((resolve, reject) => { const transaction = this._readWriteTransaction([objectStoreName], resolve, reject); const objectStore = transaction.objectStore(objectStoreName); diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 70c1622f..c3c0e685 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -39,7 +39,7 @@ export class OptionsUtil { * @param {?number} [targetVersion] * @returns {Promise<import('settings').Options>} */ - async update(optionsInput, targetVersion=null) { + async update(optionsInput, targetVersion = null) { // Invalid options let options = /** @type {{[key: string]: unknown}} */ ( typeof optionsInput === 'object' && optionsInput !== null && !Array.isArray(optionsInput) ? @@ -530,6 +530,7 @@ export class OptionsUtil { * @returns {import('options-util').ModernUpdate[]} */ _getVersionUpdates(targetVersion) { + /* eslint-disable no-multi-spaces */ const result = [ {async: false, update: this._updateVersion1.bind(this)}, {async: false, update: this._updateVersion2.bind(this)}, @@ -553,6 +554,7 @@ export class OptionsUtil { {async: false, update: this._updateVersion20.bind(this)}, {async: true, update: this._updateVersion21.bind(this)} ]; + /* eslint-enable no-multi-spaces */ if (typeof targetVersion === 'number' && targetVersion < result.length) { result.splice(targetVersion); } @@ -818,6 +820,7 @@ export class OptionsUtil { }; delete profile.options.anki.sentenceExt; profile.options.general.popupActionBarLocation = 'top'; + /* eslint-disable no-multi-spaces */ profile.options.inputs = { hotkeys: [ {action: 'close', key: 'Escape', modifiers: [], scopes: ['popup'], enabled: true}, @@ -838,6 +841,7 @@ export class OptionsUtil { {action: 'copyHostSelection', key: 'KeyC', modifiers: ['ctrl'], scopes: ['popup'], enabled: true} ] }; + /* eslint-enable no-multi-spaces */ profile.options.anki.suspendNewCards = false; profile.options.popupWindow = { width: profile.options.general.popupWidth, diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js index 81791285..322237da 100644 --- a/ext/js/display/display-anki.js +++ b/ext/js/display/display-anki.js @@ -108,12 +108,14 @@ export class DisplayAnki { /** */ prepare() { this._noteContext = this._getNoteContext(); + /* eslint-disable no-multi-spaces */ this._display.hotkeyHandler.registerActions([ ['addNoteKanji', () => { this._tryAddAnkiNoteForSelectedEntry('kanji'); }], ['addNoteTermKanji', () => { this._tryAddAnkiNoteForSelectedEntry('term-kanji'); }], ['addNoteTermKana', () => { this._tryAddAnkiNoteForSelectedEntry('term-kana'); }], ['viewNote', this._viewNoteForSelectedEntry.bind(this)] ]); + /* eslint-enable no-multi-spaces */ this._display.on('optionsUpdated', this._onOptionsUpdated.bind(this)); this._display.on('contentClear', this._onContentClear.bind(this)); this._display.on('contentUpdateStart', this._onContentUpdateStart.bind(this)); diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js index 1f279030..8cd1ccc3 100644 --- a/ext/js/display/display-audio.js +++ b/ext/js/display/display-audio.js @@ -83,6 +83,7 @@ export class DisplayAudio { /** */ prepare() { this._audioSystem.prepare(); + /* eslint-disable no-multi-spaces */ this._display.hotkeyHandler.registerActions([ ['playAudio', this._onHotkeyActionPlayAudio.bind(this)], ['playAudioFromSource', this._onHotkeyActionPlayAudioFromSource.bind(this)] @@ -90,6 +91,7 @@ export class DisplayAudio { this._display.registerDirectMessageHandlers([ ['Display.clearAutoPlayTimer', {async: false, handler: this._onMessageClearAutoPlayTimer.bind(this)}] ]); + /* eslint-enable no-multi-spaces */ this._display.on('optionsUpdated', this._onOptionsUpdated.bind(this)); this._display.on('contentClear', this._onContentClear.bind(this)); this._display.on('contentUpdateEntry', this._onContentUpdateEntry.bind(this)); @@ -120,7 +122,7 @@ export class DisplayAudio { * @param {number} headwordIndex * @param {?string} [sourceType] */ - async playAudio(dictionaryEntryIndex, headwordIndex, sourceType=null) { + async playAudio(dictionaryEntryIndex, headwordIndex, sourceType = null) { let sources = this._audioSources; if (sourceType !== null) { sources = []; diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index eb464001..7bedfa12 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -28,7 +28,7 @@ export class DisplayGenerator { /** * @param {import('display').DisplayGeneratorConstructorDetails} details */ - constructor({japaneseUtil, contentManager, hotkeyHelpController=null}) { + constructor({japaneseUtil, contentManager, hotkeyHelpController = null}) { /** @type {import('../language/sandbox/japanese-util.js').JapaneseUtil} */ this._japaneseUtil = japaneseUtil; /** @type {import('./display-content-manager.js').DisplayContentManager} */ diff --git a/ext/js/display/display-history.js b/ext/js/display/display-history.js index f9d2e35d..af6d734e 100644 --- a/ext/js/display/display-history.js +++ b/ext/js/display/display-history.js @@ -25,7 +25,7 @@ export class DisplayHistory extends EventDispatcher { /** * @param {{clearable?: boolean, useBrowserHistory?: boolean}} details */ - constructor({clearable=true, useBrowserHistory=false}) { + constructor({clearable = true, useBrowserHistory = false}) { super(); /** @type {boolean} */ this._clearable = clearable; diff --git a/ext/js/display/display-notification.js b/ext/js/display/display-notification.js index a0e9e35c..df475adf 100644 --- a/ext/js/display/display-notification.js +++ b/ext/js/display/display-notification.js @@ -67,7 +67,7 @@ export class DisplayNotification { /** * @param {boolean} [animate] */ - close(animate=false) { + close(animate = false) { if (this.isClosed()) { return; } if (animate) { diff --git a/ext/js/display/display.js b/ext/js/display/display.js index b6a818ba..945ec0b9 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -196,6 +196,7 @@ export class Display extends EventDispatcher { /** @type {ThemeController} */ this._themeController = new ThemeController(document.documentElement); + /* eslint-disable no-multi-spaces */ this._hotkeyHandler.registerActions([ ['close', () => { this._onHotkeyClose(); }], ['nextEntry', this._onHotkeyActionMoveRelative.bind(this, 1)], @@ -219,6 +220,7 @@ export class Display extends EventDispatcher { this.registerWindowMessageHandlers([ ['Display.extensionUnloaded', {async: false, handler: this._onMessageExtensionUnloaded.bind(this)}] ]); + /* eslint-enable no-multi-spaces */ } /** @type {DisplayGenerator} */ @@ -586,7 +588,7 @@ export class Display extends EventDispatcher { * @param {import('core').SerializableObject} [params] * @returns {Promise<TReturn>} */ - async invokeContentOrigin(action, params={}) { + async invokeContentOrigin(action, params = {}) { if (this._contentOriginTabId === this._tabId && this._contentOriginFrameId === this._frameId) { throw new Error('Content origin is same page'); } @@ -602,7 +604,7 @@ export class Display extends EventDispatcher { * @param {import('core').SerializableObject} [params] * @returns {Promise<TReturn>} */ - async invokeParentFrame(action, params={}) { + async invokeParentFrame(action, params = {}) { if (this._parentFrameId === null || this._parentFrameId === this._frameId) { throw new Error('Invalid parent frame'); } diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index b512a16d..44850cbb 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -94,11 +94,13 @@ export class SearchDisplayController { this._display.hotkeyHandler.registerActions([ ['focusSearchBox', this._onActionFocusSearchBox.bind(this)] ]); + /* eslint-disable no-multi-spaces */ this._registerMessageHandlers([ ['SearchDisplayController.getMode', {async: false, handler: this._onMessageGetMode.bind(this)}], ['SearchDisplayController.setMode', {async: false, handler: this._onMessageSetMode.bind(this)}], ['SearchDisplayController.updateSearchQuery', {async: false, handler: this._onExternalSearchUpdate.bind(this)}] ]); + /* eslint-enable no-multi-spaces */ this._updateClipboardMonitorEnabled(); @@ -285,7 +287,7 @@ export class SearchDisplayController { /** * @param {{text: string, animate?: boolean}} details */ - _onExternalSearchUpdate({text, animate=true}) { + _onExternalSearchUpdate({text, animate = true}) { const options = this._display.getOptions(); if (options === null) { return; } const {clipboard: {autoSearchContent, maximumSearchLength}} = options; diff --git a/ext/js/dom/document-focus-controller.js b/ext/js/dom/document-focus-controller.js index 32ea2ce8..fd88a35d 100644 --- a/ext/js/dom/document-focus-controller.js +++ b/ext/js/dom/document-focus-controller.js @@ -28,7 +28,7 @@ export class DocumentFocusController { * @param {?string} autofocusElementSelector A selector string which can be used to specify an element which * should be automatically focused on prepare. */ - constructor(autofocusElementSelector=null) { + constructor(autofocusElementSelector = null) { /** @type {?HTMLElement} */ this._autofocusElement = (autofocusElementSelector !== null ? document.querySelector(autofocusElementSelector) : null); /** @type {?HTMLElement} */ diff --git a/ext/js/dom/document-util.js b/ext/js/dom/document-util.js index 0153e74a..fe10d670 100644 --- a/ext/js/dom/document-util.js +++ b/ext/js/dom/document-util.js @@ -349,7 +349,7 @@ export class DocumentUtil { * @param {EventListener} onFullscreenChanged The event callback. * @param {?import('../core.js').EventListenerCollection} eventListenerCollection An optional `EventListenerCollection` to add the registration to. */ - static addFullscreenChangeEventListener(onFullscreenChanged, eventListenerCollection=null) { + static addFullscreenChangeEventListener(onFullscreenChanged, eventListenerCollection = null) { const target = document; const options = false; const fullscreenEventNames = [ diff --git a/ext/js/dom/dom-data-binder.js b/ext/js/dom/dom-data-binder.js index cf98a243..e2558338 100644 --- a/ext/js/dom/dom-data-binder.js +++ b/ext/js/dom/dom-data-binder.js @@ -27,7 +27,7 @@ export class DOMDataBinder { /** * @param {import('dom-data-binder').ConstructorDetails<T>} details */ - constructor({selector, createElementMetadata, compareElementMetadata, getValues, setValues, onError=null}) { + constructor({selector, createElementMetadata, compareElementMetadata, getValues, setValues, onError = null}) { /** @type {string} */ this._selector = selector; /** @type {import('dom-data-binder').CreateElementMetadataCallback<T>} */ diff --git a/ext/js/dom/dom-text-scanner.js b/ext/js/dom/dom-text-scanner.js index 42e0acc9..df097688 100644 --- a/ext/js/dom/dom-text-scanner.js +++ b/ext/js/dom/dom-text-scanner.js @@ -31,7 +31,7 @@ export class DOMTextScanner { * regardless of CSS styling. * @param {boolean} generateLayoutContent Whether or not newlines should be added based on CSS styling. */ - constructor(node, offset, forcePreserveWhitespace=false, generateLayoutContent=true) { + constructor(node, offset, forcePreserveWhitespace = false, generateLayoutContent = true) { const ruby = DOMTextScanner.getParentRubyElement(node); const resetOffset = (ruby !== null); if (resetOffset) { node = ruby; } diff --git a/ext/js/dom/panel-element.js b/ext/js/dom/panel-element.js index 748c3a36..d4cb28fd 100644 --- a/ext/js/dom/panel-element.js +++ b/ext/js/dom/panel-element.js @@ -57,7 +57,7 @@ export class PanelElement extends EventDispatcher { * @param {boolean} value * @param {boolean} [animate] */ - setVisible(value, animate=true) { + setVisible(value, animate = true) { value = !!value; if (this.isVisible() === value) { return; } diff --git a/ext/js/dom/popup-menu.js b/ext/js/dom/popup-menu.js index 33cdd1ae..72df82a0 100644 --- a/ext/js/dom/popup-menu.js +++ b/ext/js/dom/popup-menu.js @@ -96,7 +96,7 @@ export class PopupMenu extends EventDispatcher { * @param {boolean} [cancelable] * @returns {boolean} */ - close(cancelable=true) { + close(cancelable = true) { return this._close(null, 'close', cancelable, null); } diff --git a/ext/js/dom/selector-observer.js b/ext/js/dom/selector-observer.js index 2cf46543..8dd18242 100644 --- a/ext/js/dom/selector-observer.js +++ b/ext/js/dom/selector-observer.js @@ -25,7 +25,7 @@ export class SelectorObserver { * Creates a new instance. * @param {import('selector-observer').ConstructorDetails<T>} details The configuration for the object. */ - constructor({selector, ignoreSelector=null, onAdded=null, onRemoved=null, onChildrenUpdated=null, isStale=null}) { + constructor({selector, ignoreSelector = null, onAdded = null, onRemoved = null, onChildrenUpdated = null, isStale = null}) { /** @type {string} */ this._selector = selector; /** @type {?string} */ @@ -65,7 +65,7 @@ export class SelectorObserver { * @throws {Error} An error if element is null. * @throws {Error} An error if an element is already being observed. */ - observe(element, attributes=false) { + observe(element, attributes = false) { if (element === null) { throw new Error('Invalid element'); } diff --git a/ext/js/general/text-source-map.js b/ext/js/general/text-source-map.js index b03f6eb2..cfccf7c9 100644 --- a/ext/js/general/text-source-map.js +++ b/ext/js/general/text-source-map.js @@ -21,7 +21,7 @@ export class TextSourceMap { * @param {string} source * @param {number[]|null} [mapping=null] */ - constructor(source, mapping=null) { + constructor(source, mapping = null) { /** @type {string} */ this._source = source; /** @type {?number[]} */ diff --git a/ext/js/input/hotkey-util.js b/ext/js/input/hotkey-util.js index 10328924..601f5d55 100644 --- a/ext/js/input/hotkey-util.js +++ b/ext/js/input/hotkey-util.js @@ -24,7 +24,7 @@ export class HotkeyUtil { * Creates a new instance. * @param {?import('environment').OperatingSystem} os The operating system for this instance. */ - constructor(os=null) { + constructor(os = null) { /** @type {?import('environment').OperatingSystem} */ this._os = os; /** @type {string} */ diff --git a/ext/js/language/deinflector.js b/ext/js/language/deinflector.js index b7a235d0..537a4556 100644 --- a/ext/js/language/deinflector.js +++ b/ext/js/language/deinflector.js @@ -103,6 +103,8 @@ export class Deinflector { } } + +/* eslint-disable no-multi-spaces */ /** @type {Map<string, import('translation-internal').DeinflectionRuleFlags>} */ // eslint-disable-next-line no-underscore-dangle Deinflector._ruleTypes = new Map([ @@ -114,3 +116,4 @@ Deinflector._ruleTypes = new Map([ ['adj-i', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00100000)], // Adjective i ['iru', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b01000000)] // Intermediate -iru endings for progressive or perfect tense ]); +/* eslint-enable no-multi-spaces */ diff --git a/ext/js/language/dictionary-importer.js b/ext/js/language/dictionary-importer.js index 08fcf86b..dfbd9590 100644 --- a/ext/js/language/dictionary-importer.js +++ b/ext/js/language/dictionary-importer.js @@ -112,11 +112,11 @@ export class DictionaryImporter { const dataBankSchemas = this._getDataBankSchemas(version); // Files - const termFiles = this._getArchiveFiles(fileMap, 'term_bank_?.json'); - const termMetaFiles = this._getArchiveFiles(fileMap, 'term_meta_bank_?.json'); - const kanjiFiles = this._getArchiveFiles(fileMap, 'kanji_bank_?.json'); + const termFiles = this._getArchiveFiles(fileMap, 'term_bank_?.json'); + const termMetaFiles = this._getArchiveFiles(fileMap, 'term_meta_bank_?.json'); + const kanjiFiles = this._getArchiveFiles(fileMap, 'kanji_bank_?.json'); const kanjiMetaFiles = this._getArchiveFiles(fileMap, 'kanji_meta_bank_?.json'); - const tagFiles = this._getArchiveFiles(fileMap, 'tag_bank_?.json'); + const tagFiles = this._getArchiveFiles(fileMap, 'tag_bank_?.json'); // Load data this._progressNextStep(termFiles.length + termMetaFiles.length + kanjiFiles.length + kanjiMetaFiles.length + tagFiles.length); @@ -538,7 +538,7 @@ export class DictionaryImporter { */ const createError = (message) => { const {expression, reading} = entry; - const readingSource = reading.length > 0 ? ` (${reading})`: ''; + const readingSource = reading.length > 0 ? ` (${reading})` : ''; return new Error(`${message} at path ${JSON.stringify(path)} for ${expression}${readingSource} in ${dictionary}`); }; diff --git a/ext/js/language/sandbox/japanese-util.js b/ext/js/language/sandbox/japanese-util.js index 6f4fc8e0..9d36497a 100644 --- a/ext/js/language/sandbox/japanese-util.js +++ b/ext/js/language/sandbox/japanese-util.js @@ -88,7 +88,7 @@ const JAPANESE_RANGES = [ [0xff1a, 0xff1f], // Fullwidth punctuation 2 [0xff3b, 0xff3f], // Fullwidth punctuation 3 [0xff5b, 0xff60], // Fullwidth punctuation 4 - [0xffe0, 0xffee] // Currency markers + [0xffe0, 0xffee] // Currency markers ]; const SMALL_KANA_SET = new Set(Array.from('ぁぃぅぇぉゃゅょゎァィゥェォャュョヮ')); @@ -235,7 +235,7 @@ export class JapaneseUtil { /** * @param {?import('wanakana')|import('../../../lib/wanakana.js')} wanakana */ - constructor(wanakana=null) { + constructor(wanakana = null) { /** @type {?import('wanakana')} */ this._wanakana = /** @type {import('wanakana')} */ (wanakana); } @@ -386,7 +386,7 @@ export class JapaneseUtil { * @param {boolean} [keepProlongedSoundMarks] * @returns {string} */ - convertKatakanaToHiragana(text, keepProlongedSoundMarks=false) { + convertKatakanaToHiragana(text, keepProlongedSoundMarks = false) { let result = ''; const offset = (HIRAGANA_CONVERSION_RANGE[0] - KATAKANA_CONVERSION_RANGE[0]); for (let char of text) { @@ -469,7 +469,7 @@ export class JapaneseUtil { * @param {?import('../../general/text-source-map.js').TextSourceMap} [sourceMap] * @returns {string} */ - convertHalfWidthKanaToFullWidth(text, sourceMap=null) { + convertHalfWidthKanaToFullWidth(text, sourceMap = null) { let result = ''; // This function is safe to use charCodeAt instead of codePointAt, since all @@ -516,7 +516,7 @@ export class JapaneseUtil { * @param {?import('../../general/text-source-map.js').TextSourceMap} sourceMap * @returns {string} */ - convertAlphabeticToKana(text, sourceMap=null) { + convertAlphabeticToKana(text, sourceMap = null) { let part = ''; let result = ''; @@ -679,7 +679,7 @@ export class JapaneseUtil { * @param {?import('../../general/text-source-map.js').TextSourceMap} [sourceMap] * @returns {string} */ - collapseEmphaticSequences(text, fullCollapse, sourceMap=null) { + collapseEmphaticSequences(text, fullCollapse, sourceMap = null) { let result = ''; let collapseCodePoint = -1; const hasSourceMap = (sourceMap !== null); diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js index 3de16f54..800e3697 100644 --- a/ext/js/language/text-scanner.js +++ b/ext/js/language/text-scanner.js @@ -31,12 +31,12 @@ export class TextScanner extends EventDispatcher { constructor({ node, getSearchContext, - ignoreElements=null, - ignorePoint=null, - searchTerms=false, - searchKanji=false, - searchOnClick=false, - searchOnClickOnly=false + ignoreElements = null, + ignorePoint = null, + searchTerms = false, + searchKanji = false, + searchOnClick = false, + searchOnClickOnly = false }) { super(); /** @type {HTMLElement|Window} */ diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js index 94f85416..85803077 100644 --- a/ext/js/pages/settings/backup-controller.js +++ b/ext/js/pages/settings/backup-controller.js @@ -540,7 +540,7 @@ export class BackupController { * @param {string} message * @param {boolean} [isWarning] */ - _databaseExportImportErrorMessage(message, isWarning=false) { + _databaseExportImportErrorMessage(message, isWarning = false) { /** @type {HTMLElement} */ const errorMessageContainer = querySelectorNotNull(document, '#db-ops-error-report'); errorMessageContainer.style.display = 'block'; diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 0d84ccbf..63671feb 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -324,7 +324,7 @@ class DictionaryExtraInfo { node.parentNode.removeChild(node); } } - this._nodes.length =0; + this._nodes.length = 0; } // Private diff --git a/ext/js/pages/settings/keyboard-mouse-input-field.js b/ext/js/pages/settings/keyboard-mouse-input-field.js index f0a53f1a..99af3941 100644 --- a/ext/js/pages/settings/keyboard-mouse-input-field.js +++ b/ext/js/pages/settings/keyboard-mouse-input-field.js @@ -30,7 +30,7 @@ export class KeyboardMouseInputField extends EventDispatcher { * @param {?import('environment').OperatingSystem} os * @param {?(pointerType: string) => boolean} [isPointerTypeSupported] */ - constructor(inputNode, mouseButton, os, isPointerTypeSupported=null) { + constructor(inputNode, mouseButton, os, isPointerTypeSupported = null) { super(); /** @type {HTMLInputElement} */ this._inputNode = inputNode; @@ -65,7 +65,7 @@ export class KeyboardMouseInputField extends EventDispatcher { * @param {boolean} [mouseModifiersSupported] * @param {boolean} [keySupported] */ - prepare(key, modifiers, mouseModifiersSupported=false, keySupported=false) { + prepare(key, modifiers, mouseModifiersSupported = false, keySupported = false) { this.cleanup(); this._mouseModifiersSupported = mouseModifiersSupported; diff --git a/ext/js/pages/settings/keyboard-shortcuts-controller.js b/ext/js/pages/settings/keyboard-shortcuts-controller.js index 0734faa1..cbdae77d 100644 --- a/ext/js/pages/settings/keyboard-shortcuts-controller.js +++ b/ext/js/pages/settings/keyboard-shortcuts-controller.js @@ -46,6 +46,7 @@ export class KeyboardShortcutController { this._stringComparer = new Intl.Collator('en-US'); // Invariant locale /** @type {HTMLElement} */ this._scrollContainer = querySelectorNotNull(document, '#keyboard-shortcuts-modal .modal-body'); + /* eslint-disable no-multi-spaces */ /** @type {Map<string, import('keyboard-shortcut-controller').ActionDetails>} */ this._actionDetails = new Map([ ['', {scopes: new Set()}], @@ -70,6 +71,7 @@ export class KeyboardShortcutController { ['scanTextAtCaret', {scopes: new Set(['web'])}], ['toggleOption', {scopes: new Set(['popup', 'search']), argument: {template: 'hotkey-argument-setting-path', default: ''}}] ]); + /* eslint-enable no-multi-spaces */ } /** @type {import('./settings-controller.js').SettingsController} */ diff --git a/ext/js/pages/settings/popup-preview-frame.js b/ext/js/pages/settings/popup-preview-frame.js index e5cc6580..7828a025 100644 --- a/ext/js/pages/settings/popup-preview-frame.js +++ b/ext/js/pages/settings/popup-preview-frame.js @@ -57,6 +57,7 @@ export class PopupPreviewFrame { /** @type {string} */ this._targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, ''); + /* eslint-disable no-multi-spaces */ /** @type {Map<string, (params: import('core').SerializableObjectAny) => void>} */ this._windowMessageHandlers = new Map(/** @type {[key: string, handler: (params: import('core').SerializableObjectAny) => void][]} */ ([ ['PopupPreviewFrame.setText', this._onSetText.bind(this)], @@ -64,6 +65,7 @@ export class PopupPreviewFrame { ['PopupPreviewFrame.setCustomOuterCss', this._setCustomOuterCss.bind(this)], ['PopupPreviewFrame.updateOptionsContext', this._updateOptionsContext.bind(this)] ])); + /* eslint-enable no-multi-spaces */ } /** */ diff --git a/ext/js/pages/settings/profile-conditions-ui.js b/ext/js/pages/settings/profile-conditions-ui.js index e02d2585..715aeb69 100644 --- a/ext/js/pages/settings/profile-conditions-ui.js +++ b/ext/js/pages/settings/profile-conditions-ui.js @@ -50,6 +50,7 @@ export class ProfileConditionsUI extends EventDispatcher { const normalizeInteger = this._normalizeInteger.bind(this); const validateFlags = this._validateFlags.bind(this); const normalizeFlags = this._normalizeFlags.bind(this); + /* eslint-disable no-multi-spaces */ /** @type {Map<import('profile-conditions-ui').DescriptorType, import('profile-conditions-ui').Descriptor>} */ this._descriptors = new Map([ [ @@ -105,6 +106,7 @@ export class ProfileConditionsUI extends EventDispatcher { } ] ]); + /* eslint-enable no-multi-spaces */ /** @type {Set<string>} */ this._validFlags = new Set([ 'clipboard' @@ -217,12 +219,12 @@ export class ProfileConditionsUI extends EventDispatcher { const info = this._getOperatorDetails(type, operator); const { - displayName=operator, - type: type2='string', - defaultValue='', - resetDefaultOnChange=false, - validate=null, - normalize=null + displayName = operator, + type: type2 = 'string', + defaultValue = '', + resetDefaultOnChange = false, + validate = null, + normalize = null } = (typeof info === 'undefined' ? {} : info); return { diff --git a/ext/js/script/dynamic-loader.js b/ext/js/script/dynamic-loader.js index 75bf7b8b..8fdb77e9 100644 --- a/ext/js/script/dynamic-loader.js +++ b/ext/js/script/dynamic-loader.js @@ -64,7 +64,7 @@ export const dynamicLoader = (() => { * @returns {Promise<?HTMLStyleElement|HTMLLinkElement>} * @throws {Error} */ - async function loadStyle(id, type, value, useWebExtensionApi=false, parentNode=null) { + async function loadStyle(id, type, value, useWebExtensionApi = false, parentNode = null) { if (useWebExtensionApi && yomitan.isExtensionUrl(window.location.href)) { // Permissions error will occur if trying to use the WebExtension API to inject into an extension page useWebExtensionApi = false; diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js index dbf395e9..857922bf 100644 --- a/ext/js/templates/sandbox/anki-template-renderer.js +++ b/ext/js/templates/sandbox/anki-template-renderer.js @@ -74,6 +74,7 @@ export class AnkiTemplateRenderer { * Prepares the data that is necessary before the template renderer can be safely used. */ async prepare() { + /* eslint-disable no-multi-spaces */ this._templateRenderer.registerHelpers([ ['dumpObject', this._dumpObject.bind(this)], ['furigana', this._furigana.bind(this)], @@ -103,6 +104,7 @@ export class AnkiTemplateRenderer { ['hiragana', this._hiragana.bind(this)], ['katakana', this._katakana.bind(this)] ]); + /* eslint-enable no-multi-spaces */ this._templateRenderer.registerDataType('ankiNote', { modifier: ({marker, commonData}) => this._ankiNoteDataCreator.create(marker, commonData), composeData: ({marker}, commonData) => ({marker, commonData}) @@ -392,9 +394,9 @@ export class AnkiTemplateRenderer { case '!=': return operand1 != operand2; // eslint-disable-line eqeqeq case '===': return operand1 === operand2; case '!==': return operand1 !== operand2; - case '<': return operand1 < operand2; + case '<': return operand1 < operand2; case '<=': return operand1 <= operand2; - case '>': return operand1 > operand2; + case '>': return operand1 > operand2; case '>=': return operand1 >= operand2; case '<<': return operand1 << operand2; case '>>': return operand1 >> operand2; diff --git a/ext/js/templates/sandbox/template-renderer-media-provider.js b/ext/js/templates/sandbox/template-renderer-media-provider.js index d8a0a16d..0a7f5d9b 100644 --- a/ext/js/templates/sandbox/template-renderer-media-provider.js +++ b/ext/js/templates/sandbox/template-renderer-media-provider.js @@ -79,7 +79,7 @@ export class TemplateRendererMediaProvider { */ _getFormattedValue(data, namedArgs) { let {value} = data; - const {escape=true} = namedArgs; + const {escape = true} = namedArgs; if (escape) { value = Handlebars.Utils.escapeExpression(value); } diff --git a/ext/js/templates/template-renderer-proxy.js b/ext/js/templates/template-renderer-proxy.js index 642eea8b..7cbab3c8 100644 --- a/ext/js/templates/template-renderer-proxy.js +++ b/ext/js/templates/template-renderer-proxy.js @@ -99,7 +99,7 @@ export class TemplateRendererProxy { * @param {number} [timeout] * @returns {Promise<void>} */ - _loadFrame(frame, url, timeout=5000) { + _loadFrame(frame, url, timeout = 5000) { return new Promise((resolve, reject) => { let state = 0x0; // 0x1 = frame added; 0x2 = frame loaded; 0x4 = frame ready const cleanup = () => { @@ -165,7 +165,7 @@ export class TemplateRendererProxy { * @param {?number} [timeout] * @returns {Promise<unknown>} */ - _invoke(action, params, timeout=null) { + _invoke(action, params, timeout = null) { return new Promise((resolve, reject) => { const frameWindow = (this._frame !== null ? this._frame.contentWindow : null); if (frameWindow === null) { diff --git a/ext/js/yomitan.js b/ext/js/yomitan.js index 7cf67aec..37455d00 100644 --- a/ext/js/yomitan.js +++ b/ext/js/yomitan.js @@ -88,6 +88,7 @@ export class Yomitan extends EventDispatcher { /** @type {?(() => void)} */ this._isBackendReadyPromiseResolve = resolve; + /* eslint-disable no-multi-spaces */ /** @type {import('core').MessageHandlerMap} */ this._messageHandlers = new Map(/** @type {import('core').MessageHandlerArray} */ ([ ['Yomitan.isReady', {async: false, handler: this._onMessageIsReady.bind(this)}], @@ -97,6 +98,7 @@ export class Yomitan extends EventDispatcher { ['Yomitan.databaseUpdated', {async: false, handler: this._onMessageDatabaseUpdated.bind(this)}], ['Yomitan.zoomChanged', {async: false, handler: this._onMessageZoomChanged.bind(this)}] ])); + /* eslint-enable no-multi-spaces */ } /** @@ -140,7 +142,7 @@ export class Yomitan extends EventDispatcher { * Prepares the instance for use. * @param {boolean} [isBackground=false] Assigns whether this instance is being used from the background page/service worker. */ - async prepare(isBackground=false) { + async prepare(isBackground = false) { this._isBackground = isBackground; chrome.runtime.onMessage.addListener(this._onMessage.bind(this)); |