Skip to content

Commit

Permalink
Merge pull request #2 from QuantGeekDev/feature/husky-hooks
Browse files Browse the repository at this point in the history
Feature/husky hooks
  • Loading branch information
QuantGeekDev authored Jan 4, 2024
2 parents c1db9af + 4576b40 commit bab8ed5
Show file tree
Hide file tree
Showing 9 changed files with 11,152 additions and 7,733 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"parser": "@typescript-eslint/parser",
"plugins": [
"prettier",
"react",
"import",
"@typescript-eslint",
"github",
Expand All @@ -22,5 +21,6 @@
"arrow-parens": "off",
"prettier/prettier": 2,
"semi": "off"
}
},
"ignorePatterns":"commitlint.config.cjs"
}
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
13 changes: 13 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

branch="$(git symbolic-ref --short -q HEAD)"

if [ "$branch" = "master" ] || [ "$branch" = "main" ]; then
echo "You can't commit directly to main branch"
exit 1
fi

exec >/dev/tty 2>&1

npx lint-staged
15 changes: 15 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

local_branch_name="$(git rev-parse --abbrev-ref HEAD)"

valid_branch_regex='^((hotfix|bugfix|feature)\/[a-zA-Z0-9\-]+)$'

message="Please check your branch name."

if [[ ! $local_branch_name =~ $valid_branch_regex ]]; then
echo -e "\033[0;31m$message"
exit 1
fi

exit 0
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.{ts, js,css,json,md}": "prettier --write",
"*.ts": "eslint --max-warnings=0"
}
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"trailingComma": "none",
"trailingComma": "all",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
Expand Down
12 changes: 12 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
formatter: '@commitlint/format',
rules: {
'header-min-length': [2, 'always', 10],
'header-max-length': [2, 'always', 72],
'header-case': [2, 'always', ['sentence-case']],
'type-empty': [2, 'always'],
'scope-empty': [2, 'always'],
'subject-empty': [2, 'always']
}
}
Loading

0 comments on commit bab8ed5

Please sign in to comment.