From 06d2aca0db2f042517bc7ef2b2220f6c0a3c1767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E5=B8=85?= <892739385@qq.com> Date: Wed, 7 Jun 2023 11:49:43 +0800 Subject: [PATCH] chore: add commitlint and pre-commit --- .gitignore | 5 ++++- .../autoinstallers/lint/commitlint.config.js | 21 ++++++++++++++++++- common/git-hooks/pre-commit | 6 +++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 4fe21622a..fd87fe19e 100644 --- a/.gitignore +++ b/.gitignore @@ -93,4 +93,7 @@ common/autoinstallers/*/.npmrc # packages/vtable-docs/public/css packages/vtable-docs/public/zh/documents packages/vtable-docs/public/en/documents -packages/vtable-docs/public/*.html \ No newline at end of file +packages/vtable-docs/public/*.html + +#git-hook +common/scripts/pre-commit \ No newline at end of file diff --git a/common/autoinstallers/lint/commitlint.config.js b/common/autoinstallers/lint/commitlint.config.js index 69b4242cc..cfade48be 100644 --- a/common/autoinstallers/lint/commitlint.config.js +++ b/common/autoinstallers/lint/commitlint.config.js @@ -1,3 +1,22 @@ module.exports = { - extends: ["@commitlint/config-conventional"], + extends: ['@commitlint/config-conventional'], + rules: { + 'not-allowed-chars': [2, 'always'] + }, + plugins: [ + { + rules: { + 'not-allowed-chars': params => { + const { raw } = params; + const reg = + /^[a-zA-Z0-9\s`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、]+$/im; + + return [ + reg.exec(raw), + 'Your commit message should only contain english characters, numbers, empty space, and special characters.' + ]; + } + } + } + ] }; diff --git a/common/git-hooks/pre-commit b/common/git-hooks/pre-commit index d6de9b661..5686c1c8a 100644 --- a/common/git-hooks/pre-commit +++ b/common/git-hooks/pre-commit @@ -1,3 +1,7 @@ #!/bin/sh -node common/scripts/install-run-rush.js lint-staged || exit $? #++ \ No newline at end of file +node common/scripts/install-run-rush.js lint-staged || exit $? #++ + +if [ -f "common/scripts/pre-commit" ]; then + common/scripts/pre-commit +fi \ No newline at end of file