Skip to content

Commit

Permalink
Merge branch 'master' into debug-translator
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanVukovic99 committed Feb 19, 2024
2 parents ebd98c1 + 2da866f commit 81f2655
Show file tree
Hide file tree
Showing 71 changed files with 299 additions and 292 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"no-implied-eval": "error",
"no-new": "error",
"no-new-native-nonconstructor": "error",
"no-octal": "off",
"no-octal-escape": "off",
"no-octal": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-promise-executor-return": "error",
"no-prototype-builtins": "error",
Expand Down Expand Up @@ -394,9 +394,9 @@
"plugin:@typescript-eslint/recommended-type-checked"
],
"rules": {
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-floating-promises": ["error", {"ignoreIIFE": true}],
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-redundant-type-constituents": "error",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
Expand Down
2 changes: 1 addition & 1 deletion dev/bin/build-libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

import {buildLibs} from '../build-libs.js';

buildLibs();
await buildLibs();
2 changes: 1 addition & 1 deletion dev/bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,4 @@ export async function main(argv) {
}
}

testMain(main, process.argv.slice(2));
await testMain(main, process.argv.slice(2));
2 changes: 1 addition & 1 deletion dev/bin/dictionary-validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ async function main() {
await testDictionaryFiles(mode, dictionaryFileNames);
}

main();
await main();
32 changes: 16 additions & 16 deletions ext/js/app/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ export class Frontend {
* @returns {void}
*/
_onActionScanSelectedText() {
this._scanSelectedText(false);
void this._scanSelectedText(false);
}

/**
* @returns {void}
*/
_onActionScanTextAtCaret() {
this._scanSelectedText(true);
void this._scanSelectedText(true);
}

// API message handlers
Expand Down Expand Up @@ -320,7 +320,7 @@ export class Frontend {
* @returns {void}
*/
_onResize() {
this._updatePopupPosition();
void this._updatePopupPosition();
}

/** @type {import('extension').ChromeRuntimeOnMessageCallback<import('application').ApiMessageAny>} */
Expand All @@ -347,7 +347,7 @@ export class Frontend {
* @returns {void}
*/
_onVisualViewportScroll() {
this._updatePopupPosition();
void this._updatePopupPosition();
}

/**
Expand Down Expand Up @@ -423,8 +423,8 @@ export class Frontend {
_clearSelection(passive) {
this._stopClearSelectionDelayed();
if (this._popup !== null) {
this._popup.clearAutoPlayTimer();
this._popup.hide(!passive);
void this._popup.clearAutoPlayTimer();
void this._popup.hide(!passive);
this._isPointerOverPopup = false;
}
this._textScanner.clearSelection();
Expand Down Expand Up @@ -630,7 +630,7 @@ export class Frontend {
});
popup.on('offsetNotFound', () => {
this._allowRootFramePopupProxy = false;
this._updatePopup();
void this._updatePopup();
});
return popup;
}
Expand Down Expand Up @@ -679,7 +679,7 @@ export class Frontend {
* @param {import('text-source').TextSource} textSource
*/
_showExtensionUnloaded(textSource) {
this._showPopupContent(textSource, null, null);
void this._showPopupContent(textSource, null, null);
}

/**
Expand Down Expand Up @@ -726,7 +726,7 @@ export class Frontend {
details.params.full = textSource.fullContent;
details.params['full-visible'] = 'true';
}
this._showPopupContent(textSource, optionsContext, details);
void this._showPopupContent(textSource, optionsContext, details);
}

/**
Expand Down Expand Up @@ -792,9 +792,9 @@ export class Frontend {

this._contentScale = contentScale;
if (this._popup !== null) {
this._popup.setContentScale(this._contentScale);
void this._popup.setContentScale(this._contentScale);
}
this._updatePopupPosition();
void this._updatePopupPosition();
}

/**
Expand All @@ -807,7 +807,7 @@ export class Frontend {
this._popup !== null &&
await this._popup.isVisible()
) {
this._showPopupContent(textSource, null, null);
void this._showPopupContent(textSource, null, null);
}
}

Expand All @@ -818,9 +818,9 @@ export class Frontend {
/** @type {import('application').ApiMessageNoFrameId<'frontendReady'>} */
const message = {action: 'frontendReady', params: {frameId: this._application.frameId}};
if (targetFrameId === null) {
this._application.api.broadcastTab(message);
void this._application.api.broadcastTab(message);
} else {
this._application.api.sendMessageToFrame(targetFrameId, message);
void this._application.api.sendMessageToFrame(targetFrameId, message);
}
}

Expand Down Expand Up @@ -864,7 +864,7 @@ export class Frontend {
}

chrome.runtime.onMessage.addListener(onMessage);
this._application.api.broadcastTab({action: 'frontendRequestReadyBroadcast', params: {frameId: this._application.frameId}});
void this._application.api.broadcastTab({action: 'frontendRequestReadyBroadcast', params: {frameId: this._application.frameId}});
});
}

Expand Down Expand Up @@ -950,7 +950,7 @@ export class Frontend {
_prepareSiteSpecific() {
switch (location.hostname.toLowerCase()) {
case 'docs.google.com':
this._prepareGoogleDocs();
void this._prepareGoogleDocs();
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions ext/js/app/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export class Popup extends EventDispatcher {
await this._show(sourceRects, writingMode);

if (displayDetails !== null) {
this._invokeSafe('displaySetContent', {details: displayDetails});
void this._invokeSafe('displaySetContent', {details: displayDetails});
}
}

Expand Down Expand Up @@ -662,7 +662,7 @@ export class Popup extends EventDispatcher {
if (this._visibleValue === value) { return; }
this._visibleValue = value;
this._frame.style.setProperty('visibility', value ? 'visible' : 'hidden', 'important');
this._invokeSafe('displayVisibilityChanged', {value});
void this._invokeSafe('displayVisibilityChanged', {value});
}

/**
Expand Down Expand Up @@ -1028,7 +1028,7 @@ export class Popup extends EventDispatcher {
this._useSecureFrameUrl = general.useSecurePopupFrameUrl;
this._useShadowDom = general.usePopupShadowDom;
this._customOuterCss = general.customPopupOuterCss;
this.updateTheme();
void this.updateTheme();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ext/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class Application extends EventDispatcher {
ready() {
if (this._isReady) { return; }
this._isReady = true;
this._webExtension.sendMessagePromise({action: 'applicationReady'});
void this._webExtension.sendMessagePromise({action: 'applicationReady'});
}

/** */
Expand Down
35 changes: 18 additions & 17 deletions ext/js/background/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class Backend {
this._prepareCompleteReject(error);
}
);
promise.finally(() => this._updateBadge());
void promise.finally(() => this._updateBadge());
this._preparePromise = promise;
}
return this._prepareCompletePromise;
Expand Down Expand Up @@ -282,7 +282,7 @@ export class Backend {

/** @type {import('language-transformer').LanguageTransformDescriptor} */
const descriptor = await fetchJson('/data/language/japanese-transforms.json');
this._translator.prepare(descriptor);
void this._translator.prepare(descriptor);

await this._optionsUtil.prepare();
this._defaultAnkiFieldTemplates = (await fetchText('/data/templates/default-anki-field-templates.handlebars')).trim();
Expand All @@ -292,7 +292,7 @@ export class Backend {

const options = this._getProfileOptions({current: true}, false);
if (options.general.showGuide) {
this._openWelcomeGuidePageOnce();
void this._openWelcomeGuidePageOnce();
}

this._clipboardMonitor.on('change', this._onClipboardTextChange.bind(this));
Expand Down Expand Up @@ -409,15 +409,15 @@ export class Backend {
* @returns {void}
*/
_onPermissionsChanged() {
this._checkPermissions();
void this._checkPermissions();
}

/**
* @param {chrome.runtime.InstalledDetails} event
*/
_onInstalled({reason}) {
if (reason !== 'install') { return; }
this._requestPersistentStorage();
void this._requestPersistentStorage();
}

// Message handlers
Expand Down Expand Up @@ -1047,7 +1047,7 @@ export class Backend {
if (this._searchPopupTabCreatePromise === null) {
const promise = this._getOrCreateSearchPopup();
this._searchPopupTabCreatePromise = promise;
promise.then(() => { this._searchPopupTabCreatePromise = null; });
void promise.then(() => { this._searchPopupTabCreatePromise = null; });
}
return this._searchPopupTabCreatePromise;
}
Expand Down Expand Up @@ -1239,7 +1239,7 @@ export class Backend {
this._clipboardMonitor.stop();
}

this._accessibilityController.update(this._getOptionsFull(false));
void this._accessibilityController.update(this._getOptionsFull(false));

this._sendMessageAllTabsIgnoreResponse({action: 'applicationOptionsUpdated', params: {source}});
}
Expand Down Expand Up @@ -1612,16 +1612,16 @@ export class Backend {
}

if (color !== null && typeof chrome.action.setBadgeBackgroundColor === 'function') {
chrome.action.setBadgeBackgroundColor({color});
void chrome.action.setBadgeBackgroundColor({color});
}
if (text !== null && typeof chrome.action.setBadgeText === 'function') {
chrome.action.setBadgeText({text});
void chrome.action.setBadgeText({text});
}
if (typeof chrome.action.setTitle === 'function') {
if (status !== null) {
title = `${title} - ${status}`;
}
chrome.action.setTitle({title});
void chrome.action.setTitle({title});
}
}

Expand Down Expand Up @@ -2339,7 +2339,7 @@ export class Backend {
* @param {import('backend').DatabaseUpdateCause} cause
*/
_triggerDatabaseUpdated(type, cause) {
this._translator.clearDatabaseCaches();
void this._translator.clearDatabaseCaches();
this._sendMessageAllTabsIgnoreResponse({action: 'applicationDatabaseUpdated', params: {type, cause}});
}

Expand Down Expand Up @@ -2468,12 +2468,13 @@ export class Backend {
* @returns {Promise<void>}
*/
async _openWelcomeGuidePageOnce() {
chrome.storage.session.get(['openedWelcomePage']).then((result) => {
if (!result.openedWelcomePage) {
this._openWelcomeGuidePage();
chrome.storage.session.set({openedWelcomePage: true});
}
});
const result = await chrome.storage.session.get(['openedWelcomePage']);
if (!result.openedWelcomePage) {
await Promise.all([
this._openWelcomeGuidePage(),
chrome.storage.session.set({openedWelcomePage: true})
]);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ext/js/background/background-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ async function main() {
await backend.prepare();
}

main();
void main();
2 changes: 1 addition & 1 deletion ext/js/background/offscreen-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class ClipboardReaderProxy {
set browser(value) {
if (this._browser === value) { return; }
this._browser = value;
this._offscreen.sendMessagePromise({action: 'clipboardSetBrowserOffscreen', params: {value}});
void this._offscreen.sendMessagePromise({action: 'clipboardSetBrowserOffscreen', params: {value}});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ext/js/comm/clipboard-monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class ClipboardMonitor extends EventDispatcher {

this._timerToken = token;

intervalCallback();
void intervalCallback();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ext/js/comm/frame-ancestry-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class FrameAncestryHandler {
const {params} = /** @type {import('core').SerializableObject} */ (data);
if (typeof params !== 'object' || params === null) { return; }

this._onRequestFrameInfo(/** @type {import('core').SerializableObject} */ (params), source);
void this._onRequestFrameInfo(/** @type {import('core').SerializableObject} */ (params), source);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ext/js/comm/frame-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class FrameClient {

/** @type {import('extension').ChromeRuntimeOnMessageCallback<import('application').ApiMessageAny>} */
const onMessage = (message) => {
onMessageInner(message);
void onMessageInner(message);
return false;
};

Expand Down
4 changes: 2 additions & 2 deletions ext/js/comm/frame-endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class FrameEndpoint {
}
/** @type {import('frame-client').FrameEndpointReadyDetails} */
const details = {secret: this._secret};
this._api.broadcastTab({action: 'frameEndpointReady', params: details});
void this._api.broadcastTab({action: 'frameEndpointReady', params: details});
}

/**
Expand Down Expand Up @@ -88,6 +88,6 @@ export class FrameEndpoint {
this._eventListeners.removeAllEventListeners();
/** @type {import('frame-client').FrameEndpointConnectedDetails} */
const details = {secret, token};
this._api.sendMessageToFrame(hostFrameId, {action: 'frameEndpointConnected', params: details});
void this._api.sendMessageToFrame(hostFrameId, {action: 'frameEndpointConnected', params: details});
}
}
4 changes: 2 additions & 2 deletions ext/js/data/anki-note-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class AnkiNoteBuilder {
_runBatchedRequestsDelayed() {
if (this._batchedRequestsQueued) { return; }
this._batchedRequestsQueued = true;
Promise.resolve().then(() => {
void Promise.resolve().then(() => {
this._batchedRequestsQueued = false;
this._runBatchedRequests();
});
Expand Down Expand Up @@ -322,7 +322,7 @@ export class AnkiNoteBuilder {

this._batchedRequests.length = 0;

this._resolveBatchedRequests(items, allRequests);
void this._resolveBatchedRequests(items, allRequests);
}

/**
Expand Down
Loading

0 comments on commit 81f2655

Please sign in to comment.