aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/pages')
-rw-r--r--ext/js/pages/action-popup-main.js2
-rw-r--r--ext/js/pages/info-main.js2
-rw-r--r--ext/js/pages/permissions-main.js2
-rw-r--r--ext/js/pages/settings/anki-controller.js7
-rw-r--r--ext/js/pages/settings/audio-controller.js2
-rw-r--r--ext/js/pages/settings/backup-controller.js4
-rw-r--r--ext/js/pages/settings/collapsible-dictionary-controller.js4
-rw-r--r--ext/js/pages/settings/dictionary-controller.js6
-rw-r--r--ext/js/pages/settings/dictionary-import-controller.js6
-rw-r--r--ext/js/pages/settings/extension-keyboard-shortcuts-controller.js2
-rw-r--r--ext/js/pages/settings/keyboard-shortcuts-controller.js2
-rw-r--r--ext/js/pages/settings/profile-controller.js4
-rw-r--r--ext/js/pages/settings/sentence-termination-characters-controller.js5
-rw-r--r--ext/js/pages/settings/settings-controller.js4
-rw-r--r--ext/js/pages/settings/settings-display-controller.js4
15 files changed, 28 insertions, 28 deletions
diff --git a/ext/js/pages/action-popup-main.js b/ext/js/pages/action-popup-main.js
index b5728215..f58083a7 100644
--- a/ext/js/pages/action-popup-main.js
+++ b/ext/js/pages/action-popup-main.js
@@ -238,7 +238,7 @@ class DisplayController {
*/
_onProfileSelectChange(event) {
const node = /** @type {HTMLInputElement} */ (event.currentTarget);
- const value = parseInt(node.value, 10);
+ const value = Number.parseInt(node.value, 10);
if (typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= /** @type {import('settings').Options} */ (this._optionsFull).profiles.length) {
this._setPrimaryProfileIndex(value);
}
diff --git a/ext/js/pages/info-main.js b/ext/js/pages/info-main.js
index 7d7d56a5..0bc84d97 100644
--- a/ext/js/pages/info-main.js
+++ b/ext/js/pages/info-main.js
@@ -108,7 +108,7 @@ async function showDictionaryInfo(api) {
/** @type {HTMLElement} */
const noneElement = querySelectorNotNull(document, '#installed-dictionaries-none');
- noneElement.hidden = (dictionaryInfos.length !== 0);
+ noneElement.hidden = (dictionaryInfos.length > 0);
/** @type {HTMLElement} */
const container = querySelectorNotNull(document, '#installed-dictionaries');
container.textContent = '';
diff --git a/ext/js/pages/permissions-main.js b/ext/js/pages/permissions-main.js
index 3092782b..17169c12 100644
--- a/ext/js/pages/permissions-main.js
+++ b/ext/js/pages/permissions-main.js
@@ -102,6 +102,8 @@ await Application.main(async (application) => {
/** @type {HTMLInputElement} */
const permissionCheckbox2 = querySelectorNotNull(document, '#permission-checkbox-allow-file-url-access');
/** @type {HTMLInputElement[]} */
+ // This collection is actually used, not sure why this eslint-disable is needed.
+ // eslint-disable-next-line sonarjs/no-unused-collection
const permissionsCheckboxes = [permissionCheckbox1, permissionCheckbox2];
const permissions = await Promise.all([
diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js
index 3a6345ed..e161d86b 100644
--- a/ext/js/pages/settings/anki-controller.js
+++ b/ext/js/pages/settings/anki-controller.js
@@ -401,11 +401,11 @@ export class AnkiController {
if (typeof data !== 'undefined') {
details += `${JSON.stringify(data, null, 4)}\n\n`;
}
- details += `${error.stack}`.trimRight();
+ details += `${error.stack}`.trimEnd();
/** @type {HTMLElement} */ (this._ankiErrorMessageDetailsNode).textContent = details;
/** @type {HTMLElement} */ (this._ankiErrorMessageDetailsContainer).hidden = true;
- /** @type {HTMLElement} */ (this._ankiErrorInvalidResponseInfo).hidden = (errorString.indexOf('Invalid response') < 0);
+ /** @type {HTMLElement} */ (this._ankiErrorInvalidResponseInfo).hidden = !errorString.includes('Invalid response');
/** @type {HTMLElement} */ (this._ankiErrorMessageDetailsToggle).hidden = false;
}
@@ -762,7 +762,8 @@ class AnkiCardController {
const ELEMENT_NODE = Node.ELEMENT_NODE;
const container = this._ankiCardFieldsContainer;
if (container !== null) {
- for (const node of [...container.childNodes]) {
+ const childNodesFrozen = [...container.childNodes];
+ for (const node of childNodesFrozen) {
if (node.nodeType === ELEMENT_NODE && node instanceof HTMLElement && node.dataset.persistent === 'true') { continue; }
container.removeChild(node);
}
diff --git a/ext/js/pages/settings/audio-controller.js b/ext/js/pages/settings/audio-controller.js
index 9633c4b3..5b597d33 100644
--- a/ext/js/pages/settings/audio-controller.js
+++ b/ext/js/pages/settings/audio-controller.js
@@ -144,7 +144,7 @@ export class AudioController extends EventDispatcher {
const text = input.value || '';
const voiceUri = input.dataset.voice;
const audio = this._audioSystem.createTextToSpeechAudio(text, typeof voiceUri === 'string' ? voiceUri : '');
- audio.volume = 1.0;
+ audio.volume = 1;
audio.play();
} catch (e) {
// NOP
diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js
index 59bcaed9..2bab00e3 100644
--- a/ext/js/pages/settings/backup-controller.js
+++ b/ext/js/pages/settings/backup-controller.js
@@ -144,7 +144,7 @@ export class BackupController {
}
}
- const data = {
+ return {
version: this._currentVersion,
date: this._getSettingsExportDateString(date, '-', ' ', ':', 6),
url: chrome.runtime.getURL('/'),
@@ -154,8 +154,6 @@ export class BackupController {
permissions,
options: optionsFull
};
-
- return data;
}
/**
diff --git a/ext/js/pages/settings/collapsible-dictionary-controller.js b/ext/js/pages/settings/collapsible-dictionary-controller.js
index 5ba61e0c..62f84b96 100644
--- a/ext/js/pages/settings/collapsible-dictionary-controller.js
+++ b/ext/js/pages/settings/collapsible-dictionary-controller.js
@@ -156,9 +156,7 @@ export class CollapsibleDictionaryController {
const versionNode = querySelectorNotNull(node, '.dictionary-version');
versionNode.textContent = version;
- /** @type {HTMLSelectElement} */
- const select = querySelectorNotNull(node, '.definitions-collapsible');
- return select;
+ return querySelectorNotNull(node, '.definitions-collapsible');
}
/** */
diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js
index 1d3c1730..5020dc7c 100644
--- a/ext/js/pages/settings/dictionary-controller.js
+++ b/ext/js/pages/settings/dictionary-controller.js
@@ -558,7 +558,7 @@ export class DictionaryController {
const {profiles} = optionsFull;
for (let i = 0, ii = profiles.length; i < ii; ++i) {
let modified = false;
- const missingDictionaries = new Set([...installedDictionaries]);
+ const missingDictionaries = new Set(installedDictionaries);
const dictionaryOptionsArray = profiles[i].options.dictionaries;
for (let j = dictionaryOptionsArray.length - 1; j >= 0; --j) {
const {name} = dictionaryOptionsArray[j];
@@ -871,8 +871,8 @@ export class DictionaryController {
const onProgress = ({processed, count, storeCount, storesProcesed}) => {
const percent = (
(count > 0 && storesProcesed > 0) ?
- (processed / count) * (storesProcesed / storeCount) * 100.0 :
- 0.0
+ (processed / count) * (storesProcesed / storeCount) * 100 :
+ 0
);
const cssString = `${percent}%`;
const statusString = `${percent.toFixed(0)}%`;
diff --git a/ext/js/pages/settings/dictionary-import-controller.js b/ext/js/pages/settings/dictionary-import-controller.js
index 0484001d..34e21c5d 100644
--- a/ext/js/pages/settings/dictionary-import-controller.js
+++ b/ext/js/pages/settings/dictionary-import-controller.js
@@ -172,7 +172,7 @@ export class DictionaryImportController {
for (const label of infoLabels) { label.textContent = labelText; }
}
- const percent = count > 0 ? (index / count * 100.0) : 0.0;
+ const percent = count > 0 ? (index / count * 100) : 0;
const cssString = `${percent}%`;
const statusString = `${Math.floor(percent).toFixed(0)}%`;
for (const progressBar of progressBars) { progressBar.style.width = cssString; }
@@ -199,8 +199,8 @@ export class DictionaryImportController {
await this._importDictionary(files[i], importDetails, onProgress);
}
- } catch (err) {
- this._showErrors([toError(err)]);
+ } catch (error) {
+ this._showErrors([toError(error)]);
} finally {
prevention.end();
for (const progress of progressContainers) { progress.hidden = true; }
diff --git a/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js b/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js
index 61eefffa..b9d107ae 100644
--- a/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js
+++ b/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js
@@ -353,7 +353,7 @@ class ExtensionKeyboardShortcutHotkeyEntry {
* @param {boolean} updateInput
*/
async _tryUpdateInput(key, modifiers, updateInput) {
- let okay = (key === null ? (modifiers.length === 0) : (modifiers.length !== 0));
+ let okay = (key === null ? (modifiers.length === 0) : (modifiers.length > 0));
if (okay) {
try {
await this._parent.updateCommand(this._name, key, modifiers);
diff --git a/ext/js/pages/settings/keyboard-shortcuts-controller.js b/ext/js/pages/settings/keyboard-shortcuts-controller.js
index 7b28a322..907cf4a1 100644
--- a/ext/js/pages/settings/keyboard-shortcuts-controller.js
+++ b/ext/js/pages/settings/keyboard-shortcuts-controller.js
@@ -183,7 +183,7 @@ export class KeyboardShortcutController {
const listContainer = /** @type {HTMLElement} */ (this._listContainer);
listContainer.appendChild(fragment);
listContainer.hidden = (hotkeys.length === 0);
- /** @type {HTMLElement} */ (this._emptyIndicator).hidden = (hotkeys.length !== 0);
+ /** @type {HTMLElement} */ (this._emptyIndicator).hidden = (hotkeys.length > 0);
}
/**
diff --git a/ext/js/pages/settings/profile-controller.js b/ext/js/pages/settings/profile-controller.js
index 5a7b5ed4..a82a4b4e 100644
--- a/ext/js/pages/settings/profile-controller.js
+++ b/ext/js/pages/settings/profile-controller.js
@@ -544,7 +544,7 @@ export class ProfileController {
*/
_tryGetValidProfileIndex(stringValue) {
if (typeof stringValue !== 'string') { return null; }
- const intValue = parseInt(stringValue, 10);
+ const intValue = Number.parseInt(stringValue, 10);
return (
Number.isFinite(intValue) &&
intValue >= 0 &&
@@ -573,7 +573,7 @@ export class ProfileController {
suffix = match[5];
if (typeof match[2] === 'string') {
space = match[3];
- index = parseInt(match[4], 10) + 1;
+ index = Number.parseInt(match[4], 10) + 1;
} else {
space = ' ';
index = 2;
diff --git a/ext/js/pages/settings/sentence-termination-characters-controller.js b/ext/js/pages/settings/sentence-termination-characters-controller.js
index c393aaa1..4ceed22b 100644
--- a/ext/js/pages/settings/sentence-termination-characters-controller.js
+++ b/ext/js/pages/settings/sentence-termination-characters-controller.js
@@ -125,8 +125,9 @@ export class SentenceTerminationCharactersController {
entry.prepare();
}
- /** @type {HTMLElement} */ (this._listTable).hidden = (terminationCharacters.length === 0);
- /** @type {HTMLElement} */ (this._emptyIndicator).hidden = (terminationCharacters.length !== 0);
+ const empty = terminationCharacters.length === 0;
+ /** @type {HTMLElement} */ (this._listTable).hidden = empty;
+ /** @type {HTMLElement} */ (this._emptyIndicator).hidden = !empty;
}
/**
diff --git a/ext/js/pages/settings/settings-controller.js b/ext/js/pages/settings/settings-controller.js
index 3f389271..c835f8e6 100644
--- a/ext/js/pages/settings/settings-controller.js
+++ b/ext/js/pages/settings/settings-controller.js
@@ -195,6 +195,7 @@ export class SettingsController extends EventDispatcher {
*/
preventPageExit() {
/** @type {import('settings-controller').PageExitPrevention} */
+ // eslint-disable-next-line sonarjs/prefer-object-literal
const obj = {};
obj.end = this._endPreventPageExit.bind(this, obj);
if (this._pageExitPreventionEventListeners.size === 0) {
@@ -226,8 +227,7 @@ export class SettingsController extends EventDispatcher {
async getDefaultOptions() {
const optionsUtil = new OptionsUtil();
await optionsUtil.prepare();
- const optionsFull = optionsUtil.getDefault();
- return optionsFull;
+ return optionsUtil.getDefault();
}
// Private
diff --git a/ext/js/pages/settings/settings-display-controller.js b/ext/js/pages/settings/settings-display-controller.js
index 0a729d96..47aa9c9c 100644
--- a/ext/js/pages/settings/settings-display-controller.js
+++ b/ext/js/pages/settings/settings-display-controller.js
@@ -290,7 +290,7 @@ export class SettingsDisplayController {
*/
_getMoreContainer(link) {
const v = link.dataset.parentDistance;
- const distance = v ? parseInt(v, 10) : 1;
+ const distance = v ? Number.parseInt(v, 10) : 1;
if (Number.isNaN(distance)) { return null; }
/** @type {?Element} */
@@ -338,7 +338,7 @@ export class SettingsDisplayController {
let indent = '\t';
if (args.length > 1) {
- const count = parseInt(args[1], 10);
+ const count = Number.parseInt(args[1], 10);
indent = (Number.isFinite(count) && count >= 0 ? ' '.repeat(count) : args[1]);
}