From 2716865a0441b8502c8d0ee3efbdbe1bcebe0101 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Wed, 6 Mar 2024 17:35:53 +0100 Subject: infra(unicorn): switch-case-braces (#2721) --- src/modules/helpers/eval.ts | 10 +++++++--- src/modules/helpers/index.ts | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/modules/helpers') diff --git a/src/modules/helpers/eval.ts b/src/modules/helpers/eval.ts index 033c5d35..4a861ec0 100644 --- a/src/modules/helpers/eval.ts +++ b/src/modules/helpers/eval.ts @@ -119,12 +119,15 @@ function evalProcessFunction( switch (nextChar) { case '.': case '(': - case undefined: + case undefined: { break; // valid - default: + } + + default: { throw new FakerError( `Expected dot ('.'), open parenthesis ('('), or nothing after function call but got '${nextChar}'` ); + } } return [ @@ -223,7 +226,8 @@ function resolveProperty(entrypoint: unknown, key: string): unknown { return entrypoint?.[key as keyof typeof entrypoint]; } - default: + default: { return undefined; + } } } diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts index b21f13e7..b86b2cd7 100644 --- a/src/modules/helpers/index.ts +++ b/src/modules/helpers/index.ts @@ -56,8 +56,9 @@ function getRepetitionsBasedOnQuantifierParameters( break; } - default: + default: { throw new FakerError('Unknown quantifier symbol provided.'); + } } } else if (quantifierMin != null && quantifierMax != null) { repetitions = faker.number.int({ -- cgit v1.2.3