• 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官网

  • 相关阅读:
    MobaXtern显示中文
    SD卡识别——记一次stm32识别BanqSD卡 V2.0识别失败的经历。
    《Java 底层原理》Jvm GC算法
    《Java 并发编程》ThreadLock详解
    《Java 底层原理》Jvm对象结构和指针压缩
    《Java 底层原理》Java内存模型
    《Java 底层原理》Java 字节码详解
    jinjia2中的变量使用
    jsonify和json的区别
    虚拟环境是什么?有什么用?怎么用?
  • 原文地址:https://www.cnblogs.com/wusheng2016/p/10623006.html
Copyright © 2020-2023  润新知