1.2.2 • Published 7 months ago

@kvuse/commitlint-config v1.2.2

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

commitlint-config 提交验证

安装使用

  • 如果根目录没有package.json ,先添加,如果有请跳过该步骤

pnpm init
  • 安装依赖
pnpm add @kvuse/commitlint-config @commitlint/cli -D
  • 使用

⚠️ 仅第一次安装需要,如果已安装请跳过

使用命令添加配置文件

cd node_modules/@gt/commitlint-config

pnpm run preinstall

执行命令成功提示

添加.commitlintrc.json成功
添加.husky成功

添加提交eslint验证

  • package.json添加lint

    如果有请忽略

      "scripts": {
        "lint": "eslint ."
      },
  • .husky 添加 npm run lint命令

    // .husky/commit-msg
    #!/usr/bin/env sh
    . "$(dirname -- "$0")/_/husky.sh"
    
    npx --no -- commitlint --edit "$1"
    npm run lint

测试

git add .
git commit -m 'Feat更'

如果出现以下报错就成功了

⧗   input: Feat更
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

husky - commit-msg hook exited with code 1 (error)

规则

[
  'feat', // 新功能(feature)
  'fix', // 修补bug
  'docs', // 文档
  'style', // 格式
  'refactor', // 重构
  'test', // 增加测试
  'revert', // 回滚
  'config', // 配置
  'chore', // 其他改动
  'debug', // 调试
  'build', // 打包构建
  'release', // 发布
],
  • 提交类型不能为空,必须包含: [feat, fix, docs, style, refactor, test, revert, config, chore, debug]
  • 开头必须有上述字段,例如:feat: 添加xx功能(字段: 冒号后要加空格)
  • 提交内容不能小于三个字符
  • 不能连续的字符或者数字

问题

如果提交出现command not found

.husky/commit-msg: line 4: npx: command not found

需要配置环境变量

这里用nvs举例

export NVS_HOME="$HOME/.nvs"
[ -s "$NVS_HOME/nvs.sh" ] && . "$NVS_HOME/nvs.sh"  # 这里是判断 nvs.sh 文件是否存在并执行

如果不行,请重启vscode或者重启电脑使环境变量生效

1.2.2

7 months ago

1.2.1

8 months ago

1.2.0

8 months ago

1.1.9

8 months ago

1.1.8

8 months ago

1.1.7

8 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.36

9 months ago

1.0.35

9 months ago

1.0.34

9 months ago

1.0.33

9 months ago

1.0.32

9 months ago

1.0.31

9 months ago

1.0.30

9 months ago

1.0.29

9 months ago

1.0.28

9 months ago

1.0.27

9 months ago

1.0.25

9 months ago

1.0.24

9 months ago

1.0.23

9 months ago

1.0.22

9 months ago

1.0.21

9 months ago

1.0.20

9 months ago

1.0.19

9 months ago

1.0.18

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago