Skip to content

Commit 66b0f6c

Browse files
committed
feat(types): Questions
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent a4ac43a commit 66b0f6c

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"dependencies": {
7575
"@commitlint/config-conventional": "17.4.4",
7676
"@commitlint/types": "17.4.4",
77+
"@flex-development/tutils": "6.0.0-alpha.10",
7778
"conventional-changelog-conventionalcommits": "5.0.0"
7879
},
7980
"devDependencies": {
@@ -82,7 +83,6 @@
8283
"@flex-development/mkbuild": "1.0.0-alpha.14",
8384
"@flex-development/mlly": "1.0.0-alpha.13",
8485
"@flex-development/pathe": "1.0.3",
85-
"@flex-development/tutils": "6.0.0-alpha.10",
8686
"@graphql-eslint/eslint-plugin": "3.16.0",
8787
"@types/chai": "4.3.4",
8888
"@types/conventional-changelog": "3.1.1",
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @file Type Tests - Questions
3+
* @module commitlint-config/types/tests/unit-d/Questions
4+
*/
5+
6+
import { PromptKind, Scope, Type } from '#src/enums'
7+
import type Question from '../question'
8+
import type QuestionEnum from '../question-enum'
9+
import type TestSubject from '../questions'
10+
11+
describe('unit-d:types/Questions', () => {
12+
it('should extend Record<PromptKind, Question>', () => {
13+
expectTypeOf<TestSubject>().toMatchTypeOf<Record<PromptKind, Question>>()
14+
})
15+
16+
it('should match [PromptKind.SCOPE: Question<Scope>]', () => {
17+
expectTypeOf<TestSubject>()
18+
.toHaveProperty(PromptKind.SCOPE)
19+
.toEqualTypeOf<Question<Scope>>()
20+
})
21+
22+
it('should match [PromptKind.TYPE: Question<Type, Required<QuestionEnum>>]', () => {
23+
expectTypeOf<TestSubject>()
24+
.toHaveProperty(PromptKind.TYPE)
25+
.toEqualTypeOf<Question<Type, Required<QuestionEnum>>>()
26+
})
27+
})

src/types/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
export type { default as NoteKeyword } from './note-keyword'
77
export type { default as Question } from './question'
88
export type { default as QuestionEnum } from './question-enum'
9+
export type { default as Questions } from './questions'

src/types/questions.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @file Type Definitions - Questions
3+
* @module commitlint-config/types/Questions
4+
*/
5+
6+
import type { PromptKind, Scope, Type } from '#src/enums'
7+
import type { Overwrite } from '@flex-development/tutils'
8+
import type Question from './question'
9+
import type QuestionEnum from './question-enum'
10+
11+
/**
12+
* Prompt questions.
13+
*
14+
* @see https://commitlint.js.org/#/reference-prompt?id=questions
15+
*
16+
* @extends {Record<PromptKind,Question>}
17+
*/
18+
type Questions = Overwrite<
19+
Record<PromptKind, Question>,
20+
{
21+
/**
22+
* Commit scope questions configuration.
23+
*/
24+
[PromptKind.SCOPE]: Question<Scope>
25+
26+
/**
27+
* Commit type questions configuration.
28+
*/
29+
[PromptKind.TYPE]: Question<Type, Required<QuestionEnum>>
30+
}
31+
>
32+
33+
export type { Questions as default }

0 commit comments

Comments
 (0)