From 60515f579e8a7ccb54501027a4e934b45051eb97 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 15 Apr 2021 02:49:46 +0200 Subject: [PATCH] Make editor-toolbar pass eslint --- ts/editor-toolbar/cloze.ts | 4 ++-- ts/editor-toolbar/color.ts | 4 ++-- ts/editor-toolbar/format.ts | 4 ++-- ts/editor-toolbar/index.ts | 14 +++++++------- ts/editor-toolbar/notetype.ts | 4 ++-- ts/editor-toolbar/template.ts | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ts/editor-toolbar/cloze.ts b/ts/editor-toolbar/cloze.ts index 76f5925a9..8d47f23c3 100644 --- a/ts/editor-toolbar/cloze.ts +++ b/ts/editor-toolbar/cloze.ts @@ -1,7 +1,7 @@ import IconButton from "./IconButton.svelte"; import type { IconButtonProps } from "./IconButton"; -import { dynamicComponent } from "sveltelib/dynamicComponent"; +import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent"; import * as tr from "anki/i18n"; import bracketsIcon from "./code-brackets.svg"; @@ -35,7 +35,7 @@ function onCloze(event: MouseEvent): void { const iconButton = dynamicComponent(IconButton); -export function getClozeButton() { +export function getClozeButton(): DynamicSvelteComponent & IconButtonProps { return iconButton({ id: "cloze", icon: bracketsIcon, diff --git a/ts/editor-toolbar/color.ts b/ts/editor-toolbar/color.ts index 79bd65a10..0595bec7e 100644 --- a/ts/editor-toolbar/color.ts +++ b/ts/editor-toolbar/color.ts @@ -5,7 +5,7 @@ import type { ColorPickerProps } from "./ColorPicker"; import ButtonGroup from "./ButtonGroup.svelte"; import type { ButtonGroupProps } from "./ButtonGroup"; -import { dynamicComponent } from "sveltelib/dynamicComponent"; +import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent"; import * as tr from "anki/i18n"; import squareFillIcon from "./square-fill.svg"; @@ -29,7 +29,7 @@ const iconButton = dynamicComponent(IconButt const colorPicker = dynamicComponent(ColorPicker); const buttonGroup = dynamicComponent(ButtonGroup); -export function getColorGroup() { +export function getColorGroup(): DynamicSvelteComponent & ButtonGroupProps { const forecolorButton = iconButton({ icon: squareFillIcon, className: "forecolor", diff --git a/ts/editor-toolbar/format.ts b/ts/editor-toolbar/format.ts index 2aeb8d4f6..6fc447d64 100644 --- a/ts/editor-toolbar/format.ts +++ b/ts/editor-toolbar/format.ts @@ -3,7 +3,7 @@ import type { CommandIconButtonProps } from "./CommandIconButton"; import ButtonGroup from "./ButtonGroup.svelte"; import type { ButtonGroupProps } from "./ButtonGroup"; -import { dynamicComponent } from "sveltelib/dynamicComponent"; +import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent"; import * as tr from "anki/i18n"; import boldIcon from "./type-bold.svg"; @@ -19,7 +19,7 @@ const commandIconButton = dynamicComponent< >(CommandIconButton); const buttonGroup = dynamicComponent(ButtonGroup); -export function getFormatGroup() { +export function getFormatGroup(): DynamicSvelteComponent & ButtonGroupProps { const boldButton = commandIconButton({ icon: boldIcon, command: "bold", diff --git a/ts/editor-toolbar/index.ts b/ts/editor-toolbar/index.ts index 07afda036..f5ff68c7e 100644 --- a/ts/editor-toolbar/index.ts +++ b/ts/editor-toolbar/index.ts @@ -23,15 +23,15 @@ interface Hideable { hidden?: boolean; } -function showComponent(component: Hideable) { +function showComponent(component: Hideable): void { component.hidden = false; } -function hideComponent(component: Hideable) { +function hideComponent(component: Hideable): void { component.hidden = true; } -function toggleComponent(component: Hideable) { +function toggleComponent(component: Hideable): void { component.hidden = !component.hidden; } @@ -97,14 +97,14 @@ class EditorToolbar extends HTMLElement { this.updateButtonGroup(toggleComponent, group); } - insertButtonGroup(newGroup: ButtonGroupProps, group: string | number = 0) { + insertButtonGroup(newGroup: ButtonGroupProps, group: string | number = 0): void { this.buttons?.update((buttonGroups) => { const newButtonGroup = buttonGroup(newGroup); return insert(buttonGroups, newButtonGroup, group); }); } - addButtonGroup(newGroup: ButtonGroupProps, group: string | number = -1) { + addButtonGroup(newGroup: ButtonGroupProps, group: string | number = -1): void { this.buttons?.update((buttonGroups) => { const newButtonGroup = buttonGroup(newGroup); return add(buttonGroups, newButtonGroup, group); @@ -141,7 +141,7 @@ class EditorToolbar extends HTMLElement { newButton: ToolbarItem & Identifiable, group: string | number, button: string | number = 0 - ) { + ): void { this.updateButtonGroup((component) => { component.buttons = insert( component.buttons as (ToolbarItem & Identifiable)[], @@ -155,7 +155,7 @@ class EditorToolbar extends HTMLElement { newButton: ToolbarItem & Identifiable, group: string | number, button: string | number = -1 - ) { + ): void { this.updateButtonGroup((component) => { component.buttons = add( component.buttons as (ToolbarItem & Identifiable)[], diff --git a/ts/editor-toolbar/notetype.ts b/ts/editor-toolbar/notetype.ts index b78f1b56b..69b2081cf 100644 --- a/ts/editor-toolbar/notetype.ts +++ b/ts/editor-toolbar/notetype.ts @@ -3,14 +3,14 @@ import type { LabelButtonProps } from "./LabelButton"; import ButtonGroup from "./ButtonGroup.svelte"; import type { ButtonGroupProps } from "./ButtonGroup"; -import { dynamicComponent } from "sveltelib/dynamicComponent"; +import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent"; import { bridgeCommand } from "anki/bridgecommand"; import * as tr from "anki/i18n"; const labelButton = dynamicComponent(LabelButton); const buttonGroup = dynamicComponent(ButtonGroup); -export function getNotetypeGroup() { +export function getNotetypeGroup(): DynamicSvelteComponent & ButtonGroupProps { const fieldsButton = labelButton({ onClick: () => bridgeCommand("fields"), disables: false, diff --git a/ts/editor-toolbar/template.ts b/ts/editor-toolbar/template.ts index 683b66c0b..352a0cb86 100644 --- a/ts/editor-toolbar/template.ts +++ b/ts/editor-toolbar/template.ts @@ -10,7 +10,7 @@ import ButtonGroup from "./ButtonGroup.svelte"; import type { ButtonGroupProps } from "./ButtonGroup"; import { bridgeCommand } from "anki/bridgecommand"; -import { dynamicComponent } from "sveltelib/dynamicComponent"; +import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent"; import * as tr from "anki/i18n"; import paperclipIcon from "./paperclip.svg"; @@ -47,7 +47,7 @@ const dropdownItem = dynamicComponent( ); const buttonGroup = dynamicComponent(ButtonGroup); -export function getTemplateGroup() { +export function getTemplateGroup(): DynamicSvelteComponent & ButtonGroupProps { const attachmentButton = iconButton({ icon: paperclipIcon, onClick: onAttachment, @@ -88,7 +88,7 @@ export function getTemplateGroup() { }); } -export function getTemplateMenus() { +export function getTemplateMenus(): (DynamicSvelteComponent & DropdownMenuProps)[] { const mathjaxMenu = dropdownMenu({ id: mathjaxMenuId, menuItems: [