From c6bc1f70b5a5f70a09410f523d79bd9331bc2d02 Mon Sep 17 00:00:00 2001 From: "Y." Date: Wed, 14 Aug 2024 11:09:52 +0800 Subject: [PATCH] chore: update pre-commit (#454) --- .husky/commit-msg | 5 +---- .husky/pre-commit | 3 +-- .husky/prepare-commit-msg | 6 ++++++ package.json | 9 ++++++++- 4 files changed, 16 insertions(+), 7 deletions(-) create mode 100755 .husky/prepare-commit-msg diff --git a/.husky/commit-msg b/.husky/commit-msg index 59a2376c..fe4c17a2 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,7 +1,4 @@ #!/bin/sh -[ -n "$CI" ] && exit 0 . "$(dirname "$0")/_/husky.sh" -npx commitlint -e $HUSKY_GIT_PARAMS - -exec < /dev/tty && npx cz --hook || true \ No newline at end of file +npx --no-install commitlint --edit "" diff --git a/.husky/pre-commit b/.husky/pre-commit index 7c96b908..6cb41567 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1,4 @@ #!/bin/sh -[ -n "$CI" ] && exit 0 . "$(dirname "$0")/_/husky.sh" -npm run lint:fix +npx lint-staged && log_emails=$(git config user.email) && if [[ ${log_emails} =~ '@tencent.com' ]];then echo 本地提交邮箱 $log_emails 校验非法,需要本地更改重新提交 && exit 2;else echo 邮箱 $log_emails 校验通过;fi diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg new file mode 100755 index 00000000..67205677 --- /dev/null +++ b/.husky/prepare-commit-msg @@ -0,0 +1,6 @@ +#!/bin/sh +[[ "$(uname -a)" = *"MINGW64"* ]] && exit 0 +[ -n "$CI" ] && exit 0 +. "$(dirname "$0")/_/husky.sh" + +exec < /dev/tty && npx git-cz --hook || true \ No newline at end of file diff --git a/package.json b/package.json index 424ae49e..1185a79a 100644 --- a/package.json +++ b/package.json @@ -129,6 +129,7 @@ "inquirer": "^8.2.0", "jsdom": "^24.1.0", "less": "^4.1.2", + "lint-staged": "^15.2.9", "markdown-it-fence": "^0.1.3", "mockdate": "^3.0.5", "npm-run-all": "^4.1.5", @@ -173,5 +174,11 @@ "commitizen": { "path": "./node_modules/cz-conventional-changelog" } + }, + "lint-staged": { + "src/**/*.{ts,tsx,js,jsx}": [ + "prettier --write", + "npm run lint:fix" + ] } -} \ No newline at end of file +}