-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·62 lines (49 loc) · 1.58 KB
/
Copy pathpre-commit
File metadata and controls
executable file
·62 lines (49 loc) · 1.58 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
#!/bin/sh
# SPDX-License-Identifier: PMPL-1.0-or-later
# Pre-commit hook for ipv6-only
# Enforces RSR compliance and code quality
set -e
echo "Running pre-commit checks..."
# RSR Compliance Checks
echo "Checking RSR compliance..."
# Check for TypeScript
if find . -name "*.ts" -o -name "*.tsx" 2>/dev/null | grep -v node_modules | grep -v .d.ts | grep -q .; then
echo "ERROR: TypeScript files detected - use AffineScript instead"
exit 1
fi
# Check for Go
if find . -name "*.go" 2>/dev/null | grep -q .; then
echo "ERROR: Go files detected - use Rust instead"
exit 1
fi
# Check for Makefile
if find . -name "Makefile" -o -name "*.mk" 2>/dev/null | grep -q .; then
echo "ERROR: Makefile detected - use justfile instead"
exit 1
fi
# Check for npm lockfiles
if [ -f "package-lock.json" ] || [ -f "yarn.lock" ] || [ -f "bun.lockb" ] || [ -f "pnpm-lock.yaml" ]; then
echo "ERROR: npm/yarn/bun/pnpm lockfile detected - use Deno instead"
exit 1
fi
# Check for tsconfig.json
if [ -f "tsconfig.json" ]; then
echo "ERROR: tsconfig.json detected - use AffineScript instead"
exit 1
fi
echo "RSR compliance: OK"
# Rust checks (if cargo is available)
if command -v cargo >/dev/null 2>&1; then
echo "Running cargo fmt check..."
cargo fmt -- --check || {
echo "ERROR: Code not formatted. Run 'cargo fmt' first."
exit 1
}
echo "Running cargo clippy..."
cargo clippy -- -D warnings || {
echo "ERROR: Clippy warnings found. Fix them before committing."
exit 1
}
echo "Rust checks: OK"
fi
echo "All pre-commit checks passed!"