From b2c27f4e1d1463428fa593ec0447a1d20278d63d Mon Sep 17 00:00:00 2001 From: Perplexity Computer Date: Thu, 26 Mar 2026 16:44:02 +0000 Subject: [PATCH] =?UTF-8?q?rewrite:=20pre-commit=20hook=20for=2010-line=20?= =?UTF-8?q?net=20limit=20=E2=80=94=20drop=20JS=20check=20(#548)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .githooks/pre-commit | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 6e842f0..dd7ea82 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,19 +1,15 @@ #!/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 -FAIL=0 -for f in $(git diff --cached --name-only --diff-filter=ACM | grep '\.js$' | grep -v node_modules | grep -v tests/); do - LINES=$(wc -l < "$f" | tr -d ' ') - 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 +ADDITIONS=$(git diff --cached --numstat | awk '{s+=$1} END {print s+0}') +DELETIONS=$(git diff --cached --numstat | awk '{s+=$2} END {print s+0}') +NET=$((ADDITIONS - DELETIONS)) -if [ $FAIL -eq 1 ]; then - echo "" - echo "No JS file may exceed 777 lines. Break it up." +if [ "$NET" -gt 10 ]; then + echo "BLOCKED: Net addition is $NET lines (max: 10)." + echo " Delete code elsewhere to compensate." exit 1 fi + +echo "✓ Pre-commit: net $NET lines (limit: 10)"