From a935456acab0c7bdc021829e18ce20230e18c752 Mon Sep 17 00:00:00 2001 From: yakov116 <16872793+yakov116@users.noreply.github.com> Date: Wed, 18 Nov 2020 19:55:59 -0500 Subject: Lint (#3723) --- source/helpers/on-element-removal.ts | 24 +++++++++++++----------- source/helpers/simplified-element-observer.ts | 11 +++++++---- source/helpers/smart-block-wrap.ts | 5 ++++- 3 files changed, 24 insertions(+), 16 deletions(-) (limited to 'source/helpers') diff --git a/source/helpers/on-element-removal.ts b/source/helpers/on-element-removal.ts index 2c94a168..27e8b3b4 100644 --- a/source/helpers/on-element-removal.ts +++ b/source/helpers/on-element-removal.ts @@ -1,15 +1,17 @@ import mem from 'mem'; -const onElementRemoval = mem(async (element: Element): Promise => { - return new Promise(resolve => { - // @ts-expect-error until https://github.com/microsoft/TypeScript/issues/37861 - new ResizeObserver(([{target}], observer) => { - if (!target.isConnected) { - observer.disconnect(); - resolve(); - } - }).observe(element); - }); -}); +const onElementRemoval = mem( + async (element: Element): Promise => ( + new Promise(resolve => { + // @ts-expect-error until https://github.com/microsoft/TypeScript/issues/37861 + new ResizeObserver(([{target}], observer) => { + if (!target.isConnected) { + observer.disconnect(); + resolve(); + } + }).observe(element); + }) + ) +); export default onElementRemoval; diff --git a/source/helpers/simplified-element-observer.ts b/source/helpers/simplified-element-observer.ts index 07b2f2e6..821633e3 100644 --- a/source/helpers/simplified-element-observer.ts +++ b/source/helpers/simplified-element-observer.ts @@ -19,10 +19,13 @@ export default function observeElement( return observer; } -export async function observeOneMutation(element: Element, options: MutationObserverInit = { - childList: true, - subtree: true -}): Promise { +export async function observeOneMutation( + element: Element, + options: MutationObserverInit = { + childList: true, + subtree: true + } +): Promise { return new Promise(resolve => { new MutationObserver(([change], observer) => { observer.disconnect(); diff --git a/source/helpers/smart-block-wrap.ts b/source/helpers/smart-block-wrap.ts index 10a368cd..8d51fb48 100644 --- a/source/helpers/smart-block-wrap.ts +++ b/source/helpers/smart-block-wrap.ts @@ -1,7 +1,10 @@ // Wraps string in at least two newlines on each side, // as long as the field doesn't already have them. // Code adapted from GitHub. -export default function smartBlockWrap(content: string, field: HTMLTextAreaElement): string { +export default function smartBlockWrap( + content: string, + field: HTMLTextAreaElement +): string { const before = field.value.slice(0, field.selectionStart); const after = field.value.slice(field.selectionEnd); const [whitespaceAtStart] = /\n*$/.exec(before)!; -- cgit v1.2.3