Skip to content

Commit 4630a12

Browse files
Fix/governance rescript config exemption (#255)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 98fb08c commit 4630a12

1 file changed

Lines changed: 43 additions & 9 deletions

File tree

.github/workflows/governance-reusable.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,50 @@ jobs:
371371
echo "✅ No npm/bun violations"
372372
373373
- name: Check for tsconfig / rescript config
374+
# Honours the same `.hypatia-ignore` exemption mechanism as the
375+
# banned-language-files step (standards#72, Explicit-Escape
376+
# Principle). A config file is exempt if either
377+
# * `.hypatia-ignore` contains the exact line
378+
# `cicd_rules/banned_config_file:<config>`, OR
379+
# * the file carries an inline `# hypatia:ignore … banned_config_file`
380+
# pragma in its first 8 lines (works for JSONC-style configs;
381+
# not for strict JSON variants).
382+
# Required so repos that legitimately retain ReScript while in
383+
# mid-migration (per their `.claude/CLAUDE.md`, e.g. verisimdb)
384+
# can declare the exemption explicitly instead of being globally
385+
# blocked. Same pattern as the .res file step above.
374386
run: |
375-
if [ -f "tsconfig.json" ]; then
376-
echo "❌ tsconfig.json detected - use AffineScript instead"
377-
exit 1
378-
fi
379-
if [ -f "rescript.json" ] || [ -f "bsconfig.json" ]; then
380-
echo "❌ rescript.json/bsconfig.json detected - use AffineScript config instead"
381-
exit 1
382-
fi
383-
echo "✅ No tsconfig.json / rescript config"
387+
rule="cicd_rules/banned_config_file"
388+
389+
is_exempt() {
390+
f="$1"
391+
if [ -f .hypatia-ignore ] && grep -qxF "${rule}:${f}" .hypatia-ignore; then
392+
return 0
393+
fi
394+
if head -n 8 "$f" 2>/dev/null | grep -q "hypatia:ignore.*${rule}"; then
395+
return 0
396+
fi
397+
return 1
398+
}
399+
400+
check_config() {
401+
cfg="$1"; hint="$2"
402+
if [ -f "$cfg" ]; then
403+
if is_exempt "$cfg"; then
404+
echo "⏭️ exempt (${rule}): $cfg"
405+
return 0
406+
fi
407+
echo "❌ ${cfg} detected - ${hint}"
408+
echo " (declare an exemption via .hypatia-ignore line"
409+
echo " '${rule}:${cfg}' if intentional)"
410+
exit 1
411+
fi
412+
}
413+
414+
check_config "tsconfig.json" "use AffineScript instead"
415+
check_config "rescript.json" "use AffineScript config instead"
416+
check_config "bsconfig.json" "use AffineScript config instead"
417+
echo "✅ No non-exempt tsconfig.json / rescript config"
384418
385419
- name: Summary
386420
run: |

0 commit comments

Comments
 (0)