diff --git a/.gitignore b/.gitignore index 4fe21622a2..fd87fe19e8 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 69b4242cc7..cfade48be3 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 d6de9b6614..5686c1c8a9 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