diff options
-rw-r--r-- | .eslintrc.json | 2 | ||||
-rw-r--r-- | ext/js/core/utilities.js | 2 | ||||
-rw-r--r-- | ext/js/dom/sandbox/css-style-applier.js | 1 | ||||
-rw-r--r-- | ext/js/language/sandbox/japanese-util.js | 3 | ||||
-rw-r--r-- | package-lock.json | 47 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | test/cache-map.test.js | 4 | ||||
-rw-r--r-- | test/deinflector.test.js | 4 | ||||
-rw-r--r-- | test/fixtures/anki-template-renderer-test.js | 1 | ||||
-rw-r--r-- | test/hotkey-util.test.js | 6 | ||||
-rw-r--r-- | test/json-schema.test.js | 6 | ||||
-rw-r--r-- | test/options-util.test.js | 14 | ||||
-rw-r--r-- | test/profile-conditions-util.test.js | 4 |
13 files changed, 71 insertions, 24 deletions
diff --git a/.eslintrc.json b/.eslintrc.json index 0fa39826..d4bb3d23 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,6 +3,7 @@ "extends": [ "eslint:recommended", "plugin:jsonc/recommended-with-json", + "plugin:eslint-comments/recommended", "plugin:@typescript-eslint/recommended" ], "parser": "@typescript-eslint/parser", @@ -378,6 +379,7 @@ "allowAllPropertiesOnSameLine": true } ], + "eslint-comments/no-unused-disable": "error", "@typescript-eslint/ban-ts-comment": [ "error", { diff --git a/ext/js/core/utilities.js b/ext/js/core/utilities.js index 1fc2da42..784acdaf 100644 --- a/ext/js/core/utilities.js +++ b/ext/js/core/utilities.js @@ -303,14 +303,12 @@ export function promiseAnimationFrame(timeout) { const onTimeout = () => { timer = null; if (frameRequest !== null) { - // eslint-disable-next-line no-undef cancelAnimationFrame(frameRequest); frameRequest = null; } resolve({time: performance.now(), timeout: true}); }; - // eslint-disable-next-line no-undef frameRequest = requestAnimationFrame(onFrame); if (typeof timeout === 'number') { timer = setTimeout(onTimeout, timeout); diff --git a/ext/js/dom/sandbox/css-style-applier.js b/ext/js/dom/sandbox/css-style-applier.js index d250c0f5..ea3f1a28 100644 --- a/ext/js/dom/sandbox/css-style-applier.js +++ b/ext/js/dom/sandbox/css-style-applier.js @@ -40,7 +40,6 @@ export class CssStyleApplier { /** @type {RegExp} */ this._patternClassNameCharacter = /[0-9a-zA-Z-_]/; } - /* eslint-enable jsdoc/check-line-alignment */ /** * Loads the data file for use. diff --git a/ext/js/language/sandbox/japanese-util.js b/ext/js/language/sandbox/japanese-util.js index 89f4d5ed..f9874cd4 100644 --- a/ext/js/language/sandbox/japanese-util.js +++ b/ext/js/language/sandbox/japanese-util.js @@ -190,7 +190,6 @@ for (let i = 0, ii = kana.length; i < ii; i += 3) { * @param {import('japanese-util').CodepointRange} range * @returns {boolean} */ -// eslint-disable-next-line no-implicit-globals function isCodePointInRange(codePoint, [min, max]) { return (codePoint >= min && codePoint <= max); } @@ -200,7 +199,6 @@ function isCodePointInRange(codePoint, [min, max]) { * @param {import('japanese-util').CodepointRange[]} ranges * @returns {boolean} */ -// eslint-disable-next-line no-implicit-globals function isCodePointInRanges(codePoint, ranges) { for (const [min, max] of ranges) { if (codePoint >= min && codePoint <= max) { @@ -214,7 +212,6 @@ function isCodePointInRanges(codePoint, ranges) { * @param {string} previousCharacter * @returns {?string} */ -// eslint-disable-next-line no-implicit-globals function getProlongedHiragana(previousCharacter) { switch (KANA_TO_VOWEL_MAPPING.get(previousCharacter)) { case 'a': return 'あ'; diff --git a/package-lock.json b/package-lock.json index c1818047..8f0d5d7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,6 +38,7 @@ "dotenv": "^16.3.1", "esbuild": "^0.19.11", "eslint": "^8.56.0", + "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-header": "^3.1.1", "eslint-plugin-jsdoc": "^47.0.1", "eslint-plugin-jsonc": "^2.11.2", @@ -2622,6 +2623,34 @@ "eslint": ">=6.0.0" } }, + "node_modules/eslint-plugin-eslint-comments": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.2.0.tgz", + "integrity": "sha512-0jkOl0hfojIHHmEHgmNdqv4fmh7300NdpA9FFpF7zaoLvB/QeXOGNLIo86oAveJFrfB1p05kC8hpEMHM8DwWVQ==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^1.0.5", + "ignore": "^5.0.5" + }, + "engines": { + "node": ">=6.5.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=4.19.1" + } + }, + "node_modules/eslint-plugin-eslint-comments/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/eslint-plugin-header": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz", @@ -8017,6 +8046,24 @@ "dev": true, "requires": {} }, + "eslint-plugin-eslint-comments": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.2.0.tgz", + "integrity": "sha512-0jkOl0hfojIHHmEHgmNdqv4fmh7300NdpA9FFpF7zaoLvB/QeXOGNLIo86oAveJFrfB1p05kC8hpEMHM8DwWVQ==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "ignore": "^5.0.5" + }, + "dependencies": { + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true + } + } + }, "eslint-plugin-header": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz", diff --git a/package.json b/package.json index 35d62000..095ae214 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "dotenv": "^16.3.1", "esbuild": "^0.19.11", "eslint": "^8.56.0", + "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-header": "^3.1.1", "eslint-plugin-jsdoc": "^47.0.1", "eslint-plugin-jsonc": "^2.11.2", diff --git a/test/cache-map.test.js b/test/cache-map.test.js index 72579f25..868c5d9a 100644 --- a/test/cache-map.test.js +++ b/test/cache-map.test.js @@ -16,8 +16,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* eslint-disable no-multi-spaces */ - import {describe, expect, test} from 'vitest'; import {CacheMap} from '../ext/js/general/cache-map.js'; @@ -39,6 +37,7 @@ function testConstructor() { /** */ function testApi() { describe('api', () => { + /* eslint-disable no-multi-spaces */ const data = [ { maxSize: 1, @@ -90,6 +89,7 @@ function testApi() { ] } ]; + /* eslint-enable no-multi-spaces */ test.each(data)('api-test-%#', ({maxSize, expectedSize, calls}) => { const cache = new CacheMap(maxSize); diff --git a/test/deinflector.test.js b/test/deinflector.test.js index e90704f1..660b909a 100644 --- a/test/deinflector.test.js +++ b/test/deinflector.test.js @@ -16,8 +16,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* eslint-disable no-multi-spaces */ - import fs from 'fs'; import {fileURLToPath} from 'node:url'; import path from 'path'; @@ -62,6 +60,7 @@ function hasTermReasons(deinflector, source, expectedTerm, expectedRule, expecte /** */ function testDeinflections() { + /* eslint-disable no-multi-spaces */ const data = [ { valid: true, @@ -933,6 +932,7 @@ function testDeinflections() { ] } ]; + /* eslint-enable no-multi-spaces */ /** @type {import('deinflector').ReasonsRaw} */ const deinflectionReasons = parseJson(fs.readFileSync(path.join(dirname, '..', 'ext', 'data/deinflect.json'), {encoding: 'utf8'})); diff --git a/test/fixtures/anki-template-renderer-test.js b/test/fixtures/anki-template-renderer-test.js index 90fa0440..de447126 100644 --- a/test/fixtures/anki-template-renderer-test.js +++ b/test/fixtures/anki-template-renderer-test.js @@ -32,7 +32,6 @@ export async function createAnkiTemplateRendererTest() { /** @type {import('vitest').TestAPI<{window: import('jsdom').DOMWindow, ankiTemplateRenderer: AnkiTemplateRenderer}>} */ const result = test.extend({ window: async ({window}, use) => { await use(window); }, - // eslint-disable-next-line no-empty-pattern ankiTemplateRenderer: async ({window}, use) => { // The window property needs to be referenced for it to be initialized. // It is needed for DOM access for structured content. diff --git a/test/hotkey-util.test.js b/test/hotkey-util.test.js index f87d0ffd..0a76d0f2 100644 --- a/test/hotkey-util.test.js +++ b/test/hotkey-util.test.js @@ -16,14 +16,13 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* eslint-disable no-multi-spaces */ - import {describe, expect, test} from 'vitest'; import {HotkeyUtil} from '../ext/js/input/hotkey-util.js'; /** */ function testCommandConversions() { describe('CommandConversions', () => { + /* eslint-disable no-multi-spaces */ /** @type {{os: import('environment').OperatingSystem, command: string, expectedCommand: string, expectedInput: {key: string, modifiers: import('input').Modifier[]}}[]} */ const data = [ {os: 'win', command: 'Alt+F', expectedCommand: 'Alt+F', expectedInput: {key: 'KeyF', modifiers: ['alt']}}, @@ -41,6 +40,7 @@ function testCommandConversions() { {os: 'linux', command: 'MacCtrl+Alt+Shift+F1', expectedCommand: 'Ctrl+Alt+Shift+F1', expectedInput: {key: 'F1', modifiers: ['ctrl', 'alt', 'shift']}}, {os: 'linux', command: 'Command+Alt+Shift+F1', expectedCommand: 'Command+Alt+Shift+F1', expectedInput: {key: 'F1', modifiers: ['meta', 'alt', 'shift']}} ]; + /* eslint-enable no-multi-spaces */ const hotkeyUtil = new HotkeyUtil(); for (const {command, os, expectedInput, expectedCommand} of data) { @@ -58,6 +58,7 @@ function testCommandConversions() { /** */ function testDisplayNames() { describe('DisplayNames', () => { + /* eslint-disable no-multi-spaces */ /** @type {{os: import('environment').OperatingSystem, key: ?string, modifiers: import('input').Modifier[], expected: string}[]} */ const data = [ {os: 'win', key: null, modifiers: [], expected: ''}, @@ -136,6 +137,7 @@ function testDisplayNames() { {os: 'unknown', key: 'KeyF', modifiers: ['mouse1'], expected: 'Mouse 1 + F'}, {os: 'unknown', key: 'F1', modifiers: ['mouse1'], expected: 'Mouse 1 + F1'} ]; + /* eslint-enable no-multi-spaces */ const hotkeyUtil = new HotkeyUtil(); diff --git a/test/json-schema.test.js b/test/json-schema.test.js index fcb99ee4..a3686758 100644 --- a/test/json-schema.test.js +++ b/test/json-schema.test.js @@ -16,8 +16,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* eslint-disable no-multi-spaces */ - import {describe, expect, test} from 'vitest'; import {parseJson} from '../dev/json.js'; import {JsonSchema} from '../ext/js/data/json-schema.js'; @@ -125,6 +123,7 @@ function testValidate1() { /** */ function testValidate2() { describe('Validate2', () => { + /* eslint-disable no-multi-spaces */ /** @type {{schema: import('ext/json-schema').Schema, inputs: {expected: boolean, value: unknown}[]}[]} */ const data = [ // String tests @@ -518,6 +517,7 @@ function testValidate2() { ] } ]; + /* eslint-enable no-multi-spaces */ describe.each(data)('Schema %#', ({schema, inputs}) => { test.each(inputs)(`schemaValidate(${schema}, $value) -> $expected`, ({expected, value}) => { @@ -890,6 +890,7 @@ function testGetValidValueOrDefault1() { /** */ function testProxy1() { describe('Proxy1', () => { + /* eslint-disable no-multi-spaces */ /** @type {{schema: import('ext/json-schema').Schema, tests: {error: boolean, value?: import('ext/json-schema').Value, action: (value: import('core').SafeAny) => void}[]}[]} */ const data = [ // Object tests @@ -1019,6 +1020,7 @@ function testProxy1() { ] } ]; + /* eslint-enable no-multi-spaces */ describe.each(data)('Schema %#', ({schema, tests}) => { test.each(tests)('proxy %#', ({error, value, action}) => { diff --git a/test/options-util.test.js b/test/options-util.test.js index ded16b4c..25abe715 100644 --- a/test/options-util.test.js +++ b/test/options-util.test.js @@ -16,12 +16,10 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* eslint-disable no-multi-spaces */ - import fs from 'fs'; import {fileURLToPath} from 'node:url'; import path from 'path'; -import {expect, test, describe, vi} from 'vitest'; +import {describe, expect, test, vi} from 'vitest'; import {OptionsUtil} from '../ext/js/data/options-util.js'; import {TemplatePatcher} from '../ext/js/templates/template-patcher.js'; import {chrome, fetch} from './mocks/common.js'; @@ -477,6 +475,7 @@ function createProfileOptionsUpdatedTestData1() { ] }, inputs: { + /* eslint-disable no-multi-spaces */ hotkeys: [ {action: 'close', argument: '', key: 'Escape', modifiers: [], scopes: ['popup'], enabled: true}, {action: 'focusSearchBox', argument: '', key: 'Escape', modifiers: [], scopes: ['search'], enabled: true}, @@ -495,6 +494,7 @@ function createProfileOptionsUpdatedTestData1() { {action: 'viewNote', argument: '', key: 'KeyV', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true}, {action: 'copyHostSelection', argument: '', key: 'KeyC', modifiers: ['ctrl'], scopes: ['popup'], enabled: true} ] + /* eslint-enable no-multi-spaces */ }, popupWindow: { width: 400, @@ -667,10 +667,10 @@ async function testFieldTemplatesUpdate() { return templatePatcher.parsePatch(content).addition; }; const updates = [ - {version: 2, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v2.handlebars')}, - {version: 4, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v4.handlebars')}, - {version: 6, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v6.handlebars')}, - {version: 8, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v8.handlebars')}, + {version: 2, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v2.handlebars')}, + {version: 4, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v4.handlebars')}, + {version: 6, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v6.handlebars')}, + {version: 8, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v8.handlebars')}, {version: 10, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v10.handlebars')}, {version: 12, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v12.handlebars')}, {version: 13, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v13.handlebars')}, diff --git a/test/profile-conditions-util.test.js b/test/profile-conditions-util.test.js index 417ca409..7af5f223 100644 --- a/test/profile-conditions-util.test.js +++ b/test/profile-conditions-util.test.js @@ -16,8 +16,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* eslint-disable no-multi-spaces */ - import {describe, expect, test} from 'vitest'; import {ProfileConditionsUtil} from '../ext/js/background/profile-conditions-util.js'; @@ -62,6 +60,7 @@ function testNormalizeContext() { /** */ function testSchemas() { describe('Schemas', () => { + /* eslint-disable no-multi-spaces */ /** @type {{conditionGroups: import('settings').ProfileConditionGroup[], expectedSchema?: import('ext/json-schema').Schema, inputs?: {expected: boolean, context: import('settings').OptionsContext}[]}[]} */ const data = [ // Empty @@ -1099,6 +1098,7 @@ function testSchemas() { ] } ]; + /* eslint-enable no-multi-spaces */ test.each(data)('schemas-test-%#', ({conditionGroups, expectedSchema, inputs}) => { const profileConditionsUtil = new ProfileConditionsUtil(); |