-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.ts
More file actions
61 lines (55 loc) · 1.74 KB
/
Copy pathcommitlint.config.ts
File metadata and controls
61 lines (55 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import config from "@commitlint/config-conventional"
import type { ParserPreset, UserConfig } from "@commitlint/types"
import createPreset from "conventional-changelog-conventionalcommits"
async function createEmojiParser(): Promise<ParserPreset> {
const emojiRegexPart = Object.values(config.prompt.questions.type.enum)
.map((value) => value.emoji.trim() + String.raw`\uFE0F?`)
.join("|")
const parserOpts = {
breakingHeaderPattern: new RegExp(String.raw`^(?:${emojiRegexPart})\s+(\w*)(?:\((.*)\))?!:\s+(.*)$`),
headerPattern: new RegExp(String.raw`^(?:${emojiRegexPart})\s+(\w*)(?:\((.*)\))?!?:\s+(.*)$`),
}
const defaultPreset = await createPreset()
return {
...defaultPreset,
conventionalChangelog: {
...defaultPreset.conventionalChangelog,
parserOpts,
},
parserOpts,
recommendedBumpOpts: {
...defaultPreset.recommendedBumpOpts,
parserOpts,
},
}
}
const emojiParser = await createEmojiParser()
export default {
extends: ["@commitlint/config-conventional"],
parserPreset: emojiParser,
rules: {
"header-max-length": [2, "always", 256],
"subject-case": [2, "always", "lower-case"],
},
prompt: {
settings: { enableMultipleScopes: true },
questions: {
type: {
enum: {
build: { emoji: "🛠️ " },
ci: { emoji: "⚙️ " },
chore: { emoji: "♻️ " },
docs: { emoji: "📚 " },
feat: { emoji: "✨ " },
fix: { emoji: "🐛 " },
perf: { emoji: "🚀 " },
refactor: { emoji: "📦 " },
revert: { emoji: "🗑️ " },
style: { emoji: "💎 " },
test: { emoji: "🚨 " },
},
emojiInHeader: true,
},
},
},
} satisfies UserConfig