commitlint-config-tyler 1.0.1-alpha.0

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.
Files changed (3) hide show
  1. package/README.md +41 -0
  2. package/index.js +29 -0
  3. package/package.json +25 -0
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # `commitlint-config-tyler`
2
+
3
+ > Git 规范
4
+
5
+ 支持配套的 [commitlint 配置](https://commitlint.js.org/#/concepts-shareable-config),用于对 `git commit message` 进行校验。
6
+
7
+ ## 安装
8
+
9
+ 使用时,需要安装 [@commitlint/cli](https://www.npmjs.com/package/@commitlint/cli):
10
+
11
+ ```bash
12
+ npm install commitlint-config-tyler @commitlint/cli --save-dev
13
+ ```
14
+
15
+ ## 使用
16
+
17
+ 在 `commitlint.config.js` 中集成本包:
18
+
19
+ ```javascript
20
+ module.exports = {
21
+ extends: ['encode'],
22
+ };
23
+ ```
24
+
25
+ ## 设置 git hook
26
+
27
+ 可通过 [husky](https://www.npmjs.com/package/husky) 设置在 `git commit` 时触发 `commitlint`。
28
+
29
+ 首先安装 husky:
30
+
31
+ ```bash
32
+ npm install husky --save-dev
33
+ ```
34
+
35
+ 然后执行添加`commit-msg`:
36
+
37
+ ```bash
38
+ npx husky add .husky/commit-msg 'npx commitlint --edit $1'
39
+ ```
40
+
41
+ 更多信息可参考 [commitlint 文档](https://commitlint.js.org/#/guides-local-setup?id=install-husky)。
package/index.js ADDED
@@ -0,0 +1,29 @@
1
+ module.exports = {
2
+ parserPreset: 'conventional-changelog-conventionalcommits',
3
+ rules: {
4
+ // 规定提交信息的身体部分必须以空行为开头。这里的1表示这是一个警告级别的规则(而不是错误级别),这意味着即使违反了这个规则,提交信息也不会被阻止,但是会发出警告提醒
5
+ 'body-leading-blank': [1, 'always'],
6
+ // 这是限制提交信息主体部分的每行文本长度不能超过100个字符的规则。2表示这是一个错误级别的规则,如果违反了这个规则,提交信息会被阻止。
7
+ 'body-max-line-length': [2, 'always', 100],
8
+ // 规定提交信息的底部部分必须以空行为开头,和主体部分的规则类似,这是一个警告级别的规则。
9
+ 'footer-leading-blank': [1, 'always'],
10
+ // 限制提交信息的底部部分每行文本的长度不能超过100个字符。2表示这是一个错误级别的规则,如果违反了这个规则,提交信息会被阻止。
11
+ 'footer-max-line-length': [2, 'always', 100],
12
+ // 限制提交信息的标题(即第一行)的长度不能超过100个字符。2表示这是一个错误级别的规则,如果违反了这个规则,提交信息会被阻止。
13
+ 'header-max-length': [2, 'always', 100],
14
+ // 规定提交信息的作用域部分必须全部使用小写字母,这是一个错误级别的规则。
15
+ 'scope-case': [2, 'always', 'lower-case'],
16
+ // 这个规则被禁用,意味着提交信息的主题部分的大小写没有特定的格式要求。
17
+ 'subject-case': [0],
18
+ // 规定提交信息的主题部分不能为空,这是一个错误级别的规则。
19
+ 'subject-empty': [2, 'never'],
20
+ // 规定提交信息的主题部分不能以句号(.)结尾,这是一个错误级别的规则。
21
+ 'subject-full-stop': [2, 'never', '.'],
22
+ // 规定提交信息的类型部分必须全部使用小写字母,这是一个错误级别的规则。
23
+ 'type-case': [2, 'always', 'lower-case'],
24
+ // 规定提交信息的类型部分不能为空,这是一个错误级别的规则。
25
+ 'type-empty': [2, 'never'],
26
+ // 规定提交信息的类型部分必须是特定的值之一,比如feat(新功能)、fix(修复bug)等等,这是一个错误级别的规则。
27
+ 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'test', 'refactor', 'chore', 'revert']],
28
+ },
29
+ };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "commitlint-config-tyler",
3
+ "version": "1.0.1-alpha.0",
4
+ "main": "index.js",
5
+ "description": "Git规范",
6
+ "keywords": [
7
+ "tyler",
8
+ "commit",
9
+ "lint"
10
+ ],
11
+ "author": "tyler",
12
+ "homepage": "https://github.com/gaotianbin/tyler-fe-spec#readme",
13
+ "license": "ISC",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/gaotianbin/tyler-fe-spec.git"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/gaotianbin/tyler-fe-spec/issues"
20
+ },
21
+ "dependencies": {
22
+ "conventional-changelog-conventionalcommits": "^9.1.0"
23
+ },
24
+ "gitHead": "36fbdd062ef22de7415f0075597c2a91075d3d74"
25
+ }