From f987cb6c8473e544e410b6998aab7e040d942363 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 25 Apr 2024 09:42:57 +1200 Subject: [PATCH] refactor: remove unneeded checks --- src/rules/utils/padding.ts | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/rules/utils/padding.ts b/src/rules/utils/padding.ts index 8d8295277..edd071b05 100644 --- a/src/rules/utils/padding.ts +++ b/src/rules/utils/padding.ts @@ -197,26 +197,23 @@ const paddingTesters: { [T in PaddingType]: PaddingTester } = { }; const createScopeInfo = (): ScopeInfo => { - return (() => { - let scope: Scope | null = null; + let scope: Scope | null = null; - return { - get prevNode() { - return scope?.prevNode ?? null; - }, - set prevNode(node) { - if (scope) { - scope.prevNode = node; - } - }, - enter() { - scope = { upper: scope, prevNode: null }; - }, - exit() { - scope = scope?.upper ?? null; - }, - }; - })(); + // todo: explore seeing if we can refactor to a more TypeScript friendly structure + return { + get prevNode() { + return scope!.prevNode; + }, + set prevNode(node) { + scope!.prevNode = node; + }, + enter() { + scope = { upper: scope, prevNode: null }; + }, + exit() { + scope = scope!.upper; + }, + }; }; /**