Skip to content

Commit

Permalink
Add no-multi-spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Dec 16, 2023
1 parent 425f5c1 commit 54ff846
Show file tree
Hide file tree
Showing 27 changed files with 75 additions and 20 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
}
],
"no-implicit-globals": "error",
"no-multi-spaces": "error",
"no-trailing-spaces": "error",
"no-whitespace-before-property": "error",
"object-curly-spacing": [
Expand Down Expand Up @@ -521,7 +522,10 @@
"files": [
"*.json"
],
"parser": "jsonc-eslint-parser"
"parser": "jsonc-eslint-parser",
"rules": {
"no-multi-spaces": "off"
}
},
{
"files": [
Expand Down
4 changes: 4 additions & 0 deletions ext/js/app/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}],
Expand All @@ -117,6 +118,7 @@ export class Frontend {
['scanSelectedText', this._onActionScanSelectedText.bind(this)],
['scanTextAtCaret', this._onActionScanTextAtCaret.bind(this)]
]);
/* eslint-enable no-multi-spaces */
}

/**
Expand Down Expand Up @@ -174,13 +176,15 @@ 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)}],
['Frontend.getSelectionText', {async: false, handler: this._onApiGetSelectionText.bind(this)}],
['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();
Expand Down
2 changes: 2 additions & 0 deletions ext/js/app/popup-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}],
Expand All @@ -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 */
}

/**
Expand Down
10 changes: 6 additions & 4 deletions ext/js/background/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}],
Expand Down Expand Up @@ -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
Expand All @@ -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)]
]));
}

Expand Down
2 changes: 2 additions & 0 deletions ext/js/background/offscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}],
Expand All @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions ext/js/background/profile-conditions-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
]))
}
Expand Down
4 changes: 4 additions & 0 deletions ext/js/data/options-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand All @@ -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);
}
Expand Down Expand Up @@ -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},
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions ext/js/display/display-anki.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,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));
Expand Down
2 changes: 2 additions & 0 deletions ext/js/display/display-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ 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)]
]);
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));
Expand Down
2 changes: 2 additions & 0 deletions ext/js/display/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,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)],
Expand All @@ -218,6 +219,7 @@ export class Display extends EventDispatcher {
this.registerWindowMessageHandlers([
['Display.extensionUnloaded', {async: false, handler: this._onMessageExtensionUnloaded.bind(this)}]
]);
/* eslint-enable no-multi-spaces */
}

/** @type {DisplayGenerator} */
Expand Down
2 changes: 2 additions & 0 deletions ext/js/display/search-display-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,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();

Expand Down
3 changes: 3 additions & 0 deletions ext/js/language/deinflector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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 */
8 changes: 4 additions & 4 deletions ext/js/language/dictionary-importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ext/js/language/sandbox/japanese-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('ぁぃぅぇぉゃゅょゎァィゥェォャュョヮ'));
Expand Down
2 changes: 2 additions & 0 deletions ext/js/pages/settings/keyboard-shortcuts-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class KeyboardShortcutController {
this._stringComparer = new Intl.Collator('en-US'); // Invariant locale
/** @type {?HTMLElement} */
this._scrollContainer = null;
/* eslint-disable no-multi-spaces */
/** @type {Map<string, import('keyboard-shortcut-controller').ActionDetails>} */
this._actionDetails = new Map([
['', {scopes: new Set()}],
Expand All @@ -69,6 +70,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} */
Expand Down
2 changes: 2 additions & 0 deletions ext/js/pages/settings/popup-preview-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ 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)],
['PopupPreviewFrame.setCustomCss', this._setCustomCss.bind(this)],
['PopupPreviewFrame.setCustomOuterCss', this._setCustomOuterCss.bind(this)],
['PopupPreviewFrame.updateOptionsContext', this._updateOptionsContext.bind(this)]
]));
/* eslint-enable no-multi-spaces */
}

/** */
Expand Down
2 changes: 2 additions & 0 deletions ext/js/pages/settings/profile-conditions-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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([
[
Expand Down Expand Up @@ -104,6 +105,7 @@ export class ProfileConditionsUI extends EventDispatcher {
}
]
]);
/* eslint-enable no-multi-spaces */
/** @type {Set<string>} */
this._validFlags = new Set([
'clipboard'
Expand Down
6 changes: 4 additions & 2 deletions ext/js/templates/sandbox/anki-template-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions ext/js/yomitan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}],
Expand All @@ -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 */
}

/**
Expand Down
2 changes: 2 additions & 0 deletions test/cache-map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/* eslint-disable no-multi-spaces */

import {expect, test} from 'vitest';
import {CacheMap} from '../ext/js/general/cache-map.js';

Expand Down
Loading

0 comments on commit 54ff846

Please sign in to comment.