From 15022f51b9e627fe370da8b1974a8ba5c843ef8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Fri, 15 Apr 2022 00:44:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0husky=20+=20commitlin?= =?UTF-8?q?t=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 766fdd4bb607d559ce16bf1f18aae6ad3b6b37cb --- .husky/commit-msg | 4 ++++ .husky/pre-commit | 4 ++++ commitlint.config.js | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 .husky/commit-msg create mode 100644 .husky/pre-commit create mode 100644 commitlint.config.js diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 0000000..e8511ea --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no-install commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..dba9310 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npm run lint \ No newline at end of file diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..de3022d --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,26 @@ +module.exports = { + // 继承的规则 + extends: ['@commitlint/config-conventional'], + // 定义规则类型 + rules: { + // type 类型定义,表示 git 提交的 type 必须在以下类型范围内 + 'type-enum': [ + 2, + 'always', + [ + 'feat', // 新功能 feature + 'fix', // 修复 bug + 'docs', // 文档注释 + 'style', // 代码格式(不影响代码运行的变动) + 'refactor', // 重构(既不增加新功能,也不是修复bug) + 'perf', // 性能优化 + 'test', // 增加测试 + 'chore', // 构建过程或辅助工具的变动 + 'revert', // 回退 + 'build' // 打包 + ] + ], + // subject 大小写不做校验 + 'subject-case': [0] + } + } \ No newline at end of file