Skip to content

Commit ec07019

Browse files
author
Halsey
committed
chore: 🔨 增加 Git 提交规范
1 parent 66a3d43 commit ec07019

File tree

6 files changed

+4754
-190
lines changed

6 files changed

+4754
-190
lines changed

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit $1

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run lint:lint-staged

commitlint.config.js

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
// @see: https://cz-git.qbenben.com/zh/guide
2+
/** @type {import('cz-git').UserConfig} */
3+
4+
module.exports = {
5+
extends: ["@commitlint/config-conventional"],
6+
rules: {
7+
// @see: https://commitlint.js.org/#/reference-rules
8+
"body-leading-blank": [2, "always"],
9+
"footer-leading-blank": [1, "always"],
10+
"header-max-length": [2, "always", 108],
11+
"subject-empty": [2, "never"],
12+
"type-empty": [2, "never"],
13+
"subject-case": [0],
14+
"type-enum": [
15+
2,
16+
"always",
17+
[
18+
"feat",
19+
"fix",
20+
"docs",
21+
"style",
22+
"refactor",
23+
"perf",
24+
"test",
25+
"build",
26+
"ci",
27+
"chore",
28+
"revert",
29+
"wip",
30+
"workflow",
31+
"types",
32+
"release"
33+
]
34+
]
35+
},
36+
prompt: {
37+
messages: {
38+
type: "Select the type of change that you're committing:",
39+
scope: "Denote the SCOPE of this change (optional):",
40+
customScope: "Denote the SCOPE of this change:",
41+
subject: "Write a SHORT, IMPERATIVE tense description of the change:\n",
42+
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
43+
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
44+
footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):",
45+
customFooterPrefixs: "Input ISSUES prefix:",
46+
footer: "List any ISSUES by this change. E.g.: #31, #34:\n",
47+
confirmCommit: "Are you sure you want to proceed with the commit above?"
48+
// 中文版
49+
// type: "选择你要提交的类型 :",
50+
// scope: "选择一个提交范围(可选):",
51+
// customScope: "请输入自定义的提交范围 :",
52+
// subject: "填写简短精炼的变更描述 :\n",
53+
// body: '填写更加详细的变更描述(可选)。使用 "|" 换行 :\n',
54+
// breaking: '列举非兼容性重大的变更(可选)。使用 "|" 换行 :\n',
55+
// footerPrefixsSelect: "选择关联issue前缀(可选):",
56+
// customFooterPrefixs: "输入自定义issue前缀 :",
57+
// footer: "列举关联issue (可选) 例如: #31, #I3244 :\n",
58+
// confirmCommit: "是否提交或修改commit ?"
59+
},
60+
types: [
61+
{
62+
value: "feat",
63+
name: "feat: 🚀 A new feature",
64+
emoji: "🚀"
65+
},
66+
{
67+
value: "fix",
68+
name: "fix: 🧩 A bug fix",
69+
emoji: "🧩"
70+
},
71+
{
72+
value: "docs",
73+
name: "docs: 📚 Documentation only changes",
74+
emoji: "📚"
75+
},
76+
{
77+
value: "style",
78+
name: "style: 🎨 Changes that do not affect the meaning of the code",
79+
emoji: "🎨"
80+
},
81+
{
82+
value: "refactor",
83+
name: "refactor: ♻️ A code change that neither fixes a bug nor adds a feature",
84+
emoji: "♻️"
85+
},
86+
{
87+
value: "perf",
88+
name: "perf: ⚡️ A code change that improves performance",
89+
emoji: "⚡️"
90+
},
91+
{
92+
value: "test",
93+
name: "test: ✅ Adding missing tests or correcting existing tests",
94+
emoji: "✅"
95+
},
96+
{
97+
value: "build",
98+
name: "build: 📦️ Changes that affect the build system or external dependencies",
99+
emoji: "📦️"
100+
},
101+
{
102+
value: "ci",
103+
name: "ci: 🎡 Changes to our CI configuration files and scripts",
104+
emoji: "🎡"
105+
},
106+
{
107+
value: "chore",
108+
name: "chore: 🔨 Other changes that don't modify src or test files",
109+
emoji: "🔨"
110+
},
111+
{
112+
value: "revert",
113+
name: "revert: ⏪️ Reverts a previous commit",
114+
emoji: "⏪️"
115+
}
116+
// 中文版
117+
// { value: "特性", name: "特性: 🚀 新增功能", emoji: "🚀" },
118+
// { value: "修复", name: "修复: 🧩 修复缺陷", emoji: "🧩" },
119+
// { value: "文档", name: "文档: 📚 文档变更", emoji: "📚" },
120+
// { value: "格式", name: "格式: 🎨 代码格式(不影响功能,例如空格、分号等格式修正)", emoji: "🎨" },
121+
// { value: "重构", name: "重构: ♻️ 代码重构(不包括 bug 修复、功能新增)", emoji: "♻️" },
122+
// { value: "性能", name: "性能: ⚡️ 性能优化", emoji: "⚡️" },
123+
// { value: "测试", name: "测试: ✅ 添加疏漏测试或已有测试改动", emoji: "✅" },
124+
// { value: "构建", name: "构建: 📦️ 构建流程、外部依赖变更(如升级 npm 包、修改 webpack 配置等)", emoji: "📦️" },
125+
// { value: "集成", name: "集成: 🎡 修改 CI 配置、脚本", emoji: "🎡" },
126+
// { value: "回退", name: "回退: ⏪️ 回滚 commit", emoji: "⏪️" },
127+
// { value: "其他", name: "其他: 🔨 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)", emoji: "🔨" }
128+
],
129+
useEmoji: true,
130+
themeColorCode: "",
131+
scopes: [],
132+
allowCustomScopes: true,
133+
allowEmptyScopes: true,
134+
customScopesAlign: "bottom",
135+
customScopesAlias: "custom",
136+
emptyScopesAlias: "empty",
137+
upperCaseSubject: false,
138+
allowBreakingChanges: ["feat", "fix"],
139+
breaklineNumber: 100,
140+
breaklineChar: "|",
141+
skipQuestions: [],
142+
issuePrefixs: [{ value: "closed", name: "closed: ISSUES has been processed" }],
143+
customIssuePrefixsAlign: "top",
144+
emptyIssuePrefixsAlias: "skip",
145+
customIssuePrefixsAlias: "custom",
146+
allowCustomIssuePrefixs: true,
147+
allowEmptyIssuePrefixs: true,
148+
confirmColorize: true,
149+
maxHeaderLength: Infinity,
150+
maxSubjectLength: Infinity,
151+
minSubjectLength: 0,
152+
scopeOverrides: undefined,
153+
defaultBody: "",
154+
defaultIssues: "",
155+
defaultScope: "",
156+
defaultSubject: ""
157+
}
158+
};

lint-staged.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"],
3+
"{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": ["prettier --write--parser json"],
4+
"package.json": ["prettier --write"],
5+
"*.vue": ["eslint --fix", "prettier --write", "stylelint --fix"],
6+
"*.{scss,less,styl,html}": ["stylelint --fix", "prettier --write"],
7+
"*.md": ["prettier --write"]
8+
};

0 commit comments

Comments
 (0)