Skip to content

Commit

Permalink
refactor(parse): add strict options interface
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Jul 29, 2019
1 parent 8cd3051 commit 8f08e67
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion @commitlint/parse/src/index.test.ts
Expand Up @@ -180,7 +180,7 @@ test('parses references leading subject', async () => {
);
const {
references: [actual]
} = await parse(message, undefined, opts);
} = await parse(message, undefined, opts as any);

expect(actual.issue).toBe('1');
});
Expand Down
6 changes: 3 additions & 3 deletions @commitlint/parse/src/index.ts
@@ -1,5 +1,5 @@
import {isArray, mergeWith} from 'lodash';
import {Commit} from './types';
import {Commit, ParserOptions} from './types';

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

async function parse(
message?: any,
message?: string,
parser: any = sync,
parserOpts: any = undefined
parserOpts?: ParserOptions
): Promise<Commit> {
const defaultOpts = (await defaultChangelogOpts).parserOpts;
const parsed = parser(
Expand Down
12 changes: 12 additions & 0 deletions @commitlint/parse/src/types.ts
Expand Up @@ -26,3 +26,15 @@ export interface CommitReference {
repository: string | null;
issue: string | null;
}

export interface ParserOptions {
commentChar?: string;
headerCorrespondence?: string[];
headerPattern?: RegExp;
issuePrefixes?: string[];
mergeCorrespondence?: string[];
mergePattern?: RegExp;
noteKeywords?: string[];
revertCorrespondence?: string[];
revertPattern?: RegExp;
}

0 comments on commit 8f08e67

Please sign in to comment.