Skip to content

Commit

Permalink
fix: remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Jan 30, 2021
1 parent b750743 commit 1c251d2
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions @commitlint/load/src/utils/load-parser-opts.ts
Expand Up @@ -5,7 +5,7 @@ function isObjectLike(obj: unknown): obj is Record<string, unknown> {
}

function isPromiseLike(obj: unknown): obj is Promise<unknown> {
return typeof obj === 'object' && typeof (obj as any).then === 'function';
return isObjectLike(obj) && typeof (obj as any).then === 'function';
}

function isParserOptsFunction<T extends ParserPreset>(
Expand All @@ -21,14 +21,11 @@ function isParserOptsFunction<T extends ParserPreset>(
export async function loadParserOpts(
pendingParser: string | ParserPreset | Promise<ParserPreset> | undefined
): Promise<ParserPreset | undefined> {
if (!pendingParser || typeof pendingParser === 'string') {
if (!pendingParser || typeof pendingParser !== 'object') {
return undefined;
}
// Await for the module, loaded with require
const parser = await pendingParser;
if (typeof pendingParser !== 'object') {
return undefined;
}

// Await parser opts if applicable
if (isPromiseLike(parser.parserOpts)) {
Expand Down

0 comments on commit 1c251d2

Please sign in to comment.