Skip to content

Commit 4664fd1

Browse files
committed
feat(interfaces): Config
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 53b8d11 commit 4664fd1

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @file Type Tests - Config
3+
* @module commitlint-config/interfaces/tests/unit-d/Config
4+
*/
5+
6+
import type { ParserPreset } from '#src/types'
7+
import type * as commitlint from '@commitlint/types'
8+
import type TestSubject from '../config'
9+
import type PromptConfig from '../config-prompt'
10+
import type RulesConfig from '../config-rules'
11+
12+
describe('unit-d:interfaces/Config', () => {
13+
it('should extend Required<Omit<commitlint.UserConfig, "extends">>', () => {
14+
expectTypeOf<TestSubject>().toMatchTypeOf<
15+
Required<Omit<commitlint.UserConfig, 'extends'>>
16+
>()
17+
})
18+
19+
it('should match [formatter: "@commitlint/format"]', () => {
20+
expectTypeOf<TestSubject>()
21+
.toHaveProperty('formatter')
22+
.toEqualTypeOf<'@commitlint/format'>()
23+
})
24+
25+
it('should match [parserPreset: ParserPreset]', () => {
26+
expectTypeOf<TestSubject>()
27+
.toHaveProperty('parserPreset')
28+
.toEqualTypeOf<ParserPreset>()
29+
})
30+
31+
it('should match [prompt: PromptConfig]', () => {
32+
expectTypeOf<TestSubject>()
33+
.toHaveProperty('prompt')
34+
.toEqualTypeOf<PromptConfig>()
35+
})
36+
37+
it('should match [rules: RulesConfig]', () => {
38+
expectTypeOf<TestSubject>()
39+
.toHaveProperty('rules')
40+
.toEqualTypeOf<RulesConfig>()
41+
})
42+
})

src/interfaces/config.ts

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* @file Interfaces - Config
3+
* @module commitlint-config/interfaces/Config
4+
*/
5+
6+
import type { ParserPreset } from '#src/types'
7+
import type * as commitlint from '@commitlint/types'
8+
import type PromptConfig from './config-prompt'
9+
import type RulesConfig from './config-rules'
10+
11+
/**
12+
* Object representing `commitlint` configuration for [Flex Development][1].
13+
*
14+
* [1]: https://flexdevelopment.llc
15+
*
16+
* @see https://commitlint.js.org/#/reference-configuration
17+
*
18+
* @extends {Required<Omit<commitlint.UserConfig,'extends'>>}
19+
*/
20+
interface Config extends Required<Omit<commitlint.UserConfig, 'extends'>> {
21+
/**
22+
* Use default ignore rules.
23+
*
24+
* @default true
25+
*/
26+
defaultIgnores: boolean
27+
28+
/**
29+
* Report formatter.
30+
*/
31+
formatter: '@commitlint/format'
32+
33+
/**
34+
* URL to show upon failure.
35+
*
36+
* @default 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
37+
*/
38+
helpUrl: string
39+
40+
/**
41+
* Functions that return `true` if `commitlint` should ignore the given
42+
* message.
43+
*
44+
* @default []
45+
*/
46+
ignores: ((commit: string) => boolean)[]
47+
48+
/**
49+
* Commit parser preset.
50+
*
51+
* @see {@linkcode ParserPreset}
52+
*
53+
* @default parserPreset
54+
*/
55+
parserPreset: ParserPreset
56+
57+
/**
58+
* Plugins to apply.
59+
*
60+
* @see {@linkcode commitlint.Plugin}
61+
* @see https://commitlint.js.org/#/reference-plugins
62+
*
63+
* @default []
64+
*/
65+
plugins: (commitlint.Plugin | string)[]
66+
67+
/**
68+
* Prompt configuration used by [`@commitlint/cz-commitlint`][1].
69+
*
70+
* [1]: https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/cz-commitlint
71+
*
72+
* @see {@linkcode PromptConfig}
73+
* @see https://commitlint.js.org/#/reference-prompt
74+
*
75+
* @default prompt
76+
*/
77+
prompt: PromptConfig
78+
79+
/**
80+
* Commit rules.
81+
*
82+
* Enforces [conventional commits][1], with the exception of additional casing
83+
* rules for consistency.
84+
*
85+
* [1]: https://www.conventionalcommits.org
86+
*
87+
* @see {@linkcode RulesConfig}
88+
* @see https://commitlint.js.org/#/reference-rules
89+
*
90+
* @default rules
91+
*/
92+
rules: RulesConfig
93+
}
94+
95+
export type { Config as default }

src/interfaces/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @module commitlint-config/interfaces
44
*/
55

6+
export type { default as Config } from './config'
67
export type { default as PromptConfig } from './config-prompt'
78
export type { default as RulesConfig } from './config-rules'
89
export type { default as ParserOptions } from './options-parser'

0 commit comments

Comments
 (0)