forked from sprint-22-part2/Rolling-Front
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.cjs
More file actions
73 lines (59 loc) · 1.58 KB
/
commitlint.config.cjs
File metadata and controls
73 lines (59 loc) · 1.58 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
62
63
64
65
66
67
68
69
70
71
72
73
const EMOJI_BY_TYPE = {
chore: '📦',
feat: '✨',
style: '🎨',
fix: '🐛',
del: '🔥',
docs: '📝',
rename: '⏪️',
refactor: '♻️',
};
const TYPES = Object.keys(EMOJI_BY_TYPE);
const AVAILABLE_TYPES = Object.entries(EMOJI_BY_TYPE)
.map(([type, emoji]) => `${emoji}[${type}]`)
.join(', ');
module.exports = {
extends: ['@commitlint/config-conventional'],
parserPreset: {
parserOpts: {
headerPattern: /^(.+)\[(.+)\]: (.+)$/,
headerCorrespondence: ['emoji', 'type', 'subject'],
},
},
plugins: [
{
rules: {
'emoji-type-match': (parsed) => {
const { header, emoji, type } = parsed;
if (/^Merge (branch|pull request)/.test(header)) {
return [true];
}
if (!TYPES.includes(type)) {
return [
false,
`type은 다음 중 하나여야 합니다: ${AVAILABLE_TYPES}`,
];
}
const expectedEmoji = EMOJI_BY_TYPE[type];
if (emoji !== expectedEmoji) {
return [
false,
`"${type}" 타입은 "${expectedEmoji}" 이모지를 사용해야 합니다.`,
];
}
return [true];
},
},
},
],
rules: {
'header-max-length': [2, 'always', 50],
'subject-full-stop': [2, 'never', '.'],
'subject-empty': [2, 'never'],
'type-empty': [2, 'never'],
'type-enum': [2, 'always', TYPES],
'body-leading-blank': [2, 'always'],
'body-max-line-length': [2, 'always', 72],
'emoji-type-match': [2, 'always'],
},
};