Skip to content

Commit 8c0ffd2

Browse files
authored
🐙(git hook): add commitlint with gitmoji
New commitlint configuration to add convention and gitmoji to prepare for auto-generation of changelog
2 parents be7122e + 71be075 commit 8c0ffd2

File tree

4 files changed

+1902
-4
lines changed

4 files changed

+1902
-4
lines changed

.husky/prepare-commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn commit

commitlint.config.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
module.exports = {
2+
parserPreset: 'conventional-changelog-conventionalcommits',
3+
rules: {
4+
'body-leading-blank': [1, 'always'],
5+
'body-max-line-length': [2, 'always', 100],
6+
'footer-leading-blank': [1, 'always'],
7+
'footer-max-line-length': [2, 'always', 100],
8+
'header-max-length': [2, 'always', 100],
9+
'subject-case': [
10+
2,
11+
'never',
12+
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
13+
],
14+
'subject-empty': [2, 'never'],
15+
'subject-full-stop': [2, 'never', '.'],
16+
'type-case': [2, 'always', 'lower-case'],
17+
'type-empty': [2, 'never'],
18+
'type-enum': [
19+
2,
20+
'always',
21+
[
22+
'✨',
23+
'🐛',
24+
'📚',
25+
'💎',
26+
'♻️',
27+
'🐙',
28+
],
29+
],
30+
},
31+
prompt: {
32+
questions: {
33+
type: {
34+
description: "Select the TYPE of change that you're committing",
35+
enum: {
36+
'✨': {
37+
description: 'A new feature',
38+
title: 'Features',
39+
emoji: '✨',
40+
},
41+
'🐛': {
42+
description: 'A bug fix',
43+
title: 'Bug Fixes',
44+
emoji: '🐛',
45+
},
46+
'📚': {
47+
description: 'Documentation only changes',
48+
title: 'Documentation',
49+
emoji: '📚',
50+
},
51+
'💎': {
52+
description:
53+
'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)',
54+
title: 'Code Styles',
55+
emoji: '💎',
56+
},
57+
'♻️': {
58+
description:
59+
'A code change that neither fixes a bug nor adds a feature',
60+
title: 'Code Refactoring',
61+
emoji: '♻️',
62+
},
63+
'🐙': {
64+
description: 'Changes to the git configuration files and scripts (example scope: GitHub Actions)',
65+
title: 'Github configuration',
66+
emoji: '🐙',
67+
},
68+
},
69+
},
70+
scope: {
71+
description:
72+
'What is the SCOPE of this change (e.g. component or file name)',
73+
},
74+
subject: {
75+
description:
76+
'Write a short, imperative tense DESCRIPTION of the change',
77+
},
78+
body: {
79+
description: 'Provide a longer description of the change',
80+
},
81+
isBreaking: {
82+
description: 'Are there any breaking changes?',
83+
},
84+
breakingBody: {
85+
description:
86+
'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself',
87+
},
88+
breaking: {
89+
description: 'Describe the breaking changes',
90+
},
91+
isIssueAffected: {
92+
description: 'Does this change affect any open issues?',
93+
},
94+
issuesBody: {
95+
description:
96+
'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself',
97+
},
98+
issues: {
99+
description: 'Add issue references (e.g. "fix #123", "re #123".)',
100+
},
101+
},
102+
},
103+
};

package.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"homepage": "https://thecodingmachine.github.io/react-native-boilerplate/",
1515
"main": "post-init.script.js",
1616
"scripts": {
17-
"test": "echo \"Error: no test specified\" && exit 1"
17+
"test": "echo \"Error: no test specified\" && exit 1",
18+
"commit": "cz",
19+
"prepare": "husky install"
1820
},
1921
"keywords": [
2022
"react",
@@ -28,5 +30,19 @@
2830
"@thecodingmachine/rnb-plugin-typescript": "^1.1.0",
2931
"kleur": "^4.1.4",
3032
"prompts": "^2.4.1"
33+
},
34+
"devDependencies": {
35+
"@commitlint/cli": "^16.0.2",
36+
"@commitlint/config-conventional": "^16.0.0",
37+
"@commitlint/cz-commitlint": "^16.0.0",
38+
"@commitlint/prompt-cli": "^16.0.0",
39+
"commitizen": "^4.2.4",
40+
"cz-conventional-changelog": "^3.3.0",
41+
"husky": "^7.0.4"
42+
},
43+
"config": {
44+
"commitizen": {
45+
"path": "@commitlint/cz-commitlint"
46+
}
3147
}
3248
}

0 commit comments

Comments
 (0)