Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add semantic commit / branch hooks validation #1248

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx commitlint --edit
11 changes: 11 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

BRANCH=$(git rev-parse --abbrev-ref HEAD)
REGEX="^(master|dev|release-candidate|((audit|breaking|build|chore|ci|docs|feat|fix|perf|refactor|release|revert|test|wip)/.+))$"

if ! echo "$BRANCH" | grep -Eq "$REGEX"; then
echo "Your commit was rejected due to invalid branch name: '$BRANCH'"
echo "Please rename your branch to follow one of the accepted formats:"
echo " - audit/*, breaking/*, build/*, chore/*, ci/*, docs/*, feat/*, fix/*, perf/*, refactor/*, release/*, revert/*, test/*, wip/*"
exit 1
fi
8 changes: 8 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e

npm run lint

if [ "$PRE_PUSH_RUN_TEST" = "true" ]; then
npm test
fi
19 changes: 19 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
parserPreset: 'conventional-changelog-conventionalcommits',
rules: {
'body-leading-blank': [1, 'always'],
'footer-leading-blank': [1, 'always'],
'footer-max-line-length': [2, 'always', 100],
'header-max-length': [2, 'always', 100],
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
['build', 'breaking', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test'],
],
},
};
Loading
Loading