1.0.4 • Published 10 months ago

commitlint-config-ykplus v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

commitlint-config-ykplus

本包提供了《移卡前端规范 - Git 规范》配套的 commitlint 可共享配置,用于对 git commit message 进行校验。

安装

除了本包,你需要同时安装 @commitlint/cli

npm install commitlint-config-ykplus @commitlint/cli --save-dev

使用

在你的 commitlint.config.js 中继承本包:

module.exports = {
  extends: ['ykplus'],
}

配合 commitizen 和 husky 使用(推荐)

安装

npm install commitizen husky --save-dev

配置 commitizen

# npm 5.2+
npx commitizen init cz-conventional-changelog --save-dev --save-exact

这时候,你的 package.json 会出现下面配置:

...
  "config": {
    "commitizen": {
      "path": "cz-conventional-changelog"
    }
  }

设置 husky hooks

  1. 添加 prepare-commit-msg hook
npx husky add .husky/prepare-commit-msg "exec < /dev/tty && npx cz --hook || true"
  1. 添加 commit-msg hook
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'

更多信息可参考: