Skip to content

Commit 293f323

Browse files
committed
chore(commit): 添加husky和commitlint规范git提交说明
1 parent 6be2cf6 commit 293f323

File tree

8 files changed

+20108
-279
lines changed

8 files changed

+20108
-279
lines changed

.cz-config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
// 可选类型
3+
types: [
4+
{ value: 'feat', name: 'feat: 新功能' },
5+
{ value: 'fix', name: 'fix: 修复' },
6+
{ value: 'docs', name: 'docs: 文档变更' },
7+
{ value: 'style', name: 'style: 代码格式' },
8+
{ value: 'refactor', name: 'refactor: 代码重构' },
9+
{ value: 'perf', name: 'perf: 性能优化' },
10+
{ value: 'test', name: 'test: 增加测试' },
11+
{ value: 'chore', name: 'chore: 构建过程或辅助工具的变动' },
12+
{ value: 'revert', name: 'revert: 回退' },
13+
{ value: 'build', name: 'build: 打包' }
14+
],
15+
// 步骤
16+
messages: {
17+
type: '请选择提交类型:',
18+
customScope: '请输入修改范围(可选)',
19+
subject: '请简要描述提交(必填)',
20+
body: '请详细描述(可选)',
21+
footer: '请输入要关闭的issue(可选)',
22+
confirmCommit: '确认要使用以上信息提交吗?(y/n)'
23+
},
24+
// 跳过步骤
25+
skipQuestions: ['body', 'footer'],
26+
// 默认长度 72
27+
subjectLimit: 72
28+
}

.eslintrc.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ module.exports = {
33
env: {
44
node: true
55
},
6-
extends: [
7-
'plugin:vue/vue3-essential',
8-
'@vue/standard'
9-
],
6+
extends: ['plugin:vue/vue3-essential', '@vue/standard'],
107
parserOptions: {
118
parser: 'babel-eslint'
129
},

.husky/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+
npx --no-install commitlint --edit "$1"

.husky/pre-commit

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+
npx lint-staged

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "none"
5+
}

commitlint.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
// 继承的规则
3+
extends: ['@commitlint/config-conventional'],
4+
// 定义规则类型
5+
rules: {
6+
// type 类型定义,表示 git 提交的 type 必须在一下类型范围内
7+
'type-enum': [
8+
2,
9+
'always',
10+
[
11+
'feat', // 新功能 feature
12+
'fix', // 修复 bug
13+
'docs', // 文档注释
14+
'style', // 代码格式
15+
'refactor', // 重构
16+
'perf', // 性能优化
17+
'test', // 增加测试
18+
'chore', // 构建过程或辅助工具的变动
19+
'revert', // 回退
20+
'build' // 打包
21+
]
22+
],
23+
// subject 大小写不做校验
24+
'subject-case': [0]
25+
}
26+
}

0 commit comments

Comments
 (0)