Skip to content

Commit 2af7562

Browse files
committed
feat(interfaces): ParserOptions
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 66b0f6c commit 2af7562

File tree

6 files changed

+130
-1
lines changed

6 files changed

+130
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"@commitlint/config-conventional": "17.4.4",
7676
"@commitlint/types": "17.4.4",
7777
"@flex-development/tutils": "6.0.0-alpha.10",
78+
"@types/conventional-commits-parser": "3.0.3",
7879
"conventional-changelog-conventionalcommits": "5.0.0"
7980
},
8081
"devDependencies": {
@@ -88,7 +89,6 @@
8889
"@types/conventional-changelog": "3.1.1",
8990
"@types/conventional-changelog-core": "4.2.1",
9091
"@types/conventional-changelog-writer": "4.0.2",
91-
"@types/conventional-commits-parser": "3.0.3",
9292
"@types/conventional-recommended-bump": "6.1.0",
9393
"@types/dateformat": "5.0.0",
9494
"@types/eslint": "8.21.1",

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
*/
55

66
export * from './enums'
7+
export * from './interfaces'
78
export * from './types'
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* @file Type Tests - ParserOptions
3+
* @module commitlint-config/interfaces/tests/unit-d/ParserOptions
4+
*/
5+
6+
import type { ReferenceAction } from '#src/enums'
7+
import type { NoteKeyword } from '#src/types'
8+
import type * as parser from 'conventional-commits-parser'
9+
import type TestSubject from '../options-parser'
10+
11+
describe('unit-d:interfaces/ParserOptions', () => {
12+
it('should extend Required<parser.Options>', () => {
13+
expectTypeOf<TestSubject>().toMatchTypeOf<Required<parser.Options>>()
14+
})
15+
16+
it('should match [commentChar: string]', () => {
17+
expectTypeOf<TestSubject>().toHaveProperty('commentChar').toBeString()
18+
})
19+
20+
it('should match [fieldPattern: RegExp]', () => {
21+
expectTypeOf<TestSubject>()
22+
.toHaveProperty('fieldPattern')
23+
.toEqualTypeOf<RegExp>()
24+
})
25+
26+
it('should match [headerCorrespondence: string[]]', () => {
27+
expectTypeOf<TestSubject>()
28+
.toHaveProperty('headerCorrespondence')
29+
.toEqualTypeOf<string[]>()
30+
})
31+
32+
it('should match [headerPattern: RegExp]', () => {
33+
expectTypeOf<TestSubject>()
34+
.toHaveProperty('headerPattern')
35+
.toEqualTypeOf<RegExp>()
36+
})
37+
38+
it('should match [issuePrefixes: string[]]', () => {
39+
expectTypeOf<TestSubject>()
40+
.toHaveProperty('issuePrefixes')
41+
.toEqualTypeOf<string[]>()
42+
})
43+
44+
it('should match [issuePrefixesCaseSensitive: boolean]', () => {
45+
expectTypeOf<TestSubject>()
46+
.toHaveProperty('issuePrefixesCaseSensitive')
47+
.toBeBoolean()
48+
})
49+
50+
it('should match [mergeCorrespondence: null]', () => {
51+
expectTypeOf<TestSubject>().toHaveProperty('mergeCorrespondence').toBeNull()
52+
})
53+
54+
it('should match [mergePattern: null]', () => {
55+
expectTypeOf<TestSubject>().toHaveProperty('mergePattern').toBeNull()
56+
})
57+
58+
it('should match [noteKeywords: NoteKeyword[]]', () => {
59+
expectTypeOf<TestSubject>()
60+
.toHaveProperty('noteKeywords')
61+
.toEqualTypeOf<NoteKeyword[]>()
62+
})
63+
64+
it('should match [referenceActions: ReferenceAction[]]', () => {
65+
expectTypeOf<TestSubject>()
66+
.toHaveProperty('referenceActions')
67+
.toEqualTypeOf<ReferenceAction[]>()
68+
})
69+
70+
it('should match [revertCorrespondence: string[]]', () => {
71+
expectTypeOf<TestSubject>()
72+
.toHaveProperty('revertCorrespondence')
73+
.toEqualTypeOf<string[]>()
74+
})
75+
76+
it('should match [revertPattern: RegExp]', () => {
77+
expectTypeOf<TestSubject>()
78+
.toHaveProperty('revertPattern')
79+
.toEqualTypeOf<RegExp>()
80+
})
81+
82+
it('should match [warn: Console["warn"]]', () => {
83+
expectTypeOf<TestSubject>()
84+
.toHaveProperty('warn')
85+
.toEqualTypeOf<Console['warn']>()
86+
})
87+
})

src/interfaces/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @file Entry Point - Interfaces
3+
* @module commitlint-config/interfaces
4+
*/
5+
6+
export type { default as ParserOptions } from './options-parser'

src/interfaces/options-parser.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @file Interfaces - ParserOptions
3+
* @module commitlint-config/interfaces/ParserOptions
4+
*/
5+
6+
import type { ReferenceAction } from '#src/enums'
7+
import type { NoteKeyword } from '#src/types'
8+
import type * as parser from 'conventional-commits-parser'
9+
10+
/**
11+
* Commit parser options.
12+
*
13+
* @see https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-commits-parser/README.md#options
14+
*
15+
* @extends {Required<parser.Options>}
16+
*/
17+
interface ParserOptions extends Required<parser.Options> {
18+
commentChar: string
19+
fieldPattern: RegExp
20+
headerCorrespondence: string[]
21+
headerPattern: RegExp
22+
issuePrefixes: string[]
23+
issuePrefixesCaseSensitive: boolean
24+
mergeCorrespondence: null
25+
mergePattern: null
26+
noteKeywords: NoteKeyword[]
27+
referenceActions: ReferenceAction[]
28+
revertCorrespondence: string[]
29+
revertPattern: RegExp
30+
warn: Console['warn']
31+
}
32+
33+
export type { ParserOptions as default }

vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const config: UserConfigExport = defineConfig((): UserConfig => {
5656
'**/__mocks__/**',
5757
'**/__tests__/**',
5858
'**/index.ts',
59+
'src/interfaces/',
5960
'src/types/'
6061
],
6162
extension: ['.ts'],
@@ -121,6 +122,7 @@ const config: UserConfigExport = defineConfig((): UserConfig => {
121122
snapshotFormat: {
122123
callToJSON: true,
123124
min: false,
125+
printBasicPrototype: false,
124126
printFunctionName: true
125127
},
126128
testTimeout: 10 * 1000,

0 commit comments

Comments
 (0)