Skip to content

Commit 7f98ca3

Browse files
committed
chore: add git hooks
1 parent 7335d34 commit 7f98ca3

File tree

8 files changed

+661
-57
lines changed

8 files changed

+661
-57
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
es2021: true,
77
node: true,
88
},
9-
extends: ['prettier'],
9+
extends: ['eslint:recommended', 'prettier'],
1010
parserOptions: {
1111
ecmaVersion: 13,
1212
},

config.json

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
{
22
"lang": "en",
3-
"authors": [
4-
"chengpeiquan"
5-
],
6-
"dateRange": [
7-
"2021-12-01",
8-
"2022-01-31"
9-
],
10-
"repos": [
11-
"D:\\Git\\git-commit-analytics"
12-
],
3+
"authors": ["chengpeiquan"],
4+
"dateRange": ["2021-12-01", "2022-01-31"],
5+
"repos": ["D:\\Git\\git-commit-analytics"],
136
"format": {
147
"git-commit-analytics": "Git Commit Analytics"
158
},
16-
"includes": [
17-
"feat",
18-
"fix",
19-
"docs",
20-
"style",
21-
"refactor",
22-
"test",
23-
"chore"
24-
],
25-
"excludes": [
26-
"typo",
27-
"backup",
28-
"progress"
29-
]
9+
"includes": ["feat", "fix", "docs", "style", "refactor", "test", "chore"],
10+
"excludes": ["typo", "backup", "progress"]
3011
}

jsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,20 @@
1919
"eslint": "^8.5.0",
2020
"eslint-config-prettier": "^8.3.0",
2121
"eslint-plugin-prettier": "^4.0.0",
22-
"prettier": "^2.5.1"
22+
"lint-staged": "11.1.2",
23+
"prettier": "^2.5.1",
24+
"yorkie": "^2.0.0"
2325
},
2426
"dependencies": {
2527
"dayjs": "^1.10.7"
28+
},
29+
"gitHooks": {
30+
"pre-commit": "lint-staged",
31+
"commit-msg": "node scripts/verifyCommit.js"
32+
},
33+
"lint-staged": {
34+
"*.js": [
35+
"prettier --write ."
36+
]
2637
}
2738
}

scripts/verifyCommit.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Invoked on the commit-msg git hook by yorkie.
2+
3+
const fs = require('fs')
4+
const msgPath = process.env.GIT_PARAMS
5+
const msg = fs.readFileSync(msgPath, 'utf-8').trim()
6+
7+
const commitRE =
8+
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
9+
10+
if (!commitRE.test(msg)) {
11+
console.log()
12+
console.error(
13+
` ERROR invalid commit message format.\n\n
14+
Proper commit message format is required for automated changelog generation. Examples:\n\n
15+
feat(compiler): add 'comments' option\n
16+
fix(v-model): handle events on blur (close #28)\n\n
17+
See .github/commit-convention.md for more details.\n`
18+
)
19+
process.exit(1)
20+
}

src/config.json

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{
2-
"authors": [
3-
"程沛权",
4-
"chengpeiquan"
5-
],
6-
"dateRange": [
7-
"2021-01-01",
8-
"2021-12-31"
9-
],
2+
"authors": ["程沛权", "chengpeiquan"],
3+
"dateRange": ["2021-01-01", "2021-12-31"],
104
"repos": [
115
"D:\\Project\\npm-project\\vue-picture-cropper",
126
"D:\\Project\\npm-project\\vite-plugin-banner"
@@ -15,18 +9,6 @@
159
"vue-picture-cropper": "Vue Picture Cropper",
1610
"vite-plugin-banner": "Vite Plugin Banner"
1711
},
18-
"includes": [
19-
"feat",
20-
"fix",
21-
"docs",
22-
"style",
23-
"refactor",
24-
"test",
25-
"chore"
26-
],
27-
"excludes": [
28-
"typo",
29-
"backup",
30-
"progress"
31-
]
12+
"includes": ["feat", "fix", "docs", "style", "refactor", "test", "chore"],
13+
"excludes": ["typo", "backup", "progress"]
3214
}

src/libs/saveReport.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = function ({ result, isEN }) {
3636
// Categories that has been written
3737
const categories = []
3838

39-
list = repoResult[t]
39+
const list = repoResult[t]
4040
list.forEach((item, index) => {
4141
const { repo, category, msg } = item
4242

0 commit comments

Comments
 (0)