-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy patheslint.config.js
More file actions
110 lines (108 loc) · 2.93 KB
/
Copy patheslint.config.js
File metadata and controls
110 lines (108 loc) · 2.93 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
import { includeIgnoreFile } from "@eslint/compat";
import pluginJs from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier/flat";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import tseslint from "typescript-eslint";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");
/** @type {import('eslint').Linter.Config[]} */
export default [
includeIgnoreFile(gitignorePath),
{
ignores: [
"src/server/gatekeeper/**",
"tests/pathfinding/playground/**",
".claude/**",
],
},
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: [
"__mocks__/fileMock.js",
"eslint.config.js",
"scripts/sync-assets.mjs",
"tests/matchmaking/*.mjs",
],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
// Disable rules that would fail. The failures should be fixed, and the entries here removed.
"@typescript-eslint/no-explicit-any": "off",
"no-unused-vars": "off",
},
},
{
// The simulation must be bit-identical on every client. Math.exp & co.
// are only "implementation approximated" by the spec; use DetMath.
files: ["src/core/**/*.ts"],
ignores: ["src/core/DetMath.ts"],
rules: {
"no-restricted-properties": [
"error",
...[
"exp",
"expm1",
"log",
"log1p",
"log2",
"log10",
"pow",
"sin",
"cos",
"tan",
"asin",
"acos",
"atan",
"atan2",
"sinh",
"cosh",
"tanh",
"cbrt",
"hypot",
].map((property) => ({
object: "Math",
property,
message: `Math.${property} differs between JS engines; use src/core/DetMath.ts to keep the simulation deterministic.`,
})),
],
"no-restricted-syntax": [
"error",
{
selector:
"BinaryExpression[operator='**']:not([right.type='Literal'][right.value=2])",
message:
"`**` with a non-2 exponent differs between JS engines; use src/core/DetMath.ts to keep the simulation deterministic.",
},
],
},
},
{
rules: {
// Enable rules
"@typescript-eslint/prefer-nullish-coalescing": "error",
eqeqeq: "error",
"no-case-declarations": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "none",
caughtErrors: "none",
},
],
},
},
];