From 2f8147f9b53b78488294c78b06b9e22fc5b4a369 Mon Sep 17 00:00:00 2001 From: "chen.home" Date: Fri, 16 Jun 2023 00:23:30 +0800 Subject: [PATCH] fix: modfiy githook to husky --- .husky/commit-msg | 4 ++++ .husky/pre-commit | 4 ++++ .vscode/settings.json | 2 +- package.json | 10 +++------- 4 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 .husky/commit-msg create mode 100644 .husky/pre-commit 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..0312b76 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index c6b63c3..1ec6dfd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "editor.tabSize": 2, "editor.formatOnSave": false, - "eslint.format.enable": true, + "eslint.format.enable": false, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, diff --git a/package.json b/package.json index 997586d..1e55aea 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "build": "vue-tsc --noEmit && vite build", "preview": "vite preview", "lint": "eslint . --fix", - "prepare": "npx simple-git-hooks", + "prepare": "husky install", "commit": "cz", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md" }, @@ -82,13 +82,13 @@ "cz-conventional-changelog": "^3.3.0", "cz-customizable": "^7.0.0", "eslint": "^8.36.0", + "husky": "^8.0.3", "less": "^4.1.3", "lint-staged": "^13.1.0", "mockjs": "^1.1.0", "naive-ui": "^2.34.4", "rollup-plugin-visualizer": "^5.9.0", - "simple-git-hooks": "^2.8.1", - "typescript": "^5.1.3", + "typescript": "^5.0.0", "unocss": "^0.53.1", "unplugin-auto-import": "^0.16.4", "unplugin-icons": "^0.16.3", @@ -101,10 +101,6 @@ "vite-plugin-vue-setup-extend": "^0.4.0", "vue-tsc": "^1.6.5" }, - "simple-git-hooks": { - "pre-commit": "pnpm lint-staged", - "commit-msg": "pnpm commitlint -e" - }, "lint-staged": { "*.{js,jsx,mjs,ts,tsx,json,md,yml}": [ "eslint --fix"