summaryrefslogtreecommitdiff
path: root/source/helpers
diff options
context:
space:
mode:
authorGravatar yakov116 <16872793+yakov116@users.noreply.github.com> 2020-11-18 19:55:59 -0500
committerGravatar GitHub <noreply@github.com> 2020-11-18 18:55:59 -0600
commita935456acab0c7bdc021829e18ce20230e18c752 (patch)
treee61eed13a433381ba223a4ca962e904c8740fc91 /source/helpers
parentcab33f6f47c4eef0a3bc793f2004767f34b6abe9 (diff)
downloadrefined-github-a7e8057d2e873d04e02d03e393b5ff604298d6b2.tar.gz
refined-github-a7e8057d2e873d04e02d03e393b5ff604298d6b2.tar.zst
refined-github-a7e8057d2e873d04e02d03e393b5ff604298d6b2.zip
Lint (#3723)20.11.19
Diffstat (limited to 'source/helpers')
-rw-r--r--source/helpers/on-element-removal.ts24
-rw-r--r--source/helpers/simplified-element-observer.ts11
-rw-r--r--source/helpers/smart-block-wrap.ts5
3 files changed, 24 insertions, 16 deletions
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<void> => {
- 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<void> => (
+ 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<MutationRecord> {
+export async function observeOneMutation(
+ element: Element,
+ options: MutationObserverInit = {
+ childList: true,
+ subtree: true
+ }
+): Promise<MutationRecord> {
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)!;