commitlint-wizardoc

May 31, 2021 · View on GitHub

English | 中文文档

commitlint-wizardoc 是包含某些规则和插件commitlint 的配置包,他可以检查你提交的commit-message是否符合 Wizardoc 约定。

用法

如果你之前没有使用过 commitlint,你可以前往commitlint document来查看更多详情。

安装

你可以使用npmyarn来安装commitlint-wizardoc

# NPM
npm i commitlint-config-wizardoc -D

# YARN
yarn add commitlint-config-wizardoc -D

配置

在你项目的根目录下创建一个commitlint的配置文件,你能通过extends wizardocconfig文件来完成配置。

例如,将以下代码加入到.commitlintrc.js文件。

module.exports = {
  // This line config will read the NPM package named "commitlint-config-wizardoc", so please make sure you have installed it before config this line.
  extends: "wizardoc",
};

只需要做这些,你就可以使用commitlint-wizardowcommit-message的校验了。

规则

git 的commit-message由以下四部分组成:

![Feat::scope] some sentence
^  ^      ^          ^
|  |      |          |
|  |      |          |
|  |      |          |- Subject(required)
|  |      |
|  |      |- Scope(optional)
|  |
|  |- Type(required)
|
|- Break change symbol(optional)
  • Break change symbol:在提交破坏性更改的时候,需要使用时候用Break change symbol

  • Typecommit-messageType必须是以下类型之一。

    规范名描述
    Feat新增新功能
    Init新建项目时,对项目的初始化
    Remove代码的改动(删除),粒度较小
    Delete文件的改动(删除),粒度较大
    Update代码块的修改
    Refactor代码重构
    Move移动文件位置
    Perf优化相关,比如提升性能、体验
    Doc文档相关的修改
    Add规模较小的新增
    Patch增加逻辑块为了修复某一个逻辑错误
    Fix修复 bug
    Test覆盖测试用例
    Stub桩代码用于临时测试
    Chore小修改,修复,一些琐碎的小事情
  • Scope: 修改的模块。

  • Subject: 提交的具体描述信息。

覆盖配置

你可以覆盖 Wizardoc 的配置,来创建自己的配置

module.exports = {
  extends: 'wizardoc',
  rules: [
    // Set the $ as the third parameter if you wanna change break symbol to $
    "break-change-prefix": [2, "always", '$'],
  ]
}

LICENSE

MIT.