Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
98 lines (95 loc) · 4.06 KB
/
Copy patheslint.config.mjs
File metadata and controls
98 lines (95 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import tseslint from "typescript-eslint";
/* The 5.9.3 parser islands: the ONLY files that may import typescript5
* (the alias pinning the old compiler). Everything else lives in the
* 7.0.2 world — the two worlds' enums are renumbered and their nodes are
* not interchangeable, so a stray cross-import is a correctness bug, not
* a style problem. */
const TS5_ISLANDS = [
"packages/compiler/src/frontend/npm.ts",
// Workspace runtime TypeScript is a text→text transpile island; only the
// emitted JavaScript string returns to npm.ts, never a 5.9.3 node or enum.
"packages/compiler/src/frontend/npm-typescript.ts",
"packages/compiler/src/frontend/cjs-lexer.ts",
"packages/compiler/src/frontend/cjs-bun-exports.ts",
"packages/compiler/src/frontend/lowering/lower-comptime.ts",
"packages/compiler/src/frontend/ts7/world-check.ts",
// The provenance prescan parses files BEFORE any program world exists
// (the bare-import walk that decides what to fetch) — a parser island
// exactly like npm.ts's specifier scan.
"packages/compiler/src/frontend/provenance.ts",
// The bundler-emitted-CJS export rewrite runs inside the fs shadow,
// BEFORE the 7.0.2 program reads the file — a text→text parser island
// beside cjs-lexer.ts (only strings cross its boundary).
"packages/compiler/src/frontend/npm-static-declarations.ts",
"packages/compiler/src/frontend/npm-static-rewrite.ts",
// Source readability is a text-to-boolean eligibility scan, before the
// program exists. Pure-data AST spans never escape into the TS7 world.
"packages/compiler/src/frontend/npm-static-readability.ts",
// Type-only ESM bridge: parses declaration text, emits JSDoc text; no
// parser nodes or enums cross into the checker/lowering world.
"packages/compiler/src/frontend/npm-static-types.ts",
// Semantic cache validation parses source text only to identify exact
// regex spans and syntax errors; its boundary is strings, offsets, and
// booleans, so no 5.9.3 AST value enters the 7.0.2 program world.
"packages/compiler/src/library/semantic-source.ts",
// Rewrites `import … from "bun:*"` in EMBEDDED JavaScript (island
// source, never program AST) into trap-table reads: like npm.ts's scan,
// its boundary is source text and offsets.
"packages/compiler/src/frontend/bun-island-rewrite.ts",
];
const ts5Fence = {
group: ["typescript5", "typescript5/*"],
message: "typescript5 (the 5.9.3 island alias) is only for the explicit parser islands — everything else is the 7.0.2 world; the worlds never mix",
};
const frontendFence = {
group: ["**/frontend/*", "**/frontend/**"],
message: "backend must not import frontend — the IR is the only interface",
};
const backendFence = {
group: ["**/backend/*", "**/backend/**"],
message: "frontend must not import backend — the IR is the only interface",
};
/* NOTE: no-restricted-imports does not MERGE across matching config
* blocks — the last matching block replaces the whole rule config. Every
* block below therefore carries its complete pattern set. */
export default tseslint.config(
...tseslint.configs.recommended,
{
rules: {
"@typescript-eslint/no-non-null-assertion": "warn",
},
},
{
// The IR is the only interface between frontend and backend.
files: ["packages/compiler/src/backend/**"],
rules: {
"no-restricted-imports": ["error", { patterns: [frontendFence, ts5Fence] }],
},
},
{
files: ["packages/compiler/src/frontend/**"],
ignores: TS5_ISLANDS,
rules: {
"no-restricted-imports": ["error", { patterns: [backendFence, ts5Fence] }],
},
},
{
files: TS5_ISLANDS,
rules: {
"no-restricted-imports": ["error", { patterns: [backendFence] }],
},
},
{
// Everything in the compiler outside frontend/backend (ir, diagnostics,
// index) is 7.0.2-world too.
files: ["packages/compiler/src/**"],
ignores: [
"packages/compiler/src/frontend/**",
"packages/compiler/src/backend/**",
...TS5_ISLANDS,
],
rules: {
"no-restricted-imports": ["error", { patterns: [ts5Fence] }],
},
},
);