Skip to content

hanworks97/commitlint-config

Repository files navigation

@hanworks/commitlint-config

个人的 commitlint 配置预设。

安装

在你的项目中安装 @hanworks/commitlint-config 包:

pnpm add -D husky lint-staged czg cz-git @hanworks/commitlint-config

在你的项目根目录下创建 commitlint.config.js:

// commitlint.config.js
export default {
  extends: ['@hanworks/commitlint-config'],
}

配置

  1. 初始化 husky
pnpm husky install
  1. 然后在 package.json 添加 prepare,保证以后 install 会自动注册:
{
  "scripts": {
    "prepare": "husky"
  }
}

然后执行一次 pnpm install 来触发 prepare。

  1. 添加 pre-commit hook .husky/pre-commit
pnpm exec lint-staged
  1. 添加 commit-msg hook .husky/commit-msg
pnpm exec commitlint --config commitlint.config.js --edit "${1}"
  1. 配置 lint-staged 在 package.json 中添加:
{
  "lint-staged": {
    "*.{js,ts,vue}": "eslint --fix"
  }
}
  1. 将以下命令添加到你的脚本 package.json 部分:
{
  "scripts": {
    "cz": "czg"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-git"
    }
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors