Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
118 lines (115 loc) · 3.21 KB
/
Copy patheslint.config.js
File metadata and controls
118 lines (115 loc) · 3.21 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import globals from "globals";
const solverImportPattern = {
regex: "(^|/)solver(?:/|$)",
message: "the dev/test-only solver must not enter the production dependency graph.",
};
const dynamicSolverImportRestriction = {
selector: "ImportExpression[source.type='Literal'][source.value=/\\/solver(?:\\/|$)/]",
message: "the dev/test-only solver must not be imported dynamically by production code.",
};
export default tseslint.config(
{
ignores: [
"dist/",
"node_modules/",
"coverage/",
"playwright-report/",
"test-results/",
"**/*.config.js",
],
},
js.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
globals: { ...globals.node },
},
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
},
},
{
files: ["src/**/*.ts", "src/**/*.tsx"],
ignores: ["src/**/*.test.ts", "src/**/*.test.tsx", "src/sim/solver/**"],
rules: {
"no-restricted-imports": ["error", { patterns: [solverImportPattern] }],
"no-restricted-syntax": ["error", dynamicSolverImportRestriction],
},
},
// Determinism + purity hard-rules for the sim core, enforced automatically.
// See AGENTS.md "Hard Rules".
{
files: ["src/sim/**/*.ts"],
ignores: ["src/sim/**/*.test.ts"],
rules: {
"no-restricted-properties": [
"error",
{
object: "Math",
property: "random",
message: "sim core must use the seeded rng (src/sim/rng), never Math.random.",
},
{
object: "Date",
property: "now",
message: "sim core is tick-based; time comes from the tick counter, not Date.now.",
},
{
object: "performance",
property: "now",
message: "sim core is tick-based; no performance.now.",
},
],
"no-restricted-globals": [
"error",
{ name: "Date", message: "sim core is tick-based; no wall-clock time." },
],
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["pixi.js", "react", "react-dom", "**/render/**", "**/ui/**"],
message: "sim core is pure: it must not import render / UI / DOM libraries.",
},
],
},
],
},
},
{
files: ["src/sim/**/*.ts"],
ignores: ["src/sim/**/*.test.ts", "src/sim/solver/**"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["pixi.js", "react", "react-dom", "**/render/**", "**/ui/**"],
message: "sim core is pure: it must not import render / UI / DOM libraries.",
},
solverImportPattern,
],
},
],
"no-restricted-syntax": ["error", dynamicSolverImportRestriction],
},
},
// Tests and tooling may be looser.
{
files: ["test/**/*.ts", "tools/**/*.ts", "**/*.test.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
},
},
);