Skip to content

Commit 8f08e67

Browse files
committed
refactor(parse): add strict options interface
1 parent 8cd3051 commit 8f08e67

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

@commitlint/parse/src/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ test('parses references leading subject', async () => {
180180
);
181181
const {
182182
references: [actual]
183-
} = await parse(message, undefined, opts);
183+
} = await parse(message, undefined, opts as any);
184184

185185
expect(actual.issue).toBe('1');
186186
});

@commitlint/parse/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {isArray, mergeWith} from 'lodash';
2-
import {Commit} from './types';
2+
import {Commit, ParserOptions} from './types';
33

44
const {sync} = require('conventional-commits-parser');
55
const defaultChangelogOpts = require('conventional-changelog-angular');
@@ -8,9 +8,9 @@ export default parse;
88
export * from './types';
99

1010
async function parse(
11-
message?: any,
11+
message?: string,
1212
parser: any = sync,
13-
parserOpts: any = undefined
13+
parserOpts?: ParserOptions
1414
): Promise<Commit> {
1515
const defaultOpts = (await defaultChangelogOpts).parserOpts;
1616
const parsed = parser(

@commitlint/parse/src/types.ts

+12
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@ export interface CommitReference {
2626
repository: string | null;
2727
issue: string | null;
2828
}
29+
30+
export interface ParserOptions {
31+
commentChar?: string;
32+
headerCorrespondence?: string[];
33+
headerPattern?: RegExp;
34+
issuePrefixes?: string[];
35+
mergeCorrespondence?: string[];
36+
mergePattern?: RegExp;
37+
noteKeywords?: string[];
38+
revertCorrespondence?: string[];
39+
revertPattern?: RegExp;
40+
}

0 commit comments

Comments
 (0)