@huangjunsen/commitlint-config 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -2
- package/package.json +12 -4
package/README.md
CHANGED
|
@@ -1,3 +1,131 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @huangjunsen/commitlint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Git commit message 规范,基于 [Conventional Commits](https://www.conventionalcommits.org/),并内置 **cz-git** 交互式提交配置(带 emoji 的类型选择)。
|
|
4
|
+
|
|
5
|
+
> `@commitlint/cli` 为可选 peer 依赖(`>=16.0.0`)。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @huangjunsen/commitlint-config @commitlint/cli cz-git --save-dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 使用
|
|
18
|
+
|
|
19
|
+
在项目根目录创建 `commitlint.config.js`:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
module.exports = {
|
|
23
|
+
extends: ['@huangjunsen/commitlint-config'],
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 配合 husky 卡点
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"husky": {
|
|
32
|
+
"hooks": {
|
|
33
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 交互式提交(cz-git)
|
|
40
|
+
|
|
41
|
+
`package.json` 中加入:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"scripts": {
|
|
46
|
+
"commit": "cz"
|
|
47
|
+
},
|
|
48
|
+
"config": {
|
|
49
|
+
"commitizen": {
|
|
50
|
+
"path": "node_modules/cz-git"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
之后执行 `npm run commit`,即可按提示选择类型、范围并填写描述。
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 规范内容
|
|
61
|
+
|
|
62
|
+
### 提交类型
|
|
63
|
+
|
|
64
|
+
| 类型 | 含义 |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `feat` | ✨ 新增功能 |
|
|
67
|
+
| `fix` | 🐛 修复缺陷 |
|
|
68
|
+
| `docs` | 📝 文档更新 |
|
|
69
|
+
| `style` | 💄 代码格式(不影响逻辑) |
|
|
70
|
+
| `refactor` | ♻️ 代码重构 |
|
|
71
|
+
| `perf` | ⚡️ 性能提升 |
|
|
72
|
+
| `test` | ✅ 测试相关 |
|
|
73
|
+
| `build` | 📦️ 构建流程 / 外部依赖 |
|
|
74
|
+
| `ci` | 🎡 持续集成配置 |
|
|
75
|
+
| `revert` | ⏪️ 回退提交 |
|
|
76
|
+
| `chore` | 🔨 其他修改 |
|
|
77
|
+
|
|
78
|
+
### 校验规则
|
|
79
|
+
|
|
80
|
+
| 规则 | 级别 | 说明 |
|
|
81
|
+
| --- | --- | --- |
|
|
82
|
+
| `type-enum` | error | 类型必须是上表枚举值之一 |
|
|
83
|
+
| `type-case` / `scope-case` | error | 类型与范围必须小写 |
|
|
84
|
+
| `type-empty` / `subject-empty` | error | 类型与描述不能为空 |
|
|
85
|
+
| `subject-full-stop` | error | 描述末尾不能有句号 |
|
|
86
|
+
| `header-max-length` | error | 首行不超过 **100** 字符 |
|
|
87
|
+
| **`body-max-line-length`** | error | 正文每行不超过 **100** 字符 |
|
|
88
|
+
| **`footer-max-line-length`** | error | footer 每行不超过 **100** 字符 |
|
|
89
|
+
| `body-leading-blank` | warn | 正文前需有空行 |
|
|
90
|
+
| `footer-leading-blank` | warn | footer 前需有空行 |
|
|
91
|
+
| `subject-case` | off | 描述不做大小写校验 |
|
|
92
|
+
|
|
93
|
+
> ⚠️ **正文与 footer 的行长限制按字符数计算,中文同样计入。** 写多行说明时请主动折行,
|
|
94
|
+
> 否则 commit 会被直接拒绝(`body's lines must not be longer than 100 characters`)。
|
|
95
|
+
|
|
96
|
+
### 提交示例
|
|
97
|
+
|
|
98
|
+
```text
|
|
99
|
+
feat(eslint): 支持 ESLint 9/10 的 Flat Config
|
|
100
|
+
|
|
101
|
+
- 新增 flat/vue 与 flat/typescript 入口
|
|
102
|
+
- 清理已废弃的格式化规则
|
|
103
|
+
|
|
104
|
+
closed #123
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 配置文件格式
|
|
110
|
+
|
|
111
|
+
| 格式 | 文件名 |
|
|
112
|
+
| --- | --- |
|
|
113
|
+
| 官方推荐 | `commitlint.config.{js,cjs,mjs,ts,cts,mts}` |
|
|
114
|
+
| 旧(仍支持) | `.commitlintrc`、`.commitlintrc.{json,yaml,yml,js,cjs,mjs,ts,cts,mts}` |
|
|
115
|
+
| 旧(仍支持) | `package.json` 中的 `commitlint` 字段 |
|
|
116
|
+
|
|
117
|
+
新旧格式均由 cosmiconfig 解析,官方均支持。
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 相关包
|
|
122
|
+
|
|
123
|
+
- [`@huangjunsen/encode-fe-lint`](https://www.npmjs.com/package/@huangjunsen/encode-fe-lint) —— 一键接入与扫描的 CLI
|
|
124
|
+
- [`@huangjunsen/eslint-config`](https://www.npmjs.com/package/@huangjunsen/eslint-config)
|
|
125
|
+
- [`@huangjunsen/stylelint-config`](https://www.npmjs.com/package/@huangjunsen/stylelint-config)
|
|
126
|
+
- [`@huangjunsen/markdownlint-config`](https://www.npmjs.com/package/@huangjunsen/markdownlint-config)
|
|
127
|
+
- [`@huangjunsen/prettier-config`](https://www.npmjs.com/package/@huangjunsen/prettier-config)
|
|
128
|
+
|
|
129
|
+
## 文档
|
|
130
|
+
|
|
131
|
+
完整说明见 [项目文档](https://huangjunsen0406.github.io/js-encode-fe-spec/packages/commitlint-config.html)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huangjunsen/commitlint-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Git规范",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -9,17 +9,25 @@
|
|
|
9
9
|
"lint"
|
|
10
10
|
],
|
|
11
11
|
"author": "Huangjunsen <951434130@qq.com>",
|
|
12
|
-
"homepage": "https://github.
|
|
12
|
+
"homepage": "https://huangjunsen0406.github.io/js-encode-fe-spec/packages/commitlint-config.html",
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"conventional-changelog-conventionalcommits": "^7.0.2",
|
|
16
16
|
"cz-git": "^1.9.1"
|
|
17
17
|
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@commitlint/cli": ">=16.0.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependenciesMeta": {
|
|
22
|
+
"@commitlint/cli": {
|
|
23
|
+
"optional": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
18
26
|
"repository": {
|
|
19
27
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/
|
|
28
|
+
"url": "git+https://github.com/huangjunsen0406/js-encode-fe-spec.git"
|
|
21
29
|
},
|
|
22
30
|
"bugs": {
|
|
23
|
-
"url": "https://github.com/
|
|
31
|
+
"url": "https://github.com/huangjunsen0406/js-encode-fe-spec/issues"
|
|
24
32
|
}
|
|
25
33
|
}
|