Lint 规则
airbnb
standard
window 快捷键, Alt-Shift-Ctrl-P
IDE 插件使用官方教程: https://prettier.io/docs/en/webstorm.html
https://segmentfault.com/a/1190000015315545?utm_source=tag-newest
git 提交记录标准化
CommitLint: Lint commit messages
https://github.com/conventional-changelog/commitlint
安装:
npm install --save-dev @commitlint/config-conventional @commitlint/cli
添加配置文件 commitlint.config.js:
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"type-enum": [
2,
"always",
[
"upd",
"feat",
"fix",
"refactor",
"docs",
"chore",
"style",
"revert",
"perf",
"test"
]
],
"type-case": [0],
"type-empty": [0],
"scope-empty": [0],
"scope-case": [0],
"subject-full-stop": [0, "never"],
"subject-case": [0, "never"],
"header-max-length": [0, "always", 72]
}
};
提交记录前缀如下:
- feat :新功能
- fix :修复 bug
- chore :对构建或者辅助工具的更改
- refactor :既不是修复 bug 也不是添加新功能的代码更改
- style :不影响代码含义的更改 (例如空格、格式化、少了分号)
- docs :只是文档的更改
- perf :提高性能的代码更改
- revert :撤回提交
- test :添加或修正测试- upd:更新某功能(不是 feat, 不是 fix)
Husky
支持所有的Git Hooks, Server-side hooks (pre-receive, update and post-receive) aren't supported.
自动安装pre-commit 依赖;
不支持CI 集成配置;
1.0.0 开始支持单独配置文件: .huskyrc, .huskyrc.json, .huskyrc.js or husky.config.js
例如配置文件为 .huskyrc:
{
"hooks": {
"pre-commit": "npm lint",
"pre-push": "npm test:unit",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}package.json 中使用参数需要添加$ ??? 例如: $HUSKY_GIT_PARAMS 待验证!
本地操作时可在git 命令后添加参数 --no-verify 屏蔽检测;
GitLab CI
配置文件: https://docs.gitlab.com/ce/ci/quick_start/README.html
CommitLint 结合CI 配置: https://commitlint.js.org/#/guides-ci-setup
Yorkie:
https://www.npmjs.com/package/yorkie
--------------------------------------------------------
Reference
https://ijust.cc/tech/git-commitlint.html
xianglijiaxing
没有帐号? 立即注册