Files
q-blog/scripts/dev/phase1/remove-ts-nocheck.sh
2025-08-16 23:31:26 -04:00

38 lines
1.1 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Remove leading `// @ts-nocheck` occurrences (tiny PR safety).
# Usage: bash scripts/dev/phase1/remove-ts-nocheck.sh [--apply]
set -euo pipefail
MODE="dry"
[[ "${1-}" == "--apply" ]] && MODE="apply"
ROOT="$(git rev-parse --show-toplevel 2>/dev/null || echo .)"
OUTDIR="$ROOT/reports/phase1-$(date +%Y%m%d-%H%M%S)-ts-nocheck"
mkdir -p "$OUTDIR"
mapfile -t FILES < <(grep -RIl --include='*.{ts,tsx}' '^// *@ts-nocheck' "$ROOT/src" || true)
COUNT="${#FILES[@]}"
echo "Found $COUNT files with // @ts-nocheck"
printf '%s
' "${FILES[@]}" | tee "$OUTDIR/files.txt"
cleanup_file() {(
f="$1"
tmp="$f.__tmp__"
awk 'NR==1 && $0 ~ /^\/\/ *@ts-nocheck/ {print "// TODO(Phase 1): removed ts-nocheck; fix types in Phase 23"; next} {print}' "$f" > "$tmp"
if [[ "$MODE" == "apply" ]]; then
mv "$tmp" "$f"
echo "[APPLY] $f" >> "$OUTDIR/changes.log"
else
echo "[DRY] diff $f"
git --no-pager diff --no-index "$f" "$tmp" || true
rm -f "$tmp"
fi
)}
for f in "${FILES[@]}"; do
[[ -f "$f" ]] && cleanup_file "$f"
done
echo "Report: $OUTDIR"