Skip to content

Commit a7f92d8

Browse files
committed
fix: disable some unwanted validations
1 parent 6f00690 commit a7f92d8

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import {ParserPreset} from '@commitlint/types';
2-
import {
3-
isObjectLike,
4-
isParserOptsFunction,
5-
isPromiseLike,
6-
validateParser,
7-
} from './validators';
2+
import {isObjectLike, isParserOptsFunction, isPromiseLike} from './validators';
83

94
export async function loadParser(
105
pendingParser: unknown
@@ -15,7 +10,9 @@ export async function loadParser(
1510
// Await for the module, loaded with require
1611
const parser = await pendingParser;
1712

18-
validateParser(parser);
13+
if (!isObjectLike(parser)) {
14+
throw new Error('Invalid configuration, `parserPreset` must be an object');
15+
}
1916

2017
// Await parser opts if applicable
2118
if (isPromiseLike(parser.parserOpts)) {
@@ -26,6 +23,7 @@ export async function loadParser(
2623
// Create parser opts from factory
2724
if (
2825
isParserOptsFunction(parser) &&
26+
typeof parser.name === 'string' &&
2927
parser.name.startsWith('conventional-changelog-')
3028
) {
3129
return new Promise((resolve) => {

@commitlint/load/src/utils/validators.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,3 @@ export function validateConfig(
5656
throw new Error('Invalid configuration, `helpUrl` must be a string');
5757
}
5858
}
59-
60-
export function validateParser(
61-
parser: unknown
62-
): asserts parser is {name: string; path: string; [key: string]: unknown} {
63-
if (!isObjectLike(parser)) {
64-
throw new Error('Invalid configuration, parserPreset must be an object');
65-
}
66-
if (typeof parser.name !== 'string') {
67-
throw new Error('Invalid configuration, parserPreset must have a name');
68-
}
69-
if (typeof parser.path !== 'string') {
70-
throw new Error('Invalid configuration, parserPreset must have a name');
71-
}
72-
}

@commitlint/types/src/load.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface QualifiedConfig {
4848
}
4949

5050
export interface ParserPreset {
51-
name: string;
52-
path: string;
51+
name?: string;
52+
path?: string;
5353
parserOpts?: unknown;
5454
}

0 commit comments

Comments
 (0)