mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[build] add lint for commit-msg (#4164)
This commit is contained in:
parent
89a980466f
commit
8dcf1c1139
34
build/lint-commit-msg.js
Normal file
34
build/lint-commit-msg.js
Normal file
@ -0,0 +1,34 @@
|
||||
const fs = require('fs');
|
||||
const signale = require('signale');
|
||||
|
||||
const gitParams = process.env.HUSKY_GIT_PARAMS;
|
||||
const commitMsg = fs.readFileSync(gitParams, 'utf-8').trim();
|
||||
|
||||
const commitRE = /^(revert: )?\[(fix|feat|docs|perf|test|types|build|chore|refactor|breaking change)\].{1,50}/;
|
||||
|
||||
if (!commitRE.test(commitMsg)) {
|
||||
signale.error(`Error: invalid commit message format.
|
||||
|
||||
Proper commit message format is required for automated changelog generation.
|
||||
|
||||
Examples:
|
||||
|
||||
[fix] Button: incorrect style
|
||||
[feat] Button: add color prop
|
||||
[dosc] Button: fix typo
|
||||
|
||||
Allowed Types:
|
||||
|
||||
- fix
|
||||
- feat
|
||||
- docs
|
||||
- perf
|
||||
- test
|
||||
- types
|
||||
- build
|
||||
- chore
|
||||
- refactor
|
||||
- breaking change
|
||||
`);
|
||||
process.exit(1);
|
||||
}
|
@ -28,7 +28,8 @@
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
"pre-commit": "lint-staged",
|
||||
"commit-msg": "node build/lint-commit-msg.js"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user