Skip to content

Commit

Permalink
deps: add commitlint & husky & lint-staged
Browse files Browse the repository at this point in the history
  • Loading branch information
JunyWuuuu91 committed Jun 24, 2022
1 parent acfd6ce commit 67c3a8c
Show file tree
Hide file tree
Showing 5 changed files with 1,906 additions and 15 deletions.
75 changes: 75 additions & 0 deletions .cz-config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
module.exports = {
types: [
{
value: "chore",
name: "🎨 chore: 除定义类型之外的代码修改",
},
{
value: "feat",
name: "✨ feat(CR): 新增功能或特性",
},
{
value: "fix",
name: "🐛 fix(CR): 修复 Bug 缺陷",
},
{
value: "perf",
name: "⚡️ perf(CR): 提高代码性能的变更",
},
{
value: "refactor",
name: "🔨 refactor(CR): 功能逻辑较大的重构",
},
{
value: "revert",
name: "🗑 revert(CR): 代码回退操作",
},
{
value: "docs",
name: "📝 docs: 文档类的更新",
},
{
value: "ci",
name: "👷 ci: 持续集成类调整",
},
{
value: "wip",
name: "🚧 wip: 半成品",
},
{
value: "workflow",
name: "⚙️ workflow: 工作流调整",
},
{
value: "deps",
name: "⬆️ deps: 依赖更改",
},
{
value: "test",
name: "✅ test: 新增测试用例或是更新现有测试用例",
},
{
value: "build",
name: "🚀 build: 编译构建类的代码调整",
},
{
value: "style",
name: "💄 style: 代码格式化",
},
],
scopes: [],
messages: {
type: "请选择提交类型:",
scope: "请选择一个影响范围 (可选):",
customScope: "请输入本次修改影响范围(可选):",
subject: "请简述本次提交行为(必填,动词前置):",
body: "请输入详细描述(可选):",
breaking: "非兼容性说明 (可选):\n",
footer: "关联关闭的issue,例如:#31, #34(可选):\n",
confirmCommit: "确认按照规范填写了以上内容?(y/n)",
},
allowCustomScopes: true,
skipQuestions: ["body", "footer"],
allowBreakingChanges: ["feat", "refactor"],
subjectLimit: 256,
};
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
30 changes: 30 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"type-enum": [
2,
"always",
[
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"chore",
"wip",
"workflow",
"revert",
"build",
"ci",
"deps",
],
],
"type-case": [0],
"subject-case": [0],
"body-max-length": [0, "always", 256],
"header-max-length": [0, "always", 256],
"body-max-line-length": [0, "always", 256],
},
};
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,34 @@
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"commit": "git add -A && git-cz",
"prepare": "husky install"
},
"dependencies": {
"koa": "^2.13.4",
"puppeteer": "^15.0.0",
"puppeteer-core": "^15.0.0"
},
"devDependencies": {
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"commitizen": "^4.2.4",
"cz-customizable": "^6.3.0",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.2",
"prettier": "^2.7.1"
},
"config": {
"commitizen": {
"path": "node_modules/cz-customizable"
},
"cz-customizable": {
"config": ".cz-config.cjs"
}
}
}
Loading

0 comments on commit 67c3a8c

Please sign in to comment.