File tree Expand file tree Collapse file tree 3 files changed +7
-23
lines changed Expand file tree Collapse file tree 3 files changed +7
-23
lines changed Original file line number Diff line number Diff line change 1
1
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' ;
8
3
9
4
export async function loadParser (
10
5
pendingParser : unknown
@@ -15,7 +10,9 @@ export async function loadParser(
15
10
// Await for the module, loaded with require
16
11
const parser = await pendingParser ;
17
12
18
- validateParser ( parser ) ;
13
+ if ( ! isObjectLike ( parser ) ) {
14
+ throw new Error ( 'Invalid configuration, `parserPreset` must be an object' ) ;
15
+ }
19
16
20
17
// Await parser opts if applicable
21
18
if ( isPromiseLike ( parser . parserOpts ) ) {
@@ -26,6 +23,7 @@ export async function loadParser(
26
23
// Create parser opts from factory
27
24
if (
28
25
isParserOptsFunction ( parser ) &&
26
+ typeof parser . name === 'string' &&
29
27
parser . name . startsWith ( 'conventional-changelog-' )
30
28
) {
31
29
return new Promise ( ( resolve ) => {
Original file line number Diff line number Diff line change @@ -56,17 +56,3 @@ export function validateConfig(
56
56
throw new Error ( 'Invalid configuration, `helpUrl` must be a string' ) ;
57
57
}
58
58
}
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
- }
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ export interface QualifiedConfig {
48
48
}
49
49
50
50
export interface ParserPreset {
51
- name : string ;
52
- path : string ;
51
+ name ? : string ;
52
+ path ? : string ;
53
53
parserOpts ?: unknown ;
54
54
}
You can’t perform that action at this time.
0 commit comments