From 81cf2c9bd41fe8f3f1eaf0de08ac6c1d6dfc799b Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 6 May 2021 23:33:28 +0200 Subject: [PATCH] Turn on editor:eslint --- ts/editor/BUILD.bazel | 16 ++++++++-------- ts/editor/editable.ts | 2 +- ts/editor/editingArea.ts | 4 ++++ ts/editor/index.ts | 8 ++++++-- ts/editor/inputHandlers.ts | 4 ++++ ts/editor/toolbar.ts | 6 +++++- ts/editor/wrap.ts | 4 ++++ ts/yarn.lock | 6 +++--- 8 files changed, 35 insertions(+), 15 deletions(-) diff --git a/ts/editor/BUILD.bazel b/ts/editor/BUILD.bazel index f25d8017b..823918080 100644 --- a/ts/editor/BUILD.bazel +++ b/ts/editor/BUILD.bazel @@ -156,14 +156,14 @@ prettier_test( ]), ) -# eslint_test( -# name = "eslint", -# srcs = glob( -# [ -# "*.ts", -# ], -# ), -# ) +eslint_test( + name = "eslint", + srcs = glob( + [ + "*.ts", + ], + ), +) svelte_check( name = "svelte_check", diff --git a/ts/editor/editable.ts b/ts/editor/editable.ts index b67a21b49..680bdf35c 100644 --- a/ts/editor/editable.ts +++ b/ts/editor/editable.ts @@ -33,7 +33,7 @@ export class Editable extends HTMLElement { : this.innerHTML; } - connectedCallback() { + connectedCallback(): void { this.setAttribute("contenteditable", ""); } } diff --git a/ts/editor/editingArea.ts b/ts/editor/editingArea.ts index 8056fac3d..b5345a630 100644 --- a/ts/editor/editingArea.ts +++ b/ts/editor/editingArea.ts @@ -1,6 +1,10 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +/* eslint +@typescript-eslint/no-non-null-assertion: "off", + */ + import type { Editable } from "./editable"; import { updateActiveButtons } from "./toolbar"; diff --git a/ts/editor/index.ts b/ts/editor/index.ts index 413fe3404..b2d638e3d 100644 --- a/ts/editor/index.ts +++ b/ts/editor/index.ts @@ -1,6 +1,10 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +/* eslint +@typescript-eslint/no-non-null-assertion: "off", + */ + import { filterHTML } from "html-filter"; import { updateActiveButtons, disableButtons } from "./toolbar"; import { setupI18n, ModuleName } from "lib/i18n"; @@ -54,7 +58,7 @@ export function focusField(n: number): void { export function focusIfField(x: number, y: number): boolean { const elements = document.elementsFromPoint(x, y); for (let i = 0; i < elements.length; i++) { - let elem = elements[i] as EditingArea; + const elem = elements[i] as EditingArea; if (elem instanceof EditingArea) { elem.focusEditable(); return true; @@ -158,7 +162,7 @@ export function setSticky(stickies: boolean[]): void { }); } -export function setFormat(cmd: string, arg?: any, nosave: boolean = false): void { +export function setFormat(cmd: string, arg?: string, nosave = false): void { document.execCommand(cmd, false, arg); if (!nosave) { saveField(getCurrentField() as EditingArea, "key"); diff --git a/ts/editor/inputHandlers.ts b/ts/editor/inputHandlers.ts index 8f9043e75..88ccf76f3 100644 --- a/ts/editor/inputHandlers.ts +++ b/ts/editor/inputHandlers.ts @@ -1,6 +1,10 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +/* eslint +@typescript-eslint/no-non-null-assertion: "off", + */ + import { updateActiveButtons } from "./toolbar"; import { EditingArea } from "./editingArea"; import { caretToEnd, nodeIsElement, getBlockElement } from "./helpers"; diff --git a/ts/editor/toolbar.ts b/ts/editor/toolbar.ts index ec26e26fe..322304f8b 100644 --- a/ts/editor/toolbar.ts +++ b/ts/editor/toolbar.ts @@ -1,6 +1,10 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +/* eslint +@typescript-eslint/no-non-null-assertion: "off", + */ + import { disabledKey, nightModeKey } from "components/contextKeys"; import { writable } from "svelte/store"; @@ -27,7 +31,7 @@ export function initToolbar(i18n: Promise): Promise { document.documentElement.classList.contains("night-mode") ); - toolbarResolve(new EditorToolbar({ target, anchor, context } as any)); + toolbarResolve(new EditorToolbar({ target, anchor, context })); }); }); diff --git a/ts/editor/wrap.ts b/ts/editor/wrap.ts index c96fc7f8d..4255d4d80 100644 --- a/ts/editor/wrap.ts +++ b/ts/editor/wrap.ts @@ -1,6 +1,10 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +/* eslint +@typescript-eslint/no-non-null-assertion: "off", + */ + import { getCurrentField, setFormat } from "."; function wrappedExceptForWhitespace(text: string, front: string, back: string): string { diff --git a/ts/yarn.lock b/ts/yarn.lock index c6f6e35bf..f5f90c5e7 100644 --- a/ts/yarn.lock +++ b/ts/yarn.lock @@ -4260,9 +4260,9 @@ svelte2tsx@^0.1.133: pascal-case "^3.1.1" svelte@^3.25.0: - version "3.37.0" - resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.37.0.tgz#dc7cd24bcc275cdb3f8c684ada89e50489144ccd" - integrity sha512-TRF30F4W4+d+Jr2KzUUL1j8Mrpns/WM/WacxYlo5MMb2E5Qy2Pk1Guj6GylxsW9OnKQl1tnF8q3hG/hQ3h6VUA== + version "3.38.2" + resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.38.2.tgz#55e5c681f793ae349b5cc2fe58e5782af4275ef5" + integrity sha512-q5Dq0/QHh4BLJyEVWGe7Cej5NWs040LWjMbicBGZ+3qpFWJ1YObRmUDZKbbovddLC9WW7THTj3kYbTOFmU9fbg== symbol-tree@^3.2.4: version "3.2.4"