From 0dff5ea3a38c6092cbb0e53806e796f9b74db539 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 19 Oct 2021 01:06:00 +0200 Subject: [PATCH] Use trailingComma: all setting in .prettierrc (#1435) --- .prettierrc | 4 +-- ts/card-info/lib.ts | 2 +- ts/change-notetype/NotetypeSelector.svelte | 2 +- ts/change-notetype/index.ts | 2 +- ts/change-notetype/lib.test.ts | 8 ++--- ts/change-notetype/lib.ts | 18 +++++------ ts/components/ButtonGroup.svelte | 6 ++-- ts/components/ButtonToolbar.svelte | 6 ++-- ts/components/Section.svelte | 6 ++-- ts/components/Shortcut.svelte | 4 +-- ts/components/WithState.svelte | 2 +- ts/components/helpers.ts | 2 +- ts/components/identifier.ts | 8 ++--- ts/components/registration.ts | 14 ++++---- ts/congrats/lib.ts | 2 +- ts/deck-options/index.ts | 2 +- ts/deck-options/lib.test.ts | 4 +-- ts/deck-options/lib.ts | 14 ++++---- ts/editable/ContentEditable.svelte | 2 +- ts/editable/decorated.ts | 2 +- ts/editable/mathjax-element.ts | 11 ++++--- ts/editable/mathjax.ts | 2 +- ts/editor/CodeMirror.svelte | 2 +- ts/editor/ColorButtons.svelte | 4 +-- ts/editor/EditorField.svelte | 4 +-- ts/editor/OldEditorAdapter.svelte | 8 ++--- ts/editor/PlainTextBadge.svelte | 2 +- ts/editor/RichTextInput.svelte | 4 +-- ts/editor/TagEditor.svelte | 12 +++---- ts/editor/TagInput.svelte | 4 +-- ts/editor/TemplateButtons.svelte | 8 ++--- ts/editor/helpers.ts | 2 +- .../image-overlay/WithImageConstrained.svelte | 14 ++++---- ts/editor/index.ts | 4 +-- ts/graphs/AddedGraph.svelte | 2 +- ts/graphs/CalendarGraph.svelte | 2 +- ts/graphs/EaseGraph.svelte | 2 +- ts/graphs/FutureDue.svelte | 2 +- ts/graphs/IntervalsGraph.svelte | 2 +- ts/graphs/ReviewsGraph.svelte | 2 +- ts/graphs/WithGraphData.svelte | 16 +++++----- ts/graphs/added.ts | 6 ++-- ts/graphs/buttons.ts | 20 ++++++------ ts/graphs/calendar.ts | 10 +++--- ts/graphs/card-counts.ts | 10 +++--- ts/graphs/ease.ts | 4 +-- ts/graphs/future-due.ts | 8 ++--- ts/graphs/graph-helpers.ts | 6 ++-- ts/graphs/graphs.html | 2 +- ts/graphs/histogram-graph.ts | 24 +++++++------- ts/graphs/hours.ts | 20 ++++++------ ts/graphs/index.ts | 2 +- ts/graphs/intervals.ts | 10 +++--- ts/graphs/reviews.ts | 32 +++++++++---------- ts/graphs/today.ts | 2 +- ts/html-filter/element.ts | 4 +-- ts/html-filter/node.ts | 2 +- ts/html-filter/styling.ts | 4 +-- ts/lib/dom.ts | 2 +- ts/lib/i18n/bundles.ts | 6 ++-- ts/lib/i18n/utils.ts | 4 +-- ts/lib/keys.ts | 4 +-- ts/lib/postrequest.ts | 2 +- ts/lib/proto.ts | 2 +- ts/lib/register-package.ts | 6 ++-- ts/lib/shortcuts.ts | 10 +++--- ts/lib/time.ts | 2 +- ts/lib/wrap.ts | 4 +-- ts/reviewer/answering.ts | 6 ++-- ts/reviewer/images.ts | 4 +-- ts/reviewer/index.ts | 14 ++++---- ts/sql_format/sql_format.ts | 2 +- ts/sql_format/tsconfig.json | 2 +- ts/svelte/svelte.ts | 8 ++--- ts/svelte/tsconfig.json | 2 +- ts/sveltelib/asyncReactive.ts | 10 +++--- ts/sveltelib/context-property.ts | 2 +- ts/sveltelib/dynamicComponent.ts | 6 ++-- ts/sveltelib/mirror-dom.ts | 6 ++-- ts/sveltelib/node-store.ts | 2 +- ts/sveltelib/preferences.ts | 8 ++--- ts/sveltelib/shortcut.ts | 2 +- ts/sveltelib/store-subscribe.ts | 2 +- 83 files changed, 252 insertions(+), 251 deletions(-) diff --git a/.prettierrc b/.prettierrc index 057819fc4..b6bc56abe 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { - "trailingComma": "es5", + "trailingComma": "all", "printWidth": 88, "tabWidth": 4, - "semi": true + "semi": true, } diff --git a/ts/card-info/lib.ts b/ts/card-info/lib.ts index 4ba34139b..35a83c63f 100644 --- a/ts/card-info/lib.ts +++ b/ts/card-info/lib.ts @@ -6,6 +6,6 @@ import { postRequest } from "../lib/postrequest"; export async function getCardStats(cardId: number): Promise { return Stats.CardStatsResponse.decode( - await postRequest("/_anki/cardStats", JSON.stringify({ cardId })) + await postRequest("/_anki/cardStats", JSON.stringify({ cardId })), ); } diff --git a/ts/change-notetype/NotetypeSelector.svelte b/ts/change-notetype/NotetypeSelector.svelte index 6b2129075..236ed9268 100644 --- a/ts/change-notetype/NotetypeSelector.svelte +++ b/ts/change-notetype/NotetypeSelector.svelte @@ -20,7 +20,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html async function blur(event: Event): Promise { await state.setTargetNotetypeIndex( - parseInt((event.target! as HTMLSelectElement).value) + parseInt((event.target! as HTMLSelectElement).value), ); } diff --git a/ts/change-notetype/index.ts b/ts/change-notetype/index.ts index 3133fb06a..df5102837 100644 --- a/ts/change-notetype/index.ts +++ b/ts/change-notetype/index.ts @@ -14,7 +14,7 @@ import { nightModeKey } from "../components/context-keys"; export async function changeNotetypePage( target: HTMLDivElement, oldNotetypeId: number, - newNotetypeId: number + newNotetypeId: number, ): Promise { const [info, names] = await Promise.all([ getChangeNotetypeInfo(oldNotetypeId, newNotetypeId), diff --git a/ts/change-notetype/lib.test.ts b/ts/change-notetype/lib.test.ts index e08a783a2..3fe91cd8e 100644 --- a/ts/change-notetype/lib.test.ts +++ b/ts/change-notetype/lib.test.ts @@ -65,14 +65,14 @@ const exampleInfoSame = { function differentState(): ChangeNotetypeState { return new ChangeNotetypeState( Notetypes.NotetypeNames.fromObject(exampleNames), - Notetypes.ChangeNotetypeInfo.fromObject(exampleInfoDifferent) + Notetypes.ChangeNotetypeInfo.fromObject(exampleInfoDifferent), ); } function sameState(): ChangeNotetypeState { return new ChangeNotetypeState( Notetypes.NotetypeNames.fromObject(exampleNames), - Notetypes.ChangeNotetypeInfo.fromObject(exampleInfoSame) + Notetypes.ChangeNotetypeInfo.fromObject(exampleInfoSame), ); } @@ -92,7 +92,7 @@ test("mapping", () => { expect(get(state.info).getNewName(MapContext.Field, 1)).toBe("Back"); expect(get(state.info).getNewName(MapContext.Field, 2)).toBe("Add Reverse"); expect(get(state.info).getOldNamesIncludingNothing(MapContext.Field)).toStrictEqual( - ["Front", "Back", "(Nothing)"] + ["Front", "Back", "(Nothing)"], ); expect(get(state.info).getOldIndex(MapContext.Field, 0)).toBe(0); expect(get(state.info).getOldIndex(MapContext.Field, 1)).toBe(1); @@ -102,7 +102,7 @@ test("mapping", () => { // the same template shouldn't be mappable twice expect( - get(state.info).getOldNamesIncludingNothing(MapContext.Template) + get(state.info).getOldNamesIncludingNothing(MapContext.Template), ).toStrictEqual(["Card 1", "(Nothing)"]); expect(get(state.info).getOldIndex(MapContext.Template, 0)).toBe(0); expect(get(state.info).getOldIndex(MapContext.Template, 1)).toBe(1); diff --git a/ts/change-notetype/lib.ts b/ts/change-notetype/lib.ts index ae6a9fc5f..3bc334a03 100644 --- a/ts/change-notetype/lib.ts +++ b/ts/change-notetype/lib.ts @@ -12,24 +12,24 @@ import { isEqual } from "lodash-es"; export async function getNotetypeNames(): Promise { return Notetypes.NotetypeNames.decode( - await postRequest("/_anki/notetypeNames", "") + await postRequest("/_anki/notetypeNames", ""), ); } export async function getChangeNotetypeInfo( oldNotetypeId: number, - newNotetypeId: number + newNotetypeId: number, ): Promise { return Notetypes.ChangeNotetypeInfo.decode( await postRequest( "/_anki/changeNotetypeInfo", - JSON.stringify({ oldNotetypeId, newNotetypeId }) - ) + JSON.stringify({ oldNotetypeId, newNotetypeId }), + ), ); } export async function changeNotetype( - input: Notetypes.ChangeNotetypeRequest + input: Notetypes.ChangeNotetypeRequest, ): Promise { const data: Uint8Array = Notetypes.ChangeNotetypeRequest.encode(input).finish(); await postRequest("/_anki/changeNotetype", data); @@ -98,7 +98,7 @@ export class ChangeNotetypeInfoWrapper { const usedEntries = new Set(this.mapForContext(ctx).filter((v) => v !== null)); const oldNames = this.getOldNames(ctx); const unusedIdxs = [...Array(oldNames.length).keys()].filter( - (idx) => !usedEntries.has(idx) + (idx) => !usedEntries.has(idx), ); const unusedNames = unusedIdxs.map((idx) => oldNames[idx]); unusedNames.sort(); @@ -150,7 +150,7 @@ export class ChangeNotetypeState { constructor( notetypes: Notetypes.NotetypeNames, - info: Notetypes.ChangeNotetypeInfo + info: Notetypes.ChangeNotetypeInfo, ) { this.info_ = new ChangeNotetypeInfoWrapper(info); this.info = readable(this.info_, (set) => { @@ -168,7 +168,7 @@ export class ChangeNotetypeState { this.notetypesSetter(this.buildNotetypeList()); const newInfo = await getChangeNotetypeInfo( this.info_.input().oldNotetypeId, - this.info_.input().newNotetypeId + this.info_.input().newNotetypeId, ); this.info_ = new ChangeNotetypeInfoWrapper(newInfo); @@ -215,7 +215,7 @@ export class ChangeNotetypeState { idx, name: entry.name, current: entry.id === currentId, - } as NotetypeListEntry) + } as NotetypeListEntry), ); } } diff --git a/ts/components/ButtonGroup.svelte b/ts/components/ButtonGroup.svelte index f80170c2b..6b9ad191d 100644 --- a/ts/components/ButtonGroup.svelte +++ b/ts/components/ButtonGroup.svelte @@ -66,11 +66,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const insertButton = (button: SvelteComponent, position: Identifier = 0) => addComponent(button, (added, parent) => - insertElement(added, parent, position) + insertElement(added, parent, position), ); const appendButton = (button: SvelteComponent, position: Identifier = -1) => addComponent(button, (added, parent) => - appendElement(added, parent, position) + appendElement(added, parent, position), ); const showButton = (id: Identifier) => @@ -80,7 +80,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const toggleButton = (id: Identifier) => updateRegistration( ({ detach }) => detach.update((old: boolean): boolean => !old), - id + id, ); Object.assign(api, { diff --git a/ts/components/ButtonToolbar.svelte b/ts/components/ButtonToolbar.svelte index f85eaa0f2..09951d265 100644 --- a/ts/components/ButtonToolbar.svelte +++ b/ts/components/ButtonToolbar.svelte @@ -48,11 +48,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const insertGroup = (group: SvelteComponent, position: Identifier = 0) => addComponent(group, (added, parent) => - insertElement(added, parent, position) + insertElement(added, parent, position), ); const appendGroup = (group: SvelteComponent, position: Identifier = -1) => addComponent(group, (added, parent) => - appendElement(added, parent, position) + appendElement(added, parent, position), ); const showGroup = (id: Identifier) => @@ -62,7 +62,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const toggleGroup = (id: Identifier) => updateRegistration( ({ detach }) => detach.update((old: boolean): boolean => !old), - id + id, ); Object.assign(api, { diff --git a/ts/components/Section.svelte b/ts/components/Section.svelte index 45ef6f567..95ec80c88 100644 --- a/ts/components/Section.svelte +++ b/ts/components/Section.svelte @@ -32,11 +32,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const insert = (group: SvelteComponent, position: Identifier = 0) => addComponent(group, (added, parent) => - insertElement(added, parent, position) + insertElement(added, parent, position), ); const append = (group: SvelteComponent, position: Identifier = -1) => addComponent(group, (added, parent) => - appendElement(added, parent, position) + appendElement(added, parent, position), ); const show = (id: Identifier) => @@ -46,7 +46,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const toggle = (id: Identifier) => updateRegistration( ({ detach }) => detach.update((old: boolean): boolean => !old), - id + id, ); Object.assign(api, { insert, append, show, hide, toggle }); diff --git a/ts/components/Shortcut.svelte b/ts/components/Shortcut.svelte index a06395ea1..fec8779d8 100644 --- a/ts/components/Shortcut.svelte +++ b/ts/components/Shortcut.svelte @@ -15,7 +15,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html registerShortcut( (event: KeyboardEvent) => dispatch("action", { originalEvent: event }), keyCombination, - target as any - ) + target as any, + ), ); diff --git a/ts/components/WithState.svelte b/ts/components/WithState.svelte index 14657087f..db356ee55 100644 --- a/ts/components/WithState.svelte +++ b/ts/components/WithState.svelte @@ -27,7 +27,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html export function updateAllState(event: Event): void { updateAllStateWithCallback((key: KeyType): boolean => - updaterMap.get(key)!(event) + updaterMap.get(key)!(event), ); } diff --git a/ts/components/helpers.ts b/ts/components/helpers.ts index e3e8e61a0..14e87cb77 100644 --- a/ts/components/helpers.ts +++ b/ts/components/helpers.ts @@ -2,7 +2,7 @@ // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html export function mergeTooltipAndShortcut( tooltip: string | undefined, - shortcutLabel: string | undefined + shortcutLabel: string | undefined, ): string | undefined { if (!tooltip && !shortcutLabel) { return undefined; diff --git a/ts/components/identifier.ts b/ts/components/identifier.ts index 977d69a89..8e4b74cc3 100644 --- a/ts/components/identifier.ts +++ b/ts/components/identifier.ts @@ -4,7 +4,7 @@ export type Identifier = string | number; export function findElement( collection: HTMLCollection, - idOrIndex: Identifier + idOrIndex: Identifier, ): [number, Element] | null { let result: [number, Element] | null = null; @@ -37,7 +37,7 @@ export function findElement( export function insertElement( element: Element, collection: Element, - idOrIndex: Identifier + idOrIndex: Identifier, ): number { const match = findElement(collection.children, idOrIndex); @@ -54,7 +54,7 @@ export function insertElement( export function appendElement( element: Element, collection: Element, - idOrIndex: Identifier + idOrIndex: Identifier, ): number { const match = findElement(collection.children, idOrIndex); @@ -72,7 +72,7 @@ export function appendElement( export function updateElement( f: (element: Element) => void, collection: Element, - idOrIndex: Identifier + idOrIndex: Identifier, ): number { const match = findElement(collection.children, idOrIndex); diff --git a/ts/components/registration.ts b/ts/components/registration.ts index 0ee6fa226..9999734f1 100644 --- a/ts/components/registration.ts +++ b/ts/components/registration.ts @@ -28,11 +28,11 @@ export interface RegistrationAPI { export interface DynamicRegistrationAPI { addComponent: ( component: SvelteComponent, - add: (added: Element, parent: Element) => number + add: (added: Element, parent: Element) => number, ) => void; updateRegistration: ( update: (registration: T) => void, - position: Identifier + position: Identifier, ) => void; } @@ -41,14 +41,14 @@ export function nodeIsElement(node: Node): node is Element { } export function makeInterface( - makeRegistration: () => T + makeRegistration: () => T, ): RegistrationAPI { const registrations: T[] = []; const items = writable(registrations); function registerComponent( index: number = registrations.length, - registration = makeRegistration() + registration = makeRegistration(), ): T { items.update((registrations) => { registrations.splice(index, 0, registration); @@ -64,13 +64,13 @@ export function makeInterface( function getDynamicInterface(elementRef: HTMLElement): DynamicRegistrationAPI { function addComponent( component: SvelteComponent, - add: (added: Element, parent: Element) => number + add: (added: Element, parent: Element) => number, ): void { const registration = makeRegistration(); const callback = ( mutations: MutationRecord[], - observer: MutationObserver + observer: MutationObserver, ): void => { for (const mutation of mutations) { for (const addedNode of mutation.addedNodes) { @@ -99,7 +99,7 @@ export function makeInterface( function updateRegistration( update: (registration: T) => void, - position: Identifier + position: Identifier, ): void { const match = findElement(elementRef.children, position); diff --git a/ts/congrats/lib.ts b/ts/congrats/lib.ts index 5825876a1..5a6e104ee 100644 --- a/ts/congrats/lib.ts +++ b/ts/congrats/lib.ts @@ -8,7 +8,7 @@ import * as tr from "../lib/ftl"; export async function getCongratsInfo(): Promise { return Scheduler.CongratsInfoResponse.decode( - await postRequest("/_anki/congratsInfo", "") + await postRequest("/_anki/congratsInfo", ""), ); } diff --git a/ts/deck-options/index.ts b/ts/deck-options/index.ts index 8f68c20fd..1fbd92af8 100644 --- a/ts/deck-options/index.ts +++ b/ts/deck-options/index.ts @@ -15,7 +15,7 @@ import { nightModeKey, touchDeviceKey, modalsKey } from "../components/context-k export async function deckOptions( target: HTMLDivElement, - deckId: number + deckId: number, ): Promise { const [info] = await Promise.all([ getDeckOptionsInfo(deckId), diff --git a/ts/deck-options/lib.test.ts b/ts/deck-options/lib.test.ts index 8d3131a71..61e16c101 100644 --- a/ts/deck-options/lib.test.ts +++ b/ts/deck-options/lib.test.ts @@ -94,7 +94,7 @@ const exampleData = { function startingState(): DeckOptionsState { return new DeckOptionsState( 123, - DeckConfig.DeckConfigsForUpdate.fromObject(exampleData) + DeckConfig.DeckConfigsForUpdate.fromObject(exampleData), ); } @@ -308,7 +308,7 @@ test("aux data", () => { JSON.parse(new TextDecoder().decode((c.config as any).other)) as Record< string, unknown - > + >, ); expect(json).toStrictEqual([ // other deck comes first diff --git a/ts/deck-options/lib.ts b/ts/deck-options/lib.ts index 8d10c6bfc..679cfebc9 100644 --- a/ts/deck-options/lib.ts +++ b/ts/deck-options/lib.ts @@ -13,15 +13,15 @@ import { localeCompare } from "../lib/i18n"; import type { DynamicSvelteComponent } from "../sveltelib/dynamicComponent"; export async function getDeckOptionsInfo( - deckId: number + deckId: number, ): Promise { return DeckConfig.DeckConfigsForUpdate.decode( - await postRequest("/_anki/deckConfigsForUpdate", JSON.stringify({ deckId })) + await postRequest("/_anki/deckConfigsForUpdate", JSON.stringify({ deckId })), ); } export async function saveDeckOptions( - input: DeckConfig.UpdateDeckConfigsRequest + input: DeckConfig.UpdateDeckConfigsRequest, ): Promise { const data: Uint8Array = DeckConfig.UpdateDeckConfigsRequest.encode(input).finish(); await postRequest("/_anki/updateDeckConfigs", data); @@ -84,7 +84,7 @@ export class DeckOptionsState { }); this.selectedIdx = Math.max( 0, - this.configs.findIndex((c) => c.config.id === this.currentDeck.configId) + this.configs.findIndex((c) => c.config.id === this.currentDeck.configId), ); this.v3Scheduler = data.v3Scheduler; this.haveAddons = data.haveAddons; @@ -284,17 +284,17 @@ export class DeckOptionsState { private getParentLimits(): ParentLimits { const parentConfigs = this.configs.filter((c) => - this.currentDeck.parentConfigIds.includes(c.config.id) + this.currentDeck.parentConfigIds.includes(c.config.id), ); const newCards = parentConfigs.reduce( (previous, current) => Math.min(previous, current.config.config?.newPerDay ?? 0), - 2 ** 31 + 2 ** 31, ); const reviews = parentConfigs.reduce( (previous, current) => Math.min(previous, current.config.config?.reviewsPerDay ?? 0), - 2 ** 31 + 2 ** 31, ); return { newCards, diff --git a/ts/editable/ContentEditable.svelte b/ts/editable/ContentEditable.svelte index 9a61f8967..7e2f0e5dd 100644 --- a/ts/editable/ContentEditable.svelte +++ b/ts/editable/ContentEditable.svelte @@ -10,7 +10,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html export let resolve: (editable: HTMLElement) => void; export let mirror: ( editable: HTMLElement, - params: { store: Writable } + params: { store: Writable }, ) => void; diff --git a/ts/editable/decorated.ts b/ts/editable/decorated.ts index 89f8366a5..760e75208 100644 --- a/ts/editable/decorated.ts +++ b/ts/editable/decorated.ts @@ -39,7 +39,7 @@ export interface DecoratedElementConstructor } export class CustomElementArray< - T extends CustomElementConstructor & WithTagName + T extends CustomElementConstructor & WithTagName, > extends Array { push(...elements: T[]): number { for (const element of elements) { diff --git a/ts/editable/mathjax-element.ts b/ts/editable/mathjax-element.ts index 6202bf27b..81ddac408 100644 --- a/ts/editable/mathjax-element.ts +++ b/ts/editable/mathjax-element.ts @@ -17,7 +17,7 @@ import Mathjax_svelte from "./Mathjax.svelte"; function moveNodeOutOfElement( element: Element, node: Node, - placement: "beforebegin" | "afterend" + placement: "beforebegin" | "afterend", ): Node { element.removeChild(node); @@ -105,7 +105,7 @@ export const Mathjax: DecoratedElementConstructor = class Mathjax return typeof block === "string" && block !== "false" ? `\\[${text}\\]` : `\\(${text}\\)`; - } + }, ); } @@ -114,11 +114,12 @@ export const Mathjax: DecoratedElementConstructor = class Mathjax .replace( mathjaxBlockDelimiterPattern, (_match: string, text: string) => - `${text}` + `${text}`, ) .replace( mathjaxInlineDelimiterPattern, - (_match: string, text: string) => `${text}` + (_match: string, text: string) => + `${text}`, ); } @@ -161,7 +162,7 @@ export const Mathjax: DecoratedElementConstructor = class Mathjax const context = new Map(); context.set( nightModeKey, - document.documentElement.classList.contains("night-mode") + document.documentElement.classList.contains("night-mode"), ); this.component = new Mathjax_svelte({ diff --git a/ts/editable/mathjax.ts b/ts/editable/mathjax.ts index 739b45f43..6338b3f5d 100644 --- a/ts/editable/mathjax.ts +++ b/ts/editable/mathjax.ts @@ -32,7 +32,7 @@ function getEmptyIcon(style: HTMLStyleElement): [string, string] { export function convertMathjax( input: string, nightMode: boolean, - fontSize: number + fontSize: number, ): [string, string] { const style = getStyle(getCSS(nightMode, fontSize)); diff --git a/ts/editor/CodeMirror.svelte b/ts/editor/CodeMirror.svelte index bcaf1cc87..4073ae2ca 100644 --- a/ts/editor/CodeMirror.svelte +++ b/ts/editor/CodeMirror.svelte @@ -50,7 +50,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html {}, { editor: { get: () => codeMirror }, - } + }, ) as CodeMirrorAPI; diff --git a/ts/editor/ColorButtons.svelte b/ts/editor/ColorButtons.svelte index 1bbaa7c1c..244413f49 100644 --- a/ts/editor/ColorButtons.svelte +++ b/ts/editor/ColorButtons.svelte @@ -43,7 +43,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html $directionStore, }, - } - ) as EditorFieldAPI + }, + ) as EditorFieldAPI, ); diff --git a/ts/editor/OldEditorAdapter.svelte b/ts/editor/OldEditorAdapter.svelte index 85d2c1df4..23943c46d 100644 --- a/ts/editor/OldEditorAdapter.svelte +++ b/ts/editor/OldEditorAdapter.svelte @@ -168,7 +168,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html function updateField(index: number, content: string): void { fieldSave.schedule( () => bridgeCommand(`key:${index}:${getNoteId()}:${content}`), - 600 + 600, ); } @@ -230,8 +230,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html }, { fields: { get: () => fieldApis }, - } - ) + }, + ), ); onMount(() => { @@ -271,7 +271,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html on:focusout={() => { $currentField = null; bridgeCommand( - `blur:${index}:${getNoteId()}:${get(fieldStores[index])}` + `blur:${index}:${getNoteId()}:${get(fieldStores[index])}`, ); }} --label-color={cols[index] === "dupe" diff --git a/ts/editor/PlainTextBadge.svelte b/ts/editor/PlainTextBadge.svelte index 4aa11bfd4..eff28698b 100644 --- a/ts/editor/PlainTextBadge.svelte +++ b/ts/editor/PlainTextBadge.svelte @@ -23,7 +23,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } onMount(() => - registerShortcut(toggle, keyCombination, editorField.element as HTMLElement) + registerShortcut(toggle, keyCombination, editorField.element as HTMLElement), ); diff --git a/ts/editor/RichTextInput.svelte b/ts/editor/RichTextInput.svelte index f0e5457b2..bdcb31153 100644 --- a/ts/editor/RichTextInput.svelte +++ b/ts/editor/RichTextInput.svelte @@ -62,7 +62,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html for (const decorated of decoratedElements) { for (const element of fragment.querySelectorAll( - decorated.tagName + decorated.tagName, ) as NodeListOf) { element.undecorate(); } @@ -195,7 +195,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html }, surround(before: string, after: string) { richTextPromise.then((richText) => - wrapInternal(richText.getRootNode() as any, before, after, false) + wrapInternal(richText.getRootNode() as any, before, after, false), ); }, preventResubscription, diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte index ddc2284c2..b3b93cde2 100644 --- a/ts/editor/TagEditor.svelte +++ b/ts/editor/TagEditor.svelte @@ -30,7 +30,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html let tagTypes: TagType[]; function tagsToTagTypes(tags: string[]): void { tagTypes = tags.map( - (tag: string): TagType => attachId(replaceWithUnicodeSeparator(tag)) + (tag: string): TagType => attachId(replaceWithUnicodeSeparator(tag)), ); } @@ -59,8 +59,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const data = await postRequest( "/_anki/completeTag", Tags.CompleteTagRequest.encode( - Tags.CompleteTagRequest.create({ input, matchLimit: 500 }) - ).finish() + Tags.CompleteTagRequest.create({ input, matchLimit: 500 }), + ).finish(), ); const response = Tags.CompleteTagResponse.decode(data); return response.tags; @@ -86,7 +86,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html (names: string[]): string[] => { autocompleteDisabled = names.length === 0; return names.map(replaceWithUnicodeSeparator); - } + }, ); } } @@ -152,7 +152,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html async function enterBehavior( index: number, start: number, - end: number + end: number, ): Promise { if (autocomplete.hasSelected()) { autocomplete.chooseSelected(); @@ -334,7 +334,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html function deselect() { tagTypes = tagTypes.map( - (tag: TagType): TagType => ({ ...tag, selected: false }) + (tag: TagType): TagType => ({ ...tag, selected: false }), ); selectionAnchor = null; selectionFocus = null; diff --git a/ts/editor/TagInput.svelte b/ts/editor/TagInput.svelte index d1e072d72..509fbd506 100644 --- a/ts/editor/TagInput.svelte +++ b/ts/editor/TagInput.svelte @@ -127,7 +127,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html event.preventDefault(); name = `${before.slice(0, -1)}${delimChar}${name.slice( positionEnd, - name.length + name.length, )}`; await tick(); @@ -199,7 +199,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const selection = document.getSelection(); event.clipboardData!.setData( "text/plain", - replaceWithColons(selection!.toString()) + replaceWithColons(selection!.toString()), ); } diff --git a/ts/editor/TemplateButtons.svelte b/ts/editor/TemplateButtons.svelte index 7b6d59289..89c30b204 100644 --- a/ts/editor/TemplateButtons.svelte +++ b/ts/editor/TemplateButtons.svelte @@ -39,7 +39,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html $activeInput?.surround( "", - "" + "", )} on:mount={withButton(createShortcut)} > @@ -103,7 +103,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html on:click={() => $activeInput?.surround( '', - "" + "", )} on:mount={withButton(createShortcut)} > @@ -121,7 +121,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html on:click={() => $activeInput?.surround( "\\ce{", - "}" + "}", )} on:mount={withButton(createShortcut)} > diff --git a/ts/editor/helpers.ts b/ts/editor/helpers.ts index 7ffd387b6..493e5f801 100644 --- a/ts/editor/helpers.ts +++ b/ts/editor/helpers.ts @@ -9,7 +9,7 @@ export function appendInParentheses(text: string, appendix: string): string { export function execCommand( command: string, showUI?: boolean | undefined, - value?: string | undefined + value?: string | undefined, ): void { document.execCommand(command, showUI, value); } diff --git a/ts/editor/image-overlay/WithImageConstrained.svelte b/ts/editor/image-overlay/WithImageConstrained.svelte index 248ffaf6b..fc20be737 100644 --- a/ts/editor/image-overlay/WithImageConstrained.svelte +++ b/ts/editor/image-overlay/WithImageConstrained.svelte @@ -37,7 +37,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const nth = Array.prototype.indexOf.call( (element.parentNode! as Document | ShadowRoot).children, - element + element, ) + 1; return [`${tagName}:nth-child(${nth})`, ...tokens]; } else { @@ -46,7 +46,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html 1; return createPathRecursive( [`${tagName}:nth-child(${nth})`, ...tokens], - element.parentElement + element.parentElement, ); } } @@ -92,7 +92,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html rule.style.setProperty( "height", height < maxHeight ? `${height}px` : "auto", - "important" + "important", ); } else { // square or restricted by width @@ -100,7 +100,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html rule.style.setProperty( "width", width < maxWidth ? `${width}px` : "auto", - "important" + "important", ); rule.style.setProperty("height", "auto", "important"); @@ -125,7 +125,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html images.push(image); const index = sheet.insertRule( `${createPath(image)} {}`, - sheet.cssRules.length + sheet.cssRules.length, ); const rule = sheet.cssRules[index] as CSSStyleRule; setImageRule(image, rule); @@ -151,7 +151,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const mutationObserver = new MutationObserver((mutations) => { const addedImages = mutations.flatMap((mutation) => - filterImages([...mutation.addedNodes]) + filterImages([...mutation.addedNodes]), ); for (const image of addedImages) { @@ -159,7 +159,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } const removedImages = mutations.flatMap((mutation) => - filterImages([...mutation.removedNodes]) + filterImages([...mutation.removedNodes]), ); for (const image of removedImages) { diff --git a/ts/editor/index.ts b/ts/editor/index.ts index f6cf9af65..b4da15b43 100644 --- a/ts/editor/index.ts +++ b/ts/editor/index.ts @@ -15,7 +15,7 @@ export const $editorToolbar = new Promise(noop); export function pasteHTML( html: string, internal: boolean, - extendedMode: boolean + extendedMode: boolean, ): void { html = filterHTML(html, internal, extendedMode); @@ -76,7 +76,7 @@ function setupNoteEditor(i18n: Promise): Promise { context.set( nightModeKey, - document.documentElement.classList.contains("night-mode") + document.documentElement.classList.contains("night-mode"), ); i18n.then(() => { diff --git a/ts/graphs/AddedGraph.svelte b/ts/graphs/AddedGraph.svelte index 461f829c1..f09c474be 100644 --- a/ts/graphs/AddedGraph.svelte +++ b/ts/graphs/AddedGraph.svelte @@ -40,7 +40,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html addedData, graphRange, dispatch, - $browserLinksSupported + $browserLinksSupported, ); } diff --git a/ts/graphs/CalendarGraph.svelte b/ts/graphs/CalendarGraph.svelte index e49102590..0e357d877 100644 --- a/ts/graphs/CalendarGraph.svelte +++ b/ts/graphs/CalendarGraph.svelte @@ -64,7 +64,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html targetYear, nightMode, revlogRange, - calendarFirstDayOfWeek.set + calendarFirstDayOfWeek.set, ); } diff --git a/ts/graphs/EaseGraph.svelte b/ts/graphs/EaseGraph.svelte index de8568311..5f1fe30ef 100644 --- a/ts/graphs/EaseGraph.svelte +++ b/ts/graphs/EaseGraph.svelte @@ -30,7 +30,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html [histogramData, tableData] = prepareData( gatherData(sourceData), dispatch, - $browserLinksSupported + $browserLinksSupported, ); } diff --git a/ts/graphs/FutureDue.svelte b/ts/graphs/FutureDue.svelte index f7a304bee..3c0508046 100644 --- a/ts/graphs/FutureDue.svelte +++ b/ts/graphs/FutureDue.svelte @@ -42,7 +42,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html graphRange, $futureDueShowBacklog, dispatch, - $browserLinksSupported + $browserLinksSupported, )); } diff --git a/ts/graphs/IntervalsGraph.svelte b/ts/graphs/IntervalsGraph.svelte index 82ecf8d1f..1d3b302ca 100644 --- a/ts/graphs/IntervalsGraph.svelte +++ b/ts/graphs/IntervalsGraph.svelte @@ -42,7 +42,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html intervalData, range, dispatch, - $browserLinksSupported + $browserLinksSupported, ); } diff --git a/ts/graphs/ReviewsGraph.svelte b/ts/graphs/ReviewsGraph.svelte index 04a53e05c..e5c2e98cf 100644 --- a/ts/graphs/ReviewsGraph.svelte +++ b/ts/graphs/ReviewsGraph.svelte @@ -40,7 +40,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html bounds, graphData, graphRange, - showTime + showTime, ); } diff --git a/ts/graphs/WithGraphData.svelte b/ts/graphs/WithGraphData.svelte index 3b476328b..f7a3aee85 100644 --- a/ts/graphs/WithGraphData.svelte +++ b/ts/graphs/WithGraphData.svelte @@ -20,25 +20,25 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html async function getGraphData( search: string, - days: number + days: number, ): Promise { return Stats.GraphsResponse.decode( - await postRequest("/_anki/graphData", JSON.stringify({ search, days })) + await postRequest("/_anki/graphData", JSON.stringify({ search, days })), ); } async function getGraphPreferences(): Promise { return Stats.GraphPreferences.decode( - await postRequest("/_anki/graphPreferences", JSON.stringify({})) + await postRequest("/_anki/graphPreferences", JSON.stringify({})), ); } async function setGraphPreferences( - prefs: PreferencePayload + prefs: PreferencePayload, ): Promise { await postRequest( "/_anki/setGraphPreferences", - Stats.GraphPreferences.encode(prefs).finish() + Stats.GraphPreferences.encode(prefs).finish(), ); } @@ -58,9 +58,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html setGraphPreferences, Stats.GraphPreferences.toObject.bind(Stats.GraphPreferences) as ( preferences: Stats.GraphPreferences, - options: { defaults: boolean } - ) => PreferenceRaw - ) + options: { defaults: boolean }, + ) => PreferenceRaw, + ), ); $: revlogRange = daysToRevlogRange($days); diff --git a/ts/graphs/added.ts b/ts/graphs/added.ts index dca8ad566..c0c01ced4 100644 --- a/ts/graphs/added.ts +++ b/ts/graphs/added.ts @@ -51,7 +51,7 @@ export function buildHistogram( data: GraphData, range: GraphRange, dispatch: SearchDispatch, - browserLinksSupported: boolean + browserLinksSupported: boolean, ): [HistogramData | null, TableDatum[]] { // get min/max const total = data.daysAdded.length; @@ -91,7 +91,7 @@ export function buildHistogram( const adjustedRange = scaleLinear().range([0.7, 0.3]); const colourScale = scaleSequential((n) => - interpolateBlues(adjustedRange(n)!) + interpolateBlues(adjustedRange(n)!), ).domain([xMax!, xMin!]); const totalInPeriod = sum(bins, (bin) => bin.length); @@ -111,7 +111,7 @@ export function buildHistogram( function hoverText( bin: Bin, cumulative: number, - _percent: number + _percent: number, ): string { const day = dayLabel(bin.x0!, bin.x1!); const cards = tr.statisticsCards({ cards: bin.length }); diff --git a/ts/graphs/buttons.ts b/ts/graphs/buttons.ts index 10ae799a9..ced410fda 100644 --- a/ts/graphs/buttons.ts +++ b/ts/graphs/buttons.ts @@ -97,7 +97,7 @@ export function renderButtons( svgElem: SVGElement, bounds: GraphBounds, origData: Stats.GraphsResponse, - range: GraphRange + range: GraphRange, ): void { const sourceData = gatherData(origData, range); const data = [ @@ -129,7 +129,7 @@ export function renderButtons( const total = sum(groupData, (d) => d.count); const correct = sum( groupData.filter((d) => d.buttonNum > 1), - (d) => d.count + (d) => d.count, ); const percent = total ? ((correct / total) * 100).toFixed(2) : "0"; return { total, correct, percent }; @@ -170,8 +170,8 @@ export function renderButtons( } return `${kind} \u200e(${totalCorrect(d).percent}%)`; }) as any) - .tickSizeOuter(0) - ) + .tickSizeOuter(0), + ), ) .attr("direction", "ltr"); @@ -193,8 +193,8 @@ export function renderButtons( selection.transition(trans).call( axisLeft(y) .ticks(bounds.height / 50) - .tickSizeOuter(0) - ) + .tickSizeOuter(0), + ), ) .attr("direction", "ltr"); @@ -207,7 +207,7 @@ export function renderButtons( .transition(trans) .attr( "x", - (d: Datum) => xGroup(d.group)! + xButton(d.buttonNum.toString())! + (d: Datum) => xGroup(d.group)! + xButton(d.buttonNum.toString())!, ) .attr("y", (d: Datum) => y(d.count)!) .attr("height", (d: Datum) => y(0)! - y(d.count)!) @@ -225,7 +225,7 @@ export function renderButtons( .attr( "x", (d: Datum) => - xGroup(d.group)! + xButton(d.buttonNum.toString())! + xGroup(d.group)! + xButton(d.buttonNum.toString())!, ) .attr("y", y(0)!) .attr("height", 0) @@ -233,8 +233,8 @@ export function renderButtons( (update) => update.call(updateBar), (remove) => remove.call((remove) => - remove.transition(trans).attr("height", 0).attr("y", y(0)!) - ) + remove.transition(trans).attr("height", 0).attr("y", y(0)!), + ), ); // hover/tooltip diff --git a/ts/graphs/calendar.ts b/ts/graphs/calendar.ts index 4797ab0a9..746532f27 100644 --- a/ts/graphs/calendar.ts +++ b/ts/graphs/calendar.ts @@ -54,7 +54,7 @@ const Weekday = Stats.GraphPreferences.Weekday; /* enum */ export function gatherData( data: Stats.GraphsResponse, - firstDayOfWeek: WeekdayType + firstDayOfWeek: WeekdayType, ): GraphData { const reviewCount = new Map(); @@ -63,7 +63,7 @@ export function gatherData( continue; } const day = Math.ceil( - ((review.id as number) / 1000 - data.nextDayAtSecs) / 86400 + ((review.id as number) / 1000 - data.nextDayAtSecs) / 86400, ); const count = reviewCount.get(day) ?? 0; reviewCount.set(day, count + 1); @@ -86,7 +86,7 @@ export function renderCalendar( targetYear: number, nightMode: boolean, revlogRange: RevlogRange, - setFirstDayOfWeek: (d: number) => void + setFirstDayOfWeek: (d: number) => void, ): void { const svg = select(svgElem); const now = new Date(); @@ -187,8 +187,8 @@ export function renderCalendar( .on("click", null) .filter((d: number) => [Weekday.SUNDAY, Weekday.MONDAY, Weekday.FRIDAY, Weekday.SATURDAY].includes( - d - ) + d, + ), ) .on("click", (_event: MouseEvent, d: number) => setFirstDayOfWeek(d)); diff --git a/ts/graphs/card-counts.ts b/ts/graphs/card-counts.ts index 7897982af..1d5b1e50e 100644 --- a/ts/graphs/card-counts.ts +++ b/ts/graphs/card-counts.ts @@ -124,7 +124,7 @@ function countCards(cards: Cards.ICard[], separateInactive: boolean): Count[] { export function gatherData( data: Stats.GraphsResponse, - separateInactive: boolean + separateInactive: boolean, ): GraphData { const totalCards = data.cards.length; const counts = countCards(data.cards, separateInactive); @@ -158,7 +158,7 @@ export interface TableDatum { export function renderCards( svgElem: SVGElement, bounds: GraphBounds, - sourceData: GraphData + sourceData: GraphData, ): TableDatum[] { const summed = cumsum(sourceData.counts, (d: Count) => d[1]); const data = Array.from(summed).map((n, idx) => { @@ -200,12 +200,12 @@ export function renderCards( d.transition(trans).attrTween("d", (d) => { const interpolator = interpolate( { startAngle: 0, endAngle: 0 }, - d + d, ); return (t): string => arcGen(interpolator(t) as any) as string; - }) + }), ); - } + }, ); x.range([bounds.marginLeft, bounds.width - bounds.marginRight]); diff --git a/ts/graphs/ease.ts b/ts/graphs/ease.ts index 1ab829900..ca3b6337d 100644 --- a/ts/graphs/ease.ts +++ b/ts/graphs/ease.ts @@ -46,7 +46,7 @@ function makeQuery(start: number, end: number): string { function getAdjustedScaleAndTicks( min: number, max: number, - desiredBars: number + desiredBars: number, ): [ScaleLinear, number[]] { const prescale = scaleLinear().domain([min, max]).nice(); const ticks = prescale.ticks(desiredBars); @@ -70,7 +70,7 @@ function getAdjustedScaleAndTicks( export function prepareData( data: GraphData, dispatch: SearchDispatch, - browserLinksSupported: boolean + browserLinksSupported: boolean, ): [HistogramData | null, TableDatum[]] { // get min/max const allEases = data.eases; diff --git a/ts/graphs/future-due.ts b/ts/graphs/future-due.ts index 2c132fea5..8c17eddd3 100644 --- a/ts/graphs/future-due.ts +++ b/ts/graphs/future-due.ts @@ -66,7 +66,7 @@ export function gatherData(data: Stats.GraphsResponse): GraphData { const dueCounts = rollup( due, (v) => v.length, - (d) => d + (d) => d, ); return { dueCounts, haveBacklog }; } @@ -95,7 +95,7 @@ export function buildHistogram( range: GraphRange, backlog: boolean, dispatch: SearchDispatch, - browserLinksSupported: boolean + browserLinksSupported: boolean, ): FutureDueResponse { const output = { histogramData: null, tableData: [] }; // get min/max @@ -143,7 +143,7 @@ export function buildHistogram( const adjustedRange = scaleLinear().range([0.7, 0.3]); const colourScale = scaleSequential((n) => - interpolateGreens(adjustedRange(n)!) + interpolateGreens(adjustedRange(n)!), ).domain([xMin!, xMax!]); const total = sum(bins as any, binValue); @@ -151,7 +151,7 @@ export function buildHistogram( function hoverText( bin: Bin, cumulative: number, - _percent: number + _percent: number, ): string { const days = dayLabel(bin.x0!, bin.x1!); const cards = tr.statisticsCardsDue({ diff --git a/ts/graphs/graph-helpers.ts b/ts/graphs/graph-helpers.ts index ec5e3be7a..59e93a04f 100644 --- a/ts/graphs/graph-helpers.ts +++ b/ts/graphs/graph-helpers.ts @@ -56,7 +56,7 @@ export function defaultGraphBounds(): GraphBounds { export function setDataAvailable( svg: Selection, - available: boolean + available: boolean, ): void { svg.select(".no-data") .attr("pointer-events", available ? "none" : "all") @@ -67,7 +67,7 @@ export function setDataAvailable( export function millisecondCutoffForRange( range: GraphRange, - nextDayAtSecs: number + nextDayAtSecs: number, ): number { let days; switch (range) { @@ -96,5 +96,5 @@ export interface TableDatum { export type SearchEventMap = { search: { query: string } }; export type SearchDispatch = >( type: EventKey, - detail: SearchEventMap[EventKey] + detail: SearchEventMap[EventKey], ) => void; diff --git a/ts/graphs/graphs.html b/ts/graphs/graphs.html index b2fdee675..5d1751042 100644 --- a/ts/graphs/graphs.html +++ b/ts/graphs/graphs.html @@ -27,7 +27,7 @@ ], { controller: anki.RangeBox, - } + }, ); diff --git a/ts/graphs/histogram-graph.ts b/ts/graphs/histogram-graph.ts index 221294092..7b5dedd64 100644 --- a/ts/graphs/histogram-graph.ts +++ b/ts/graphs/histogram-graph.ts @@ -31,7 +31,7 @@ export interface HistogramData { hoverText: ( bin: Bin, cumulative: number, - percent: number + percent: number, ) => string; onClick: ((data: Bin) => void) | null; showArea: boolean; @@ -43,7 +43,7 @@ export interface HistogramData { export function histogramGraph( svgElem: SVGElement, bounds: GraphBounds, - data: HistogramData | null + data: HistogramData | null, ): void { const svg = select(svgElem); const trans = svg.transition().duration(600) as any; @@ -64,8 +64,8 @@ export function histogramGraph( axisBottom(x) .ticks(7) .tickSizeOuter(0) - .tickFormat((data.xTickFormat ?? null) as any) - ) + .tickFormat((data.xTickFormat ?? null) as any), + ), ) .attr("direction", "ltr"); @@ -81,8 +81,8 @@ export function histogramGraph( selection.transition(trans).call( axisLeft(y) .ticks(bounds.height / 50) - .tickSizeOuter(0) - ) + .tickSizeOuter(0), + ), ) .attr("direction", "ltr"); @@ -118,8 +118,8 @@ export function histogramGraph( (update) => update.call(updateBar), (remove) => remove.call((remove) => - remove.transition(trans).attr("height", 0).attr("y", y(0)!) - ) + remove.transition(trans).attr("height", 0).attr("y", y(0)!), + ), ); // cumulative area @@ -135,8 +135,8 @@ export function histogramGraph( selection.transition(trans).call( axisRight(yAreaScale) .ticks(bounds.height / 50) - .tickSizeOuter(0) - ) + .tickSizeOuter(0), + ), ) .attr("direction", "ltr"); @@ -154,12 +154,12 @@ export function histogramGraph( } }) .y0(bounds.height - bounds.marginBottom) - .y1((d: any) => yAreaScale(d)!) as any + .y1((d: any) => yAreaScale(d)!) as any, ); } const hoverData: [Bin, number][] = data.bins.map( - (bin: Bin, index: number) => [bin, areaData[index + 1]] + (bin: Bin, index: number) => [bin, areaData[index + 1]], ); // hover/tooltip diff --git a/ts/graphs/hours.ts b/ts/graphs/hours.ts index 3724bb301..e01e915f9 100644 --- a/ts/graphs/hours.ts +++ b/ts/graphs/hours.ts @@ -60,7 +60,7 @@ function gatherData(data: Stats.GraphsResponse, range: GraphRange): Hour[] { } const hour = Math.floor( - (((review.id as number) / 1000 + data.localOffsetSecs) / 3600) % 24 + (((review.id as number) / 1000 + data.localOffsetSecs) / 3600) % 24, ); hours[hour].totalCount += 1; if (review.buttonChosen != 1) { @@ -75,7 +75,7 @@ export function renderHours( svgElem: SVGElement, bounds: GraphBounds, origData: Stats.GraphsResponse, - range: GraphRange + range: GraphRange, ): void { const data = gatherData(origData, range); @@ -97,7 +97,7 @@ export function renderHours( .paddingInner(0.1); svg.select(".x-ticks") .call((selection) => - selection.transition(trans).call(axisBottom(x).tickSizeOuter(0)) + selection.transition(trans).call(axisBottom(x).tickSizeOuter(0)), ) .selectAll(".tick") .selectAll("text") @@ -121,8 +121,8 @@ export function renderHours( selection.transition(trans).call( axisLeft(y) .ticks(bounds.height / 50) - .tickSizeOuter(0) - ) + .tickSizeOuter(0), + ), ) .attr("direction", "ltr"); @@ -156,8 +156,8 @@ export function renderHours( (update) => update.call(updateBar), (remove) => remove.call((remove) => - remove.transition(trans).attr("height", 0).attr("y", y(0)!) - ) + remove.transition(trans).attr("height", 0).attr("y", y(0)!), + ), ); svg.select(".y2-ticks") @@ -166,8 +166,8 @@ export function renderHours( axisRight(yArea) .ticks(bounds.height / 50) .tickFormat((n: any) => `${Math.round(n * 100)}%`) - .tickSizeOuter(0) - ) + .tickSizeOuter(0), + ), ) .attr("direction", "ltr"); @@ -185,7 +185,7 @@ export function renderHours( .y1((d: Hour) => { const correctRatio = d.correctCount! / d.totalCount!; return yArea(isNaN(correctRatio) ? 0 : correctRatio)!; - }) + }), ); function tooltipText(d: Hour): string { diff --git a/ts/graphs/index.ts b/ts/graphs/index.ts index bee33dd83..3acfacba0 100644 --- a/ts/graphs/index.ts +++ b/ts/graphs/index.ts @@ -29,7 +29,7 @@ export function graphs( search = "deck:current", days = 365, controller = null as SvelteComponent | null, - } = {} + } = {}, ): void { const nightMode = checkNightMode(); diff --git a/ts/graphs/intervals.ts b/ts/graphs/intervals.ts index 11c796659..915206a42 100644 --- a/ts/graphs/intervals.ts +++ b/ts/graphs/intervals.ts @@ -46,7 +46,7 @@ export function gatherIntervalData(data: Stats.GraphsResponse): IntervalGraphDat export function intervalLabel( daysStart: number, daysEnd: number, - cards: number + cards: number, ): string { if (daysEnd - daysStart <= 1) { // singular @@ -79,7 +79,7 @@ export function prepareIntervalData( data: IntervalGraphData, range: IntervalRange, dispatch: SearchDispatch, - browserLinksSupported: boolean + browserLinksSupported: boolean, ): [HistogramData | null, TableDatum[]] { // get min/max const allIntervals = data.intervals; @@ -122,7 +122,7 @@ export function prepareIntervalData( const prescale = scaleLinear().domain([xMin!, xMax!]); const scale = scaleLinear().domain( - (niceNecessary ? prescale.nice() : prescale).domain().map(increment) + (niceNecessary ? prescale.nice() : prescale).domain().map(increment), ); const bins = histogram() @@ -137,13 +137,13 @@ export function prepareIntervalData( const adjustedRange = scaleLinear().range([0.7, 0.3]); const colourScale = scaleSequential((n) => - interpolateBlues(adjustedRange(n)!) + interpolateBlues(adjustedRange(n)!), ).domain([xMax!, xMin!]); function hoverText( bin: Bin, _cumulative: number, - percent: number + percent: number, ): string { // const day = dayLabel(bin.x0!, bin.x1!); const interval = intervalLabel(bin.x0!, bin.x1!, bin.length); diff --git a/ts/graphs/reviews.ts b/ts/graphs/reviews.ts index 00a6a2617..88b480b19 100644 --- a/ts/graphs/reviews.ts +++ b/ts/graphs/reviews.ts @@ -65,7 +65,7 @@ export function gatherData(data: Stats.GraphsResponse): GraphData { continue; } const day = Math.ceil( - ((review.id as number) / 1000 - data.nextDayAtSecs) / 86400 + ((review.id as number) / 1000 - data.nextDayAtSecs) / 86400, ); const countEntry = reviewCount.get(day) ?? reviewCount.set(day, { ...empty }).get(day)!; @@ -131,7 +131,7 @@ export function renderReviews( bounds: GraphBounds, sourceData: GraphData, range: GraphRange, - showTime: boolean + showTime: boolean, ): TableDatum[] { const svg = select(svgElem); const trans = svg.transition().duration(600) as any; @@ -178,7 +178,7 @@ export function renderReviews( x.range([bounds.marginLeft, bounds.width - bounds.marginRight]); svg.select(".x-ticks") .call((selection) => - selection.transition(trans).call(axisBottom(x).ticks(7).tickSizeOuter(0)) + selection.transition(trans).call(axisBottom(x).ticks(7).tickSizeOuter(0)), ) .attr("direction", "ltr"); @@ -207,8 +207,8 @@ export function renderReviews( axisLeft(y) .ticks(bounds.height / 50) .tickSizeOuter(0) - .tickFormat(yTickFormat as any) - ) + .tickFormat(yTickFormat as any), + ), ) .attr("direction", "ltr"); @@ -222,19 +222,19 @@ export function renderReviews( const cappedRange = scaleLinear().range([0.3, 0.5]); const shiftedRange = scaleLinear().range([0.4, 0.7]); const darkerGreens = scaleSequential((n) => - interpolateGreens(shiftedRange(n)!) + interpolateGreens(shiftedRange(n)!), ).domain(x.domain() as any); const lighterGreens = scaleSequential((n) => - interpolateGreens(cappedRange(n)!) + interpolateGreens(cappedRange(n)!), ).domain(x.domain() as any); const reds = scaleSequential((n) => interpolateReds(cappedRange(n)!)).domain( - x.domain() as any + x.domain() as any, ); const oranges = scaleSequential((n) => interpolateOranges(cappedRange(n)!)).domain( - x.domain() as any + x.domain() as any, ); const purples = scaleSequential((n) => interpolatePurples(cappedRange(n)!)).domain( - x.domain() as any + x.domain() as any, ); function binColor(idx: BinIndex): ScaleSequential { @@ -317,8 +317,8 @@ export function renderReviews( (update) => update.call((d) => updateBar(d, barNum)), (remove) => remove.call((remove) => - remove.transition(trans).attr("height", 0).attr("y", y(0)!) - ) + remove.transition(trans).attr("height", 0).attr("y", y(0)!), + ), ); } @@ -337,8 +337,8 @@ export function renderReviews( axisRight(yAreaScale) .ticks(bounds.height / 50) .tickFormat(yTickFormat as any) - .tickSizeOuter(0) - ) + .tickSizeOuter(0), + ), ) .attr("direction", "ltr"); @@ -356,12 +356,12 @@ export function renderReviews( } }) .y0(bounds.height - bounds.marginBottom) - .y1((d: any) => yAreaScale(d)!) as any + .y1((d: any) => yAreaScale(d)!) as any, ); } const hoverData: [Bin, number][] = bins.map( - (bin: Bin, index: number) => [bin, areaData[index + 1]] + (bin: Bin, index: number) => [bin, areaData[index + 1]], ); // hover/tooltip diff --git a/ts/graphs/today.ts b/ts/graphs/today.ts index 568e536dc..18f25343b 100644 --- a/ts/graphs/today.ts +++ b/ts/graphs/today.ts @@ -74,7 +74,7 @@ export function gatherData(data: Stats.GraphsResponse): TodayData { const againCount = answerCount - correctCount; let againCountText = tr.statisticsTodayAgainCount(); againCountText += ` ${againCount} (${((againCount / answerCount) * 100).toFixed( - 2 + 2, )}%)`; const typeCounts = tr.statisticsTodayTypeCounts({ learnCount, diff --git a/ts/html-filter/element.ts b/ts/html-filter/element.ts index f8027d9bb..ab0e5974c 100644 --- a/ts/html-filter/element.ts +++ b/ts/html-filter/element.ts @@ -17,7 +17,7 @@ type FilterMethod = (element: Element) => void; function filterAttributes( attributePredicate: (attributeName: string) => boolean, - element: Element + element: Element, ): void { for (const attr of [...element.attributes]) { const attrName = attr.name.toUpperCase(); @@ -37,7 +37,7 @@ const allow = (element: Element): void => filterAttributes( (attributeName: string) => attrs.includes(attributeName), - element + element, ); function unwrapElement(element: Element): void { diff --git a/ts/html-filter/node.ts b/ts/html-filter/node.ts index 75787f07d..989bc028c 100644 --- a/ts/html-filter/node.ts +++ b/ts/html-filter/node.ts @@ -7,7 +7,7 @@ export function removeNode(element: Node): void { function iterateElement( filter: (node: Node) => void, - fragment: DocumentFragment | Element + fragment: DocumentFragment | Element, ): void { for (const child of [...fragment.childNodes]) { filter(child); diff --git a/ts/html-filter/styling.ts b/ts/html-filter/styling.ts index 5b6833d73..1d05a0bc5 100644 --- a/ts/html-filter/styling.ts +++ b/ts/html-filter/styling.ts @@ -51,9 +51,9 @@ const filterStyling = }; export const filterStylingNightMode = filterStyling( - allowPropertiesBlockValues(stylingNightMode) + allowPropertiesBlockValues(stylingNightMode), ); export const filterStylingLightMode = filterStyling( - allowPropertiesBlockValues(stylingLightMode) + allowPropertiesBlockValues(stylingLightMode), ); export const filterStylingInternal = filterStyling(blockProperties(stylingInternal)); diff --git a/ts/lib/dom.ts b/ts/lib/dom.ts index 67c47bd99..be51ac731 100644 --- a/ts/lib/dom.ts +++ b/ts/lib/dom.ts @@ -106,7 +106,7 @@ const isListItem = (element: Element): element is HTMLLIElement => const isParagraph = (element: Element): element is HTMLParamElement => element.tagName === "P"; const isBlockElement = ( - element: Element + element: Element, ): element is HTMLLIElement & HTMLParamElement => isListItem(element) || isParagraph(element); diff --git a/ts/lib/i18n/bundles.ts b/ts/lib/i18n/bundles.ts index d83860ea3..f60aadedc 100644 --- a/ts/lib/i18n/bundles.ts +++ b/ts/lib/i18n/bundles.ts @@ -21,19 +21,19 @@ function toFluentNumber(num: number): FluentNumber { } function formatArgs( - args: Record + args: Record, ): Record { return Object.fromEntries( Object.entries(args).map(([key, value]) => [ key, typeof value === "number" ? toFluentNumber(value) : value, - ]) + ]), ); } export function getMessage( key: string, - args: Record = {} + args: Record = {}, ): string | null { for (const bundle of bundles) { const msg = bundle.getMessage(key); diff --git a/ts/lib/i18n/utils.ts b/ts/lib/i18n/utils.ts index 9ff8d9e4f..63288d640 100644 --- a/ts/lib/i18n/utils.ts +++ b/ts/lib/i18n/utils.ts @@ -43,7 +43,7 @@ let langs: string[] = []; export function toLocaleString( date: Date, - options?: Intl.DateTimeFormatOptions + options?: Intl.DateTimeFormatOptions, ): string { return date.toLocaleDateString(langs, options); } @@ -51,7 +51,7 @@ export function toLocaleString( export function localeCompare( first: string, second: string, - options?: Intl.CollatorOptions + options?: Intl.CollatorOptions, ): number { return first.localeCompare(second, langs, options); } diff --git a/ts/lib/keys.ts b/ts/lib/keys.ts index 8de5acd76..ae7f0579e 100644 --- a/ts/lib/keys.ts +++ b/ts/lib/keys.ts @@ -23,13 +23,13 @@ export const checkModifiers = ( matches: boolean, currentModifier: Modifier, - currentIndex: number + currentIndex: number, ): boolean => matches && (optional.includes(currentModifier as Modifier) || event.getModifierState(platformModifiers[currentIndex]) === required.includes(currentModifier)), - true + true, ); }; diff --git a/ts/lib/postrequest.ts b/ts/lib/postrequest.ts index 64abd1d49..a94583c95 100644 --- a/ts/lib/postrequest.ts +++ b/ts/lib/postrequest.ts @@ -4,7 +4,7 @@ export async function postRequest( path: string, body: string | Uint8Array, - headers: Record = {} + headers: Record = {}, ): Promise { if (body instanceof Uint8Array) { headers["Content-type"] = "application/octet-stream"; diff --git a/ts/lib/proto.ts b/ts/lib/proto.ts index 3604a8327..9e5ce15fd 100644 --- a/ts/lib/proto.ts +++ b/ts/lib/proto.ts @@ -21,7 +21,7 @@ export function unwrapOptionalNumber( | Generic.OptionalInt32 | Generic.OptionalUInt32 | null - | undefined + | undefined, ): number | undefined { if (msg && msg !== null) { if (msg.val !== null) { diff --git a/ts/lib/register-package.ts b/ts/lib/register-package.ts index 62eaf3042..fcf1788e2 100644 --- a/ts/lib/register-package.ts +++ b/ts/lib/register-package.ts @@ -8,7 +8,7 @@ const prohibit = () => false; export function registerPackage( name: string, entries: Record, - deprecation?: Record + deprecation?: Record, ): void { const pack = deprecation ? new Proxy(entries, { @@ -36,7 +36,7 @@ function hasPackages(...names: string[]): boolean { const libraries = listPackages(); return names.reduce( (accu: boolean, name: string) => accu && libraries.includes(name), - true + true, ); } @@ -53,5 +53,5 @@ registerPackage( }, { [immediatelyDeprecated.name]: "Do not use this function", - } + }, ); diff --git a/ts/lib/shortcuts.ts b/ts/lib/shortcuts.ts index 44d5a6899..fad8d8cdf 100644 --- a/ts/lib/shortcuts.ts +++ b/ts/lib/shortcuts.ts @@ -47,7 +47,7 @@ function splitKeyCombinationString(keyCombinationString: string): string[][] { function toPlatformString(keyCombination: string[]): string { return ( modifiersToPlatformString( - keyCombination.slice(0, -1).filter(isRequiredModifier) + keyCombination.slice(0, -1).filter(isRequiredModifier), ) + keyToPlatformString(keyCombination[keyCombination.length - 1]) ); } @@ -80,11 +80,11 @@ function removeTrailing(modifier: string): string { // function checkModifiers(event: KeyboardEvent, modifiers: string[]): boolean { function separateRequiredOptionalModifiers( - modifiers: string[] + modifiers: string[], ): [Modifier[], Modifier[]] { const [requiredModifiers, otherModifiers] = partition( isRequiredModifier, - modifiers + modifiers, ); const optionalModifiers = otherModifiers.map(removeTrailing); @@ -104,7 +104,7 @@ function keyToCode(key: string): number { } function keyCombinationToCheck( - keyCombination: string[] + keyCombination: string[], ): (event: KeyboardEvent) => boolean { const keyCode = keyToCode(keyCombination[keyCombination.length - 1]); const modifiers = keyCombination.slice(0, -1); @@ -147,7 +147,7 @@ function innerShortcut( export function registerShortcut( callback: (event: KeyboardEvent) => void, keyCombinationString: string, - target: EventTarget | Document = document + target: EventTarget | Document = document, ): () => void { const [check, ...restChecks] = splitKeyCombinationString(keyCombinationString).map(keyCombinationToCheck); diff --git a/ts/lib/time.ts b/ts/lib/time.ts index 58487c8c1..847683ca0 100644 --- a/ts/lib/time.ts +++ b/ts/lib/time.ts @@ -107,7 +107,7 @@ export function studiedToday(cards: number, secs: number): string { function i18nFuncForUnit( unit: TimespanUnit, - short: boolean + short: boolean, ): ({ amount: number }) => string { if (short) { switch (unit) { diff --git a/ts/lib/wrap.ts b/ts/lib/wrap.ts index 7f733e232..0e7d73ee3 100644 --- a/ts/lib/wrap.ts +++ b/ts/lib/wrap.ts @@ -22,7 +22,7 @@ export function wrapInternal( root: DocumentOrShadowRoot, front: string, back: string, - plainText: boolean + plainText: boolean, ): void { const selection = root.getSelection()!; const range = selection.getRangeAt(0); @@ -41,7 +41,7 @@ export function wrapInternal( if ( !span.innerHTML && /* ugly solution: treat differently than other wraps */ !front.includes( - " { return Scheduler.NextCardStates.decode( - await postRequest("/_anki/nextCardStates", "") + await postRequest("/_anki/nextCardStates", ""), ); } async function setNextStates( key: string, - states: Scheduler.NextCardStates + states: Scheduler.NextCardStates, ): Promise { const data: Uint8Array = Scheduler.NextCardStates.encode(states).finish(); await postRequest("/_anki/setNextCardStates", data, { key }); @@ -20,7 +20,7 @@ async function setNextStates( export async function mutateNextCardStates( key: string, - mutator: (states: Scheduler.NextCardStates) => void + mutator: (states: Scheduler.NextCardStates) => void, ): Promise { const states = await getNextStates(); mutator(states); diff --git a/ts/reviewer/images.ts b/ts/reviewer/images.ts index 533735d69..ce08749f0 100644 --- a/ts/reviewer/images.ts +++ b/ts/reviewer/images.ts @@ -11,7 +11,7 @@ function injectPreloadLink(href: string, as: string): void { export function allImagesLoaded(): Promise { return Promise.all( - Array.from(document.getElementsByTagName("img")).map(imageLoaded) + Array.from(document.getElementsByTagName("img")).map(imageLoaded), ); } @@ -35,7 +35,7 @@ function extractImageSrcs(html: string): string[] { tmpl.innerHTML = html; const fragment = tmpl.content; const srcs = [...fragment.querySelectorAll("img[src]")].map( - (img) => (img as HTMLImageElement).src + (img) => (img as HTMLImageElement).src, ); return srcs; } diff --git a/ts/reviewer/index.ts b/ts/reviewer/index.ts index ab92b8121..19d28ccd4 100644 --- a/ts/reviewer/index.ts +++ b/ts/reviewer/index.ts @@ -31,7 +31,7 @@ export function getTypedAnswer(): string | null { } function _runHook( - hooks: Array + hooks: Array, ): Promise>[]> { const promises: (Promise | void)[] = []; @@ -90,7 +90,7 @@ const renderError = } return `
Invalid ${type} on card: ${errorMessage}\n${errorStack}
`.replace( /\n/g, - "
" + "
", ); }; @@ -98,7 +98,7 @@ export async function _updateQA( html: string, _unusused: unknown, onupdate: Callback, - onshown: Callback + onshown: Callback, ): Promise { onUpdateHook.length = 0; onUpdateHook.push(onupdate); @@ -152,8 +152,8 @@ export function _showQuestion(q: string, a: string, bodyclass: string): void { } // preload images allImagesLoaded().then(() => preloadAnswerImages(q, a)); - } - ) + }, + ), ); } @@ -177,8 +177,8 @@ export function _showAnswer(a: string, bodyclass: string): void { }, function () { /* noop */ - } - ) + }, + ), ); } diff --git a/ts/sql_format/sql_format.ts b/ts/sql_format/sql_format.ts index f89253d69..57298f85a 100644 --- a/ts/sql_format/sql_format.ts +++ b/ts/sql_format/sql_format.ts @@ -24,7 +24,7 @@ function formatText(text: string): string { for (const keyword of ["type", "fields"]) { newText = newText.replace( new RegExp(`\\b${keyword.toUpperCase()}\\b`, "g"), - keyword + keyword, ); } return newText; diff --git a/ts/sql_format/tsconfig.json b/ts/sql_format/tsconfig.json index 0f2224052..f059d3e9f 100644 --- a/ts/sql_format/tsconfig.json +++ b/ts/sql_format/tsconfig.json @@ -9,6 +9,6 @@ // ensure node can run the resulting code "noEmitHelpers": false, "importHelpers": false, - "module": "commonjs", + "module": "commonjs" } } diff --git a/ts/svelte/svelte.ts b/ts/svelte/svelte.ts index 0ebd3ef0a..3efeb1b86 100644 --- a/ts/svelte/svelte.ts +++ b/ts/svelte/svelte.ts @@ -76,7 +76,7 @@ const languageServiceHost: ts.LanguageServiceHost = { }, getLength: () => text.length, getChangeRange: ( - _oldSnapshot: ts.IScriptSnapshot + _oldSnapshot: ts.IScriptSnapshot, ): ts.TextChangeRange | undefined => { return undefined; }, @@ -140,7 +140,7 @@ function readFile(file) { async function compileSingleSvelte( input: SvelteInput, binDir: string, - genDir: string + genDir: string, ): Promise { const preprocessOptions = preprocess({ scss: { @@ -215,7 +215,7 @@ async function extractArgsAndData(args: string[]): Promise { } async function extractSvelteAndDeps( - files: string[] + files: string[], ): Promise<[SvelteInput[], InputFile[]]> { const svelte: SvelteInput[] = []; const deps: InputFile[] = []; @@ -249,7 +249,7 @@ function remapBinToSrcDir(file: string): string { async function compileSvelte( svelte: SvelteInput[], binDir: string, - genDir: string + genDir: string, ): Promise { for (const file of svelte) { await compileSingleSvelte(file, binDir, genDir); diff --git a/ts/svelte/tsconfig.json b/ts/svelte/tsconfig.json index 70b41b73c..73b847718 100644 --- a/ts/svelte/tsconfig.json +++ b/ts/svelte/tsconfig.json @@ -8,6 +8,6 @@ // ensure node can run the resulting code "noEmitHelpers": false, "importHelpers": false, - "module": "commonjs", + "module": "commonjs" } } diff --git a/ts/sveltelib/asyncReactive.ts b/ts/sveltelib/asyncReactive.ts index 2479304a7..4cd22d113 100644 --- a/ts/sveltelib/asyncReactive.ts +++ b/ts/sveltelib/asyncReactive.ts @@ -11,13 +11,13 @@ interface AsyncReactiveData { function useAsyncReactive( asyncFunction: () => Promise, - dependencies: [Readable, ...Readable[]] + dependencies: [Readable, ...Readable[]], ): AsyncReactiveData { const promise = derived( dependencies, (_, set: (value: Promise | null) => void): void => set(asyncFunction()), // initialize with null to avoid duplicate fetch on init - null + null, ); const value = derived( @@ -25,7 +25,7 @@ function useAsyncReactive( ($promise, set: (value: T) => void): void => { $promise?.then((value: T) => set(value)); }, - null + null, ); const error = derived( @@ -34,7 +34,7 @@ function useAsyncReactive( $promise?.catch((error: E) => set(error)); return (): void => set(null); }, - null + null, ); const loading = derived( @@ -43,7 +43,7 @@ function useAsyncReactive( $promise?.finally(() => set(false)); return (): void => set(true); }, - true + true, ); return { value, error, loading }; diff --git a/ts/sveltelib/context-property.ts b/ts/sveltelib/context-property.ts index d0e862eff..8f16d529f 100644 --- a/ts/sveltelib/context-property.ts +++ b/ts/sveltelib/context-property.ts @@ -8,7 +8,7 @@ type ContextProperty = [ // this typing is a lie insofar that calling get // outside of the component's context will return undefined () => T, - () => boolean + () => boolean, ]; function contextProperty(key: symbol): ContextProperty { diff --git a/ts/sveltelib/dynamicComponent.ts b/ts/sveltelib/dynamicComponent.ts index 15e7ba7c7..25a267b5c 100644 --- a/ts/sveltelib/dynamicComponent.ts +++ b/ts/sveltelib/dynamicComponent.ts @@ -3,7 +3,7 @@ import type { SvelteComponentDev } from "svelte/internal"; export interface DynamicSvelteComponent< - T extends typeof SvelteComponentDev = typeof SvelteComponentDev + T extends typeof SvelteComponentDev = typeof SvelteComponentDev, > { component: T; [k: string]: unknown; @@ -12,9 +12,9 @@ export interface DynamicSvelteComponent< export const dynamicComponent = < Comp extends typeof SvelteComponentDev, - DefaultProps = NonNullable[0]["props"]> + DefaultProps = NonNullable[0]["props"]>, >( - component: Comp + component: Comp, ) => (props: Props): DynamicSvelteComponent & Props => { return { component, ...props }; diff --git a/ts/sveltelib/mirror-dom.ts b/ts/sveltelib/mirror-dom.ts index 35e98e3aa..6d2131ce1 100644 --- a/ts/sveltelib/mirror-dom.ts +++ b/ts/sveltelib/mirror-dom.ts @@ -15,7 +15,7 @@ const config = { interface DOMMirror { mirror( element: Element, - params: { store: Writable } + params: { store: Writable }, ): { destroy(): void }; preventResubscription(): () => void; } @@ -33,7 +33,7 @@ function getDOMMirror(): DOMMirror { function mirror( element: Element, - { store }: { store: Writable } + { store }: { store: Writable }, ): { destroy(): void } { function saveHTMLToStore(): void { const range = document.createRange(); @@ -80,7 +80,7 @@ function getDOMMirror(): DOMMirror { } else { element.removeEventListener("blur", subscribe); } - } + }, ); return { diff --git a/ts/sveltelib/node-store.ts b/ts/sveltelib/node-store.ts index da0da3b3a..c5b64ede8 100644 --- a/ts/sveltelib/node-store.ts +++ b/ts/sveltelib/node-store.ts @@ -14,7 +14,7 @@ export interface NodeStore extends Writable { export function nodeStore( node?: T, - preprocess: (node: T) => void = noop + preprocess: (node: T) => void = noop, ): NodeStore { const subscribers: Set> = new Set(); diff --git a/ts/sveltelib/preferences.ts b/ts/sveltelib/preferences.ts index b22811253..20c325377 100644 --- a/ts/sveltelib/preferences.ts +++ b/ts/sveltelib/preferences.ts @@ -22,7 +22,7 @@ export type PreferenceRaw = { function createPreference( initialValue: T, - savePreferences: () => void + savePreferences: () => void, ): CustomStore { const { subscribe, set, update } = writable(initialValue); @@ -42,7 +42,7 @@ function createPreference( function preparePreferences( Preferences: T, setter: (payload: PreferencePayload) => Promise, - toObject: (preferences: T, options: { defaults: boolean }) => PreferenceRaw + toObject: (preferences: T, options: { defaults: boolean }) => PreferenceRaw, ): PreferenceStore { const preferences: Partial> = {}; @@ -61,7 +61,7 @@ function preparePreferences( } for (const [key, value] of Object.entries( - toObject(Preferences, { defaults: true }) + toObject(Preferences, { defaults: true }), )) { preferences[key] = createPreference(value, savePreferences); } @@ -72,7 +72,7 @@ function preparePreferences( export async function getPreferences( getter: () => Promise, setter: (payload: PreferencePayload) => Promise, - toObject: (preferences: T, options: { defaults: boolean }) => PreferenceRaw + toObject: (preferences: T, options: { defaults: boolean }) => PreferenceRaw, ): Promise> { const initialPreferences = await getter(); return preparePreferences(initialPreferences, setter, toObject); diff --git a/ts/sveltelib/shortcut.ts b/ts/sveltelib/shortcut.ts index 12afbd03e..897a51e6b 100644 --- a/ts/sveltelib/shortcut.ts +++ b/ts/sveltelib/shortcut.ts @@ -13,7 +13,7 @@ export function shortcut( action: (event: KeyboardEvent) => void; keyCombination: string; target?: EventTarget; - } + }, ): { destroy: () => void } { const deregister = registerShortcut(action, keyCombination, target ?? document); diff --git a/ts/sveltelib/store-subscribe.ts b/ts/sveltelib/store-subscribe.ts index 8e9a0b9ce..dcc8ade99 100644 --- a/ts/sveltelib/store-subscribe.ts +++ b/ts/sveltelib/store-subscribe.ts @@ -12,7 +12,7 @@ interface StoreAccessors { function storeSubscribe( store: Readable, callback: (value: T) => void, - start = true + start = true, ): StoreAccessors { function subscribe(): Unsubscriber { return store.subscribe(callback);