diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..fc80939 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,24 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'subject-case': [0], + 'scope-case': [0], + 'type-enum': [ + 2, + 'always', + [ + 'feat', // 增加新功能 + 'fix', // 修复bug + 'build', // 构造工具的或者外部依赖的改动,例如webpack,npm + 'chore', // 不修改src或者test的其余修改,例如构建过程或辅助工具的变动 + 'ci', // 与CI(持续集成服务)有关的改动 + 'docs', // 只改动了文档相关的内容 + 'style', // 不影响代码含义的改动,例如去掉空格、改变缩进、增删分号 + 'perf', // 提高性能的改动 + 'refactor', // 代码重构时使用 + 'revert', // 执行git revert打印的message + 'test', // 添加测试或者修改现有测试 + ], + ], + }, +}; diff --git a/package.json b/package.json index 10a212f..4246f65 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ }, "husky": { "hooks": { - "pre-commit": "lint-staged" + "pre-commit": "lint-staged", + "commit-msg": "commitlint -e $GIT_PARAMS" } }, "lint-staged": { @@ -87,6 +88,8 @@ "github 自动commit" ], "devDependencies": { + "@commitlint/cli": "^11.0.0", + "@commitlint/config-conventional": "^11.0.0", "@types/glob": "^7.1.1", "@types/mocha": "^5.2.7", "@types/node": "^12.11.7", @@ -102,7 +105,7 @@ "ts-loader": "^6.2.1", "typescript": "^3.9.7", "vscode": "^1.1.36", - "webpack": "^4.41.4", + "webpack": "^4.44.2", "webpack-cli": "^3.3.10" }, "dependencies": {