@@ -26,38 +26,85 @@ jobs:
2626
2727 - name : Check for TypeScript
2828 run : |
29- # Allowlist (TS legitimate as a bridge/adapter to a non-ReScript ecosystem):
30- # bindings/ - language bindings (Deno/TS/AssemblyScript FFI)
31- # *.d.ts - TypeScript type declarations for ReScript FFI
32- # tests/, test/ - Deno test runners
33- # scripts/ - Deno build scripts
34- # mcp-adapter/ - MCP server adapters (MCP is Deno/TS-typed by spec)
35- # *vscode* - VSCode extensions (TS is the ecosystem default)
36- # cli/ - CLI entry points (Deno scripts)
37- # mod.ts - canonical Deno module entrypoint
38- # *lsp-server.ts, *lsp.ts - Language Server Protocol implementations
39- # deno-*/ - subprojects explicitly named for Deno
40- TS_FILES=$(find . \( -name "*.ts" -o -name "*.tsx" \) \
41- | grep -v node_modules \
42- | grep -v '/bindings/' \
43- | grep -v '\.d\.ts$' \
44- | grep -v '/tests/' \
45- | grep -v '/test/' \
46- | grep -v '/scripts/' \
47- | grep -v '/mcp-adapter/' \
48- | grep -Ev '/[^/]*vscode[^/]*/' \
49- | grep -v '/cli/' \
50- | grep -v '/mod\.ts$' \
51- | grep -Ev 'lsp[-_]?server\.ts$' \
52- | grep -Ev '[/-]lsp\.ts$' \
53- | grep -Ev '/deno-[^/]+/' \
54- || true)
55- if [ -n "$TS_FILES" ]; then
56- echo "❌ TypeScript files detected - use ReScript instead"
57- echo "$TS_FILES"
58- exit 1
59- fi
60- echo "✅ No TypeScript files outside allowlisted bridge/adapter paths"
29+ python3 << 'PYEOF'
30+ import re, sys, fnmatch, pathlib
31+
32+ # Universal builtin allowlist — bridges that need no per-repo declaration.
33+ # Files matching any of these patterns are always allowed.
34+ BUILTIN_GLOBS = [
35+ '*.d.ts',
36+ '**/bindings/**',
37+ '**/tests/**', '**/test/**',
38+ '**/scripts/**',
39+ '**/mcp-adapter/**',
40+ '**/*vscode*/**',
41+ '**/cli/**',
42+ '**/mod.ts',
43+ '**/lsp-server.ts', '**/lsp_server.ts', '**/lsp.ts', '**/*-lsp.ts',
44+ '**/deno-*/**',
45+ '**/node_modules/**',
46+ '**/vendor/**',
47+ '**/examples/**',
48+ '**/ffi/**',
49+ ]
50+
51+ # Per-repo exemptions parsed from .claude/CLAUDE.md "TypeScript Exemptions" table.
52+ # Single source of truth — adding a row here unblocks CI for that path.
53+ # Format expected:
54+ # ### TypeScript Exemptions ...
55+ # | Path | Files | Rationale | Unblock condition |
56+ # |---|---|---|---|
57+ # | `path/to/file.ts` | 1 | ... | ... |
58+ # | `dir/*.ts` | 6 | ... | ... |
59+ exemptions = []
60+ claude_md = pathlib.Path('.claude/CLAUDE.md')
61+ if claude_md.exists():
62+ in_table = False
63+ for line in claude_md.read_text(encoding='utf-8').splitlines():
64+ if re.search(r'TypeScript [Ee]xemptions', line):
65+ in_table = True
66+ continue
67+ if in_table and line.startswith(('### ', '## ', '# ')):
68+ break
69+ if in_table and line.startswith('|'):
70+ m = re.match(r'\|\s*`([^`]+)`', line)
71+ if m:
72+ exemptions.append(m.group(1))
73+
74+ # Find all .ts and .tsx files
75+ found = []
76+ for ext in ('ts', 'tsx'):
77+ found.extend(str(p) for p in pathlib.Path('.').rglob(f'*.{ext}'))
78+
79+ def allowed(path):
80+ p = path.lstrip('./')
81+ for g in BUILTIN_GLOBS + exemptions:
82+ if fnmatch.fnmatchcase(p, g):
83+ return True
84+ # also treat glob ending with / as a directory prefix
85+ base = g.rstrip('/').rstrip('*').rstrip('/')
86+ if base and (p == base or p.startswith(base + '/')):
87+ return True
88+ return False
89+
90+ bad = sorted(f for f in found if not allowed(f))
91+ if bad:
92+ print("❌ TypeScript files detected outside the allowlist.\n")
93+ for f in bad:
94+ print(f" {f}")
95+ print()
96+ print("To resolve, either:")
97+ print(" (a) migrate the file to AffineScript")
98+ print(" (see Human_Programming_Guide.adoc migration chapter), OR")
99+ print(" (b) move it to an allowlisted bridge path")
100+ print(" (bindings/, tests/, scripts/, mcp-adapter/, *vscode*/, cli/, deno-*/, etc.), OR")
101+ print(" (c) add an entry to the 'TypeScript Exemptions' table in .claude/CLAUDE.md")
102+ print(" with rationale + unblock condition.")
103+ if exemptions:
104+ print(f"\n(Currently {len(exemptions)} exemption(s) parsed from .claude/CLAUDE.md.)")
105+ sys.exit(1)
106+ print(f"✅ No TypeScript files outside allowlist ({len(exemptions)} per-repo exemption(s) parsed).")
107+ PYEOF
61108
62109 - name : Check for Go
63110 run : |
0 commit comments