summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dev/dictionary-validate.js6
-rw-r--r--dev/manifest-util.js2
-rw-r--r--ext/js/display/search-display-controller.js2
-rw-r--r--ext/js/pages/settings/settings-main.js4
-rw-r--r--ext/js/templates/sandbox/anki-template-renderer.js2
-rw-r--r--test/deinflector.test.js1
-rw-r--r--test/dictionary-data-validate.test.js4
-rw-r--r--test/playwright/integration.spec.js14
-rw-r--r--test/playwright/visual.spec.js16
9 files changed, 25 insertions, 26 deletions
diff --git a/dev/dictionary-validate.js b/dev/dictionary-validate.js
index efc2eb8c..51edcc50 100644
--- a/dev/dictionary-validate.js
+++ b/dev/dictionary-validate.js
@@ -78,8 +78,8 @@ async function validateDictionaryBanks(mode, zip, fileNameFormat, schema) {
* @param {import('dev/dictionary-validate').Schemas} schemas
*/
export async function validateDictionary(mode, archive, schemas) {
- const fileName = 'index.json';
- const indexFile = archive.files[fileName];
+ const indexFileName = 'index.json';
+ const indexFile = archive.files[indexFileName];
if (!indexFile) {
throw new Error('No dictionary index found in archive');
}
@@ -93,7 +93,7 @@ export async function validateDictionary(mode, archive, schemas) {
jsonSchema.validate(index);
} catch (e) {
const e2 = e instanceof Error ? e : new Error(`${e}`);
- e2.message += `\n(in file ${fileName})}`;
+ e2.message += `\n(in file ${indexFileName})}`;
throw e2;
}
diff --git a/dev/manifest-util.js b/dev/manifest-util.js
index 42872a40..1802e139 100644
--- a/dev/manifest-util.js
+++ b/dev/manifest-util.js
@@ -127,7 +127,7 @@ export class ManifestUtil {
_applyModifications(manifest, modifications) {
if (Array.isArray(modifications)) {
for (const modification of modifications) {
- // rename to path2 to avoid clashing with imported `node:path` module.
+ // Rename to path2 to avoid clashing with imported `node:path` module.
const {action, path: path2} = modification;
switch (action) {
case 'set':
diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js
index 4dd41736..482afd56 100644
--- a/ext/js/display/search-display-controller.js
+++ b/ext/js/display/search-display-controller.js
@@ -279,7 +279,7 @@ export class SearchDisplayController {
/** */
_onCopy() {
- // ignore copy from search page
+ // Ignore copy from search page
const selection = window.getSelection();
this._clipboardMonitor.setPreviousText(selection !== null ? selection.toString().trim() : '');
}
diff --git a/ext/js/pages/settings/settings-main.js b/ext/js/pages/settings/settings-main.js
index 3abe3bcf..5f70890b 100644
--- a/ext/js/pages/settings/settings-main.js
+++ b/ext/js/pages/settings/settings-main.js
@@ -53,7 +53,7 @@ import {TranslationTextReplacementsController} from './translation-text-replacem
/**
* @param {GenericSettingController} genericSettingController
*/
-async function setupGenericSettingsController(genericSettingController) {
+async function setupGenericSettingController(genericSettingController) {
await genericSettingController.prepare();
await genericSettingController.refresh();
}
@@ -107,7 +107,7 @@ async function main() {
dictionaryImportController.prepare();
const genericSettingController = new GenericSettingController(settingsController);
- preparePromises.push(setupGenericSettingsController(genericSettingController));
+ preparePromises.push(setupGenericSettingController(genericSettingController));
const audioController = new AudioController(settingsController, modalController);
audioController.prepare();
diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js
index 2d3c888c..57725bcb 100644
--- a/ext/js/templates/sandbox/anki-template-renderer.js
+++ b/ext/js/templates/sandbox/anki-template-renderer.js
@@ -669,7 +669,7 @@ export class AnkiTemplateRenderer {
/**
* @type {import('template-renderer').HelperFunction<string>}
*/
- _formatGlossary(args, context, options) {
+ _formatGlossary(args, _context, options) {
const [dictionary, content] = /** @type {[dictionary: string, content: import('dictionary-data').TermGlossary]} */ (args);
const data = options.data.root;
if (typeof content === 'string') { return this._stringToMultiLineHtml(this._escape(content)); }
diff --git a/test/deinflector.test.js b/test/deinflector.test.js
index 7ef8e6dd..9c8443d2 100644
--- a/test/deinflector.test.js
+++ b/test/deinflector.test.js
@@ -962,5 +962,4 @@ function main() {
testDeinflections();
}
-
main();
diff --git a/test/dictionary-data-validate.test.js b/test/dictionary-data-validate.test.js
index c54f7dbb..5334bc2e 100644
--- a/test/dictionary-data-validate.test.js
+++ b/test/dictionary-data-validate.test.js
@@ -18,7 +18,7 @@
import {fileURLToPath} from 'node:url';
import path from 'path';
-import {describe, test} from 'vitest';
+import {describe, it} from 'vitest';
import * as dictionaryValidate from '../dev/dictionary-validate.js';
import {createDictionaryArchive} from '../dev/util.js';
@@ -46,7 +46,7 @@ describe('Dictionary validation', () => {
];
const schemas = dictionaryValidate.getSchemas();
describe.each(testCases)('Test dictionary $name', ({name, valid}) => {
- test(`Should be ${valid ? 'valid' : 'invalid'}`, async ({expect}) => {
+ it(`should be ${valid ? 'valid' : 'invalid'}`, async ({expect}) => {
const archive = createTestDictionaryArchive(name);
if (valid) {
await expect(dictionaryValidate.validateDictionary(null, archive, schemas)).resolves.not.toThrow();
diff --git a/test/playwright/integration.spec.js b/test/playwright/integration.spec.js
index c8cf2f6d..d5b8360c 100644
--- a/test/playwright/integration.spec.js
+++ b/test/playwright/integration.spec.js
@@ -29,7 +29,7 @@ import {
} from './playwright-util';
test.beforeEach(async ({context}) => {
- // wait for the on-install welcome.html tab to load, which becomes the foreground tab
+ // Wait for the on-install welcome.html tab to load, which becomes the foreground tab
const welcome = await context.waitForEvent('page');
await welcome.close(); // close the welcome tab so our main tab becomes the foreground tab -- otherwise, the screenshot can hang
});
@@ -44,7 +44,7 @@ test('search clipboard', async ({page, extensionId}) => {
});
test('anki add', async ({context, page, extensionId}) => {
- // mock anki routes
+ // Mock anki routes
/** @type {?(value: unknown) => void} */
let resolve = null;
const addNotePromise = new Promise((res) => {
@@ -58,10 +58,10 @@ test('anki add', async ({context, page, extensionId}) => {
}
});
- // open settings
+ // Open settings
await page.goto(`chrome-extension://${extensionId}/settings.html`);
- // load in test dictionary
+ // Load in test dictionary
const dictionary = createDictionaryArchive(path.join(root, 'test/data/dictionaries/valid-dictionary1'), 'valid-dictionary1');
const testDictionarySource = await dictionary.generateAsync({type: 'arraybuffer'});
await page.locator('input[id="dictionary-import-file-input"]').setInputFiles({
@@ -71,11 +71,11 @@ test('anki add', async ({context, page, extensionId}) => {
});
await expect(page.locator('id=dictionaries')).toHaveText('Dictionaries (1 installed, 1 enabled)', {timeout: 5 * 60 * 1000});
- // connect to anki
+ // Connect to anki
await page.locator('.toggle', {has: page.locator('[data-setting="anki.enable"]')}).click();
await expect(page.locator('#anki-error-message')).toHaveText('Connected');
- // prep anki deck
+ // Prep anki deck
await page.locator('[data-modal-action="show,anki-cards"]').click();
await page.locator('select.anki-card-deck').selectOption('Mock Deck');
await page.locator('select.anki-card-model').selectOption('Mock Model');
@@ -85,7 +85,7 @@ test('anki add', async ({context, page, extensionId}) => {
await page.locator('#anki-cards-modal > div > div.modal-footer > button:nth-child(2)').click();
await writeToClipboardFromPage(page, '読むの例文');
- // add to anki deck
+ // Add to anki deck
await page.goto(`chrome-extension://${extensionId}/search.html`);
await expect(async () => {
await page.locator('#search-textbox').clear();
diff --git a/test/playwright/visual.spec.js b/test/playwright/visual.spec.js
index 02efc985..3b46a6d0 100644
--- a/test/playwright/visual.spec.js
+++ b/test/playwright/visual.spec.js
@@ -20,28 +20,28 @@ import {pathToFileURL} from 'url';
import {expect, root, test} from './playwright-util';
test.beforeEach(async ({context}) => {
- // wait for the on-install welcome.html tab to load, which becomes the foreground tab
+ // Wait for the on-install welcome.html tab to load, which becomes the foreground tab
const welcome = await context.waitForEvent('page');
welcome.close(); // close the welcome tab so our main tab becomes the foreground tab -- otherwise, the screenshot can hang
});
test('visual', async ({page, extensionId}) => {
- // open settings
+ // Open settings
await page.goto(`chrome-extension://${extensionId}/settings.html`);
await expect(page.locator('id=dictionaries')).toBeVisible();
- // get the locator for the disk usage indicator so we can later mask it out of the screenshot
+ // Get the locator for the disk usage indicator so we can later mask it out of the screenshot
const storage_locator = page.locator('.storage-use-finite >> xpath=..');
- // take a simple screenshot of the settings page
+ // Take a simple screenshot of the settings page
await expect.soft(page).toHaveScreenshot('settings-fresh.png', {mask: [storage_locator]});
- // load in jmdict_english.zip
+ // Load in jmdict_english.zip
await page.locator('input[id="dictionary-import-file-input"]').setInputFiles(path.join(root, 'dictionaries/jmdict_english.zip'));
await expect(page.locator('id=dictionaries')).toHaveText('Dictionaries (1 installed, 1 enabled)', {timeout: 5 * 60 * 1000});
- // take a screenshot of the settings page with jmdict loaded
+ // Take a screenshot of the settings page with jmdict loaded
await expect.soft(page).toHaveScreenshot('settings-jmdict-loaded.png', {mask: [storage_locator]});
/**
@@ -55,10 +55,10 @@ test('visual', async ({page, extensionId}) => {
const box = (await el.boundingBox()) || {x: 0, y: 0, width: 0, height: 0};
- // find the popup frame if it exists
+ // Find the popup frame if it exists
let popup_frame = page.frames().find((f) => f.url().includes('popup.html'));
- // otherwise prepare for it to be attached
+ // Otherwise prepare for it to be attached
let frame_attached;
if (popup_frame === undefined) {
frame_attached = page.waitForEvent('frameattached');