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