-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
201 lines (189 loc) · 6 KB
/
.pre-commit-config.yaml
File metadata and controls
201 lines (189 loc) · 6 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# stampchain.io Pre-commit Configuration
#
# This configuration enforces code quality standards before commits,
# including import pattern validation, formatting, and type checking.
#
# Install pre-commit hooks with:
# pip install pre-commit
# pre-commit install
#
# Run hooks manually:
# pre-commit run --all-files
repos:
# Deno formatting and linting
- repo: local
hooks:
# Deno format check
- id: deno-fmt
name: Deno Format Check
entry: deno
args: [fmt, --check]
language: system
files: \.(ts|tsx|js|jsx)$
exclude: |
(?x)^(
_fresh/.*|
node_modules/.*|
dist/.*|
coverage/.*|
tmp/.*|
build/.*|
vendor/.*|
\.git/.*|
scripts/.*\.(js|cjs)
)$
# Deno lint check
- id: deno-lint
name: Deno Lint Check
entry: deno
args: [lint, --quiet]
language: system
files: \.(ts|tsx)$
exclude: |
(?x)^(
_fresh/.*|
node_modules/.*|
dist/.*|
coverage/.*|
tmp/.*|
build/.*|
vendor/.*|
\.git/.*|
scripts/.*\.(js|cjs)
)$
# TypeScript type checking
- id: deno-check
name: Deno Type Check
entry: deno
args: [check, main.ts]
language: system
files: \.(ts|tsx)$
exclude: |
(?x)^(
_fresh/.*|
node_modules/.*|
dist/.*|
coverage/.*|
tmp/.*|
build/.*|
vendor/.*|
\.git/.*|
tests/.*
)$
# Import pattern validation (critical for domain architecture)
- repo: local
hooks:
- id: import-pattern-validation
name: Import Pattern Validation
description: "Validates import patterns to prevent $globals usage and enforce alias imports"
entry: deno
args: [task, check:imports:ci]
language: system
files: \.(ts|tsx)$
exclude: |
(?x)^(
_fresh/.*|
node_modules/.*|
dist/.*|
coverage/.*|
tmp/.*|
build/.*|
vendor/.*|
\.git/.*|
scripts/migrate-.*\.ts|
scripts/update-imports.*\.ts
)$
stages: [commit]
# Security and dependency checks
- repo: local
hooks:
# Check for sensitive information
- id: check-secrets
name: Check for Secrets
entry: bash
args:
- -c
- |
# Check for common secret patterns
if grep -r --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" \
-E "(password|secret|key|token).*[=:]\s*['\"][^'\"]{8,}['\"]" . --exclude-dir=node_modules --exclude-dir=_fresh --exclude-dir=.git --exclude-dir=coverage --exclude-dir=tmp; then
echo "❌ Potential secrets found in code. Please remove or use environment variables."
exit 1
fi
echo "✅ No obvious secrets detected"
language: system
files: \.(ts|tsx|js|jsx)$
# Check for TODO comments without issue links
- id: check-todos
name: Check TODO Comments
entry: bash
args:
- -c
- |
# Find TODO comments without links to issues
todos=$(grep -rn --include="*.ts" --include="*.tsx" "TODO" . --exclude-dir=node_modules --exclude-dir=_fresh --exclude-dir=.git --exclude-dir=coverage --exclude-dir=tmp | grep -v -E "(TODO:|#[0-9]+|https?://|task-[0-9]+)" || true)
if [ -n "$todos" ]; then
echo "⚠️ Found TODO comments without issue references:"
echo "$todos"
echo ""
echo "Please add issue references like: TODO: Fix this (#123) or TODO(task-42): Update logic"
# Don't fail the commit, just warn
fi
language: system
files: \.(ts|tsx)$
# File integrity checks
- repo: local
hooks:
# Check for large files
- id: check-large-files
name: Check for Large Files
entry: bash
args:
- -c
- |
large_files=$(find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \) \
-not -path "./_fresh/*" -not -path "./node_modules/*" -not -path "./.git/*" \
-not -path "./coverage/*" -not -path "./tmp/*" -not -path "./dist/*" \
-size +100k)
if [ -n "$large_files" ]; then
echo "⚠️ Large files detected (>100KB):"
echo "$large_files"
echo ""
echo "Consider breaking down large files or adding them to .gitignore if they're generated"
# Don't fail, just warn
fi
language: system
# Prevent commits to protected files
- id: protect-critical-files
name: Protect Critical Configuration Files
entry: bash
args:
- -c
- |
# Prevent accidental modification of critical config files
critical_files="deno.lock fresh.gen.ts"
for file in $critical_files; do
if git diff --cached --name-only | grep -q "^$file$"; then
echo "❌ Attempting to commit critical file: $file"
echo "These files should be updated through proper tooling, not manually edited."
exit 1
fi
done
language: system
# Global configuration
default_language_version:
python: python3
# Performance settings
default_stages: [commit]
fail_fast: false
# Custom configuration
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
submodules: false