husky pre-commit lint-staged @commitlint/cli @commitlint/config-conventional 配置commit提交语法

yarn add husky pre-commit lint-staged @commitlint/cli @commitlint/config-conventional -D

// 配置package.json

 "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
    }
  },
  "lint-staged": {
// 这里注意后缀名vue的 。ts和js 和react 类型
    "*.{js,vue}": [
      "eslint --fix",
      "git add"
    ]
  }

跟目录新增
commitlint.config.js


husky pre-commit lint-staged @commitlint/cli @commitlint/config-conventional 配置commit提交语法_第1张图片
image.png
module.exports = {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'type-enum': [
      2,
      'always',
      ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore', 'revert']
    ],
    'subject-full-stop': [0, 'never'],
    'subject-case': [0, 'never']
  }
}

开始这样不对
husky pre-commit lint-staged @commitlint/cli @commitlint/config-conventional 配置commit提交语法_第2张图片
image.png

必须这样提交才行


husky pre-commit lint-staged @commitlint/cli @commitlint/config-conventional 配置commit提交语法_第3张图片
image.png

你可能感兴趣的:(husky pre-commit lint-staged @commitlint/cli @commitlint/config-conventional 配置commit提交语法)