-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
79 lines (69 loc) · 2.24 KB
/
lefthook.yml
File metadata and controls
79 lines (69 loc) · 2.24 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
pre-commit:
parallel: true
jobs:
# Fixes group - runs sequentially to avoid git conflicts
- group:
parallel: false
jobs:
- name: fix-whitespace
file_types:
- text
exclude: "**/.*"
run: |
for file in {staged_files}; do
if [[ -f "$file" ]]; then
# Remove trailing whitespace (portable sed usage)
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/[[:space:]]*$//' "$file"
else
sed -i 's/[[:space:]]*$//' "$file"
fi
# Ensure file ends with newline
if [[ -s "$file" ]] && [[ $(tail -c1 "$file" | wc -l) -eq 0 ]]; then
echo >> "$file"
fi
fi
done
stage_fixed: true
- name: fmt
glob: "*.rs"
run: cargo fmt --all
stage_fixed: true
- name: toml-fmt
glob: "*.toml"
run: taplo format {staged_files}
stage_fixed: true
- name: docs-prettier
root: docs/
glob: "*.{md,mdx,astro}"
run: pnpm format
stage_fixed: true
- name: docs-check
root: docs/
glob: "*.{md,mdx,astro,ts,js,json}"
run: pnpm check
# Checks group - runs in parallel
- group:
parallel: true
jobs:
- name: clippy
glob: "*.rs"
run: cargo clippy --all-targets --all-features
- name: typos
glob: "*.{rs,md,txt,toml,yml,yaml}"
run: typos {staged_files}
- name: test
glob: "*.rs"
run: cargo test
- name: shellcheck
glob: "*.sh"
run: shellcheck {staged_files}
- name: shellcheck-scripts
glob: "**/scripts/*"
exclude: "*.md|*.txt|*.rs|*.toml|*.yml|*.yaml|*.json"
run: |
for file in {staged_files}; do
if head -n 1 "$file" | grep -qE '^#!/(usr/)?bin/(ba)?sh' || [[ "$file" =~ \.sh$ ]]; then
shellcheck "$file"
fi
done