rewrite: pre-commit hook for 10-line net limit — drop JS check (#548)
Some checks failed
Deploy Nexus / deploy (push) Has been cancelled
Some checks failed
Deploy Nexus / deploy (push) Has been cancelled
This commit is contained in:
@@ -1,19 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Pre-commit hook: enforce 777-line limit on JS files
|
# Pre-commit hook: enforce 10-line net addition limit
|
||||||
# Install: git config core.hooksPath .githooks
|
# Install: git config core.hooksPath .githooks
|
||||||
|
|
||||||
FAIL=0
|
ADDITIONS=$(git diff --cached --numstat | awk '{s+=$1} END {print s+0}')
|
||||||
for f in $(git diff --cached --name-only --diff-filter=ACM | grep '\.js$' | grep -v node_modules | grep -v tests/); do
|
DELETIONS=$(git diff --cached --numstat | awk '{s+=$2} END {print s+0}')
|
||||||
LINES=$(wc -l < "$f" | tr -d ' ')
|
NET=$((ADDITIONS - DELETIONS))
|
||||||
if [ "$LINES" -gt 777 ]; then
|
|
||||||
echo "BLOCKED: $f is $LINES lines (max: 777)"
|
|
||||||
echo " Extract into a module. app.js is a thin wrapper."
|
|
||||||
FAIL=1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ $FAIL -eq 1 ]; then
|
if [ "$NET" -gt 10 ]; then
|
||||||
echo ""
|
echo "BLOCKED: Net addition is $NET lines (max: 10)."
|
||||||
echo "No JS file may exceed 777 lines. Break it up."
|
echo " Delete code elsewhere to compensate."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "✓ Pre-commit: net $NET lines (limit: 10)"
|
||||||
|
|||||||
Reference in New Issue
Block a user