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