Skip to content

Commit

Permalink
Remove unneeded eslint disables (#554)
Browse files Browse the repository at this point in the history
* Install eslint-plugin-eslint-comments

* Update rules, fix issues
  • Loading branch information
toasted-nutbread authored Jan 27, 2024
1 parent a3224f6 commit 7a142bb
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"extends": [
"eslint:recommended",
"plugin:jsonc/recommended-with-json",
"plugin:eslint-comments/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
Expand Down Expand Up @@ -378,6 +379,7 @@
"allowAllPropertiesOnSameLine": true
}
],
"eslint-comments/no-unused-disable": "error",
"@typescript-eslint/ban-ts-comment": [
"error",
{
Expand Down
2 changes: 0 additions & 2 deletions ext/js/core/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion ext/js/dom/sandbox/css-style-applier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions ext/js/language/sandbox/japanese-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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) {
Expand All @@ -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 'あ';
Expand Down
47 changes: 47 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/cache-map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -39,6 +37,7 @@ function testConstructor() {
/** */
function testApi() {
describe('api', () => {
/* eslint-disable no-multi-spaces */
const data = [
{
maxSize: 1,
Expand Down Expand Up @@ -90,6 +89,7 @@ function testApi() {
]
}
];
/* eslint-enable no-multi-spaces */

test.each(data)('api-test-%#', ({maxSize, expectedSize, calls}) => {
const cache = new CacheMap(maxSize);
Expand Down
4 changes: 2 additions & 2 deletions test/deinflector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -62,6 +60,7 @@ function hasTermReasons(deinflector, source, expectedTerm, expectedRule, expecte

/** */
function testDeinflections() {
/* eslint-disable no-multi-spaces */
const data = [
{
valid: true,
Expand Down Expand Up @@ -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'}));
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/anki-template-renderer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions test/hotkey-util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']}},
Expand All @@ -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) {
Expand All @@ -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: ''},
Expand Down Expand Up @@ -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();

Expand Down
6 changes: 4 additions & 2 deletions test/json-schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}) => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1019,6 +1020,7 @@ function testProxy1() {
]
}
];
/* eslint-enable no-multi-spaces */

describe.each(data)('Schema %#', ({schema, tests}) => {
test.each(tests)('proxy %#', ({error, value, action}) => {
Expand Down
14 changes: 7 additions & 7 deletions test/options-util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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},
Expand All @@ -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,
Expand Down Expand Up @@ -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')},
Expand Down
4 changes: 2 additions & 2 deletions test/profile-conditions-util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1099,6 +1098,7 @@ function testSchemas() {
]
}
];
/* eslint-enable no-multi-spaces */

test.each(data)('schemas-test-%#', ({conditionGroups, expectedSchema, inputs}) => {
const profileConditionsUtil = new ProfileConditionsUtil();
Expand Down

0 comments on commit 7a142bb

Please sign in to comment.