• git commit 提交规范 & 规范校验


    Install commitlint

    npm install --save-dev @commitlint/cli @commitlint/config-conventional
    
    echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js
    
    或者配置可以在被定义.commitlintrc.js,.commitlintrc.json或者.commitlintrc.yml文件或commitlint在字段package.json
    
    例如在package.json中加入
    "commitlint": {
      "extends": [ "@commitlint/config-conventional" ],
      "rules": {
        "type-enum": [ 2, "always", [ "feat", "fix", "docs", "style", "refactor", "perf", "test", "build", "ci", "chore", "revert" ] ],
        "type-case": [ 2, "always", [ "lower-case" ] ],
        "type-empty": [ 2, "never" ], "scope-empty": [ 2, "never" ],
        "scope-case": [ 2, "always", [ "lower-case", "upper-case", "camel-case", "kebab-case", "pascal-case", "sentence-case", "snake-case", "start-case" ] ],
        "subject-case": [ 2, "always", [ "lower-case", "upper-case", "camel-case", "kebab-case", "pascal-case", "sentence-case", "snake-case", "start-case" ] ],
        "subject-empty": [ 2, "never" ],
        "subject-full-stop": [ 2, "never" ],
        "header-max-length": [ 2, "always", 72 ]
      }
    }

    Install husky


    npm install --save-dev husky

    This allows us to add git hooks directly into our package.json via the husky.hooks field.

    // package.json

    "husky": {

            "hooks": {

                "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"

            } 

      }

    commit规范


    Commit message格式

    type(scope?): subject 

    注意冒号后面有空格。

    type

    用于说明 commit 的类别,只允许使用下面7个标识。

    feat:新功能(feature)

    fix:修补bug

    docs:文档(documentation)

    style: 格式(不影响代码运行的变动)

    refactor:重构(即不是新增功能,也不是修改bug的代码变动)

    test:增加测试

    chore:构建过程或辅助工具的变动

    scope[optional]

    表示改动的模块或者文件或者功能

    subject

    提交简短的问题描述

    规则


    规则由名称和配置数组组成。配置数组包含:

    级别 [0,1,2]:0禁用规则 1报warning 2.报error。

    适用 always|never:never颠倒规则。

    值:用于此规则的值。

    参考链接: commitlint官网

  • 相关阅读:
    asm createdisk时提示没有权限
    webkit 模拟点击 winform
    .net中的反射(转载)
    wpf——三维学习1
    3dmax导出到blend或者vs中
    地理坐标系与投影坐标系
    Arcgis与CityEngine安装破解
    忘记Windows7登陆密码解决办法
    wpf的UserControl用户控件怎么添加到Window窗体中
    postgres索引创建、 存储过程的创建以及在c#中的调用
  • 原文地址:https://www.cnblogs.com/wusheng2016/p/10623006.html
Copyright © 2020-2023  润新知