Skip to content

Commit

Permalink
chore: 添加commit
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonYong committed Sep 1, 2022
1 parent 7598c14 commit 87bf01f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
9 changes: 9 additions & 0 deletions .husky/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
command_exists () {
command -v "$1" >/dev/null 2>&1
}

# Workaround for Windows 10, Git Bash and Yarn
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"

[ -n "$CI" ] && exit 0

npx lint-staged
47 changes: 47 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// feat:新增功能
// fix:bug 修复
// docs:文档更新
// style:不影响程序逻辑的代码修改(修改空白字符,格式缩进,补全缺失的分号等,没有改变代码逻辑)
// refactor:重构代码(既没有新增功能,也没有修复 bug)
// perf:性能, 体验优化
// test:新增测试用例或是更新现有测试
// build:主要目的是修改项目构建系统(例如 glup,webpack,rollup 的配置等)的提交
// ci:主要目的是修改项目继续集成流程(例如 Travis,Jenkins,GitLab CI,Circle等)的提交
// chore:不属于以上类型的其他类,比如构建流程, 依赖管理
// revert:回滚某个更早之前的提交
// version: 改变package.json 版本

module.exports = {
ignores: [(commit) => commit.includes('init')],
extends: ['@commitlint/config-conventional'],
rules: {
'body-leading-blank': [2, 'always'],
'footer-leading-blank': [1, 'always'],
'header-max-length': [2, 'always', 108],
'subject-empty': [2, 'never'],
'type-empty': [2, 'never'],
'subject-case': [0],
'type-enum': [
2,
'always',
[
'feat',
'fix',
'perf',
'style',
'docs',
'test',
'refactor',
'build',
'ci',
'chore',
'revert',
'wip',
'workflow',
'types',
'release',
'version',
],
],
},
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
},
"devDependencies": {
"@antfu/eslint-config": "^0.25.2",
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@types/md5": "^2.3.2",
"@types/node": "^18.0.6",
"@types/prettier": "^2.6.3",
Expand Down

0 comments on commit 87bf01f

Please sign in to comment.