Skip to content

Commit 1c251d2

Browse files
committed
fix: remove redundant code
1 parent b750743 commit 1c251d2

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

@commitlint/load/src/utils/load-parser-opts.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function isObjectLike(obj: unknown): obj is Record<string, unknown> {
55
}
66

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

1111
function isParserOptsFunction<T extends ParserPreset>(
@@ -21,14 +21,11 @@ function isParserOptsFunction<T extends ParserPreset>(
2121
export async function loadParserOpts(
2222
pendingParser: string | ParserPreset | Promise<ParserPreset> | undefined
2323
): Promise<ParserPreset | undefined> {
24-
if (!pendingParser || typeof pendingParser === 'string') {
24+
if (!pendingParser || typeof pendingParser !== 'object') {
2525
return undefined;
2626
}
2727
// Await for the module, loaded with require
2828
const parser = await pendingParser;
29-
if (typeof pendingParser !== 'object') {
30-
return undefined;
31-
}
3229

3330
// Await parser opts if applicable
3431
if (isPromiseLike(parser.parserOpts)) {

0 commit comments

Comments
 (0)