-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.lefthook.yaml
More file actions
40 lines (37 loc) · 1.33 KB
/
.lefthook.yaml
File metadata and controls
40 lines (37 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# yaml-language-server: $schema=https://raw.githubusercontent.com/evilmartians/lefthook/refs/heads/master/schema.json
# https://lefthook.dev/configuration/
output: [ summary ]
pre-commit:
commands:
branch-name:
run: |
branch_name=$(git rev-parse --abbrev-ref HEAD)
if ! [[ "$branch_name" =~ ^(feature|fix)/ ]]; then
echo "Error: Branch name must start with 'feature/' or 'fix/'. Your branch: $branch_name"
exit 1
fi
biome:
run: biome check --write --no-errors-on-unmatched --files-ignore-unknown=true {staged_files}
glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}"
stage_fixed: true
commit-msg:
skip:
- merge
- rebase
commands:
conventional-commit:
run: |
commit_msg_file={1}
commit_msg=$(cat "$commit_msg_file")
# Regex for conventional commits (type(scope?): subject)
regex="^(build|chore|ci|docs|feat|fix|perf|refactor|style|test|sec|wip)(\([a-z0-9\-]+\))?(!)?: .{1,50}"
if ! echo "$commit_msg" | grep -qE "$regex"; then
echo "Error: Commit message does not follow Conventional Commits format."
echo "Format: type(scope?): subject"
echo "Example: feat(login): add remember me option"
exit 1
fi
post-checkout:
commands:
mise:
run: mise -q install