Ver Fonte

feat(package.json): 新增git commit格式规范工具和提交前eslint检查

commitizen+husky+lint-staged+eslint
zhusiqing há 3 anos atrás
pai
commit
b91a5fb010
2 ficheiros alterados com 20 adições e 2 exclusões
  1. 4 0
      .husky/pre-commit
  2. 16 2
      package.json

+ 4 - 0
.husky/pre-commit

@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+lint-staged

+ 16 - 2
package.json

@@ -26,7 +26,9 @@
     "pm2:start": "yarn run compile && pm2 start ./pm2.config.js",
     "pm2:list": "pm2 list",
     "pm2:stop": "pm2 stop gateway && pm2 delete gateway",
-    "pm2:restart": "pm2 restart gateway"
+    "pm2:restart": "pm2 restart gateway",
+    "commit": "git cz",
+    "prepare": "husky install"
   },
   "dependencies": {
     "@koa/multer": "^3.0.0",
@@ -64,7 +66,11 @@
     "@types/ws": "^7.4.6",
     "@typescript-eslint/eslint-plugin": "^4.29.0",
     "@typescript-eslint/parser": "^4.29.0",
+    "commitizen": "^4.2.4",
+    "cz-conventional-changelog": "^3.3.0",
     "eslint": "^7.32.0",
+    "husky": "^7.0.1",
+    "lint-staged": "^11.1.2",
     "ts-node": "^9.0.0",
     "tsconfig-paths": "^3.9.0",
     "ttypescript": "^1.5.12",
@@ -73,5 +79,13 @@
   },
   "bugs": "http://git.zsqlm.cn/siqing/gateway_koa_ts/issues",
   "homepage": "https://www.zsqlm.cn/",
-  "repository": "http://git.zsqlm.cn/siqing/gateway_koa_ts"
+  "repository": "http://git.zsqlm.cn/siqing/gateway_koa_ts",
+  "config": {
+    "commitizen": {
+      "path": "./node_modules/cz-conventional-changelog"
+    }
+  },
+  "lint-staged": {
+    "*.{vue,js,ts}": ["eslint --fix", "git add"]
+  }
 }