@pkmn/engine 0.1.0-dev.02b7f810

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +332 -0
  3. package/build/pkg/addon.d.ts +7 -0
  4. package/build/pkg/addon.js +111 -0
  5. package/build/pkg/addon.js.map +1 -0
  6. package/build/pkg/data/ids.json +240 -0
  7. package/build/pkg/data/layout.json +86 -0
  8. package/build/pkg/data/protocol.json +173 -0
  9. package/build/pkg/data.d.ts +91 -0
  10. package/build/pkg/data.js +150 -0
  11. package/build/pkg/data.js.map +1 -0
  12. package/build/pkg/gen1.d.ts +109 -0
  13. package/build/pkg/gen1.js +668 -0
  14. package/build/pkg/gen1.js.map +1 -0
  15. package/build/pkg/index.d.ts +383 -0
  16. package/build/pkg/index.js +122 -0
  17. package/build/pkg/index.js.map +1 -0
  18. package/build/pkg/protocol.d.ts +71 -0
  19. package/build/pkg/protocol.js +452 -0
  20. package/build/pkg/protocol.js.map +1 -0
  21. package/build/test/display.js +382 -0
  22. package/build/test/display.js.map +1 -0
  23. package/build/tools/debug.js +133 -0
  24. package/build/tools/debug.js.map +1 -0
  25. package/build.zig +346 -0
  26. package/package.json +202 -0
  27. package/src/bin/install-pkmn-engine +391 -0
  28. package/src/bin/pkmn-debug +62 -0
  29. package/src/lib/binding/node.zig +229 -0
  30. package/src/lib/binding/wasm.zig +10 -0
  31. package/src/lib/common/data.zig +129 -0
  32. package/src/lib/common/debug.zig +64 -0
  33. package/src/lib/common/options.zig +40 -0
  34. package/src/lib/common/protocol.zig +1297 -0
  35. package/src/lib/common/rng.zig +234 -0
  36. package/src/lib/gen1/README.md +791 -0
  37. package/src/lib/gen1/data/moves.zig +1854 -0
  38. package/src/lib/gen1/data/species.zig +1105 -0
  39. package/src/lib/gen1/data/types.zig +131 -0
  40. package/src/lib/gen1/data.zig +620 -0
  41. package/src/lib/gen1/helpers.zig +234 -0
  42. package/src/lib/gen1/mechanics.zig +2819 -0
  43. package/src/lib/gen2/README.md +309 -0
  44. package/src/lib/gen2/data/items.zig +236 -0
  45. package/src/lib/gen2/data/moves.zig +2784 -0
  46. package/src/lib/gen2/data/species.zig +1798 -0
  47. package/src/lib/gen2/data/types.zig +123 -0
  48. package/src/lib/gen2/data.zig +425 -0
  49. package/src/lib/gen2/helpers.zig +225 -0
  50. package/src/lib/gen2/mechanics.zig +53 -0
  51. package/src/lib/pkmn.zig +54 -0
  52. package/src/test/display/pkmn.html.tmpl +368 -0
package/build.zig ADDED
@@ -0,0 +1,346 @@
1
+ const std = @import("std");
2
+ const builtin = @import("builtin");
3
+
4
+ pub const Options = struct { showdown: ?bool = null, trace: ?bool = null };
5
+
6
+ pub fn module(b: *std.Build, options: Options) *std.Build.Module {
7
+ const dirname = comptime std.fs.path.dirname(@src().file) orelse ".";
8
+ const build_options = b.addOptions();
9
+ build_options.addOption(?bool, "showdown", options.showdown);
10
+ build_options.addOption(?bool, "trace", options.trace);
11
+ return b.createModule(.{
12
+ .source_file = .{ .path = dirname ++ "/src/lib/pkmn.zig" },
13
+ .dependencies = &.{.{ .name = "build_options", .module = build_options.createModule() }},
14
+ });
15
+ }
16
+
17
+ pub fn build(b: *std.Build) !void {
18
+ const target = b.standardTargetOptions(.{});
19
+ const optimize = b.standardOptimizeOption(.{});
20
+
21
+ const node_headers = b.option([]const u8, "node-headers", "Path to node-headers");
22
+ const node_import_lib =
23
+ b.option([]const u8, "node-import-library", "Path to node import library (Windows)");
24
+ const wasm = b.option(bool, "wasm", "Build a WASM library") orelse false;
25
+ const wasm_stack_size =
26
+ b.option(u64, "wasm-stack-size", "The size of WASM stack") orelse std.wasm.page_size;
27
+ const dynamic = b.option(bool, "dynamic", "Build a dynamic library") orelse false;
28
+ const strip = b.option(bool, "strip", "Strip debugging symbols from binary") orelse false;
29
+ const pic = b.option(bool, "pic", "Force position independent code") orelse false;
30
+
31
+ const cmd = b.findProgram(&.{"strip"}, &.{}) catch null;
32
+
33
+ var parser = std.json.Parser.init(b.allocator, false);
34
+ defer parser.deinit();
35
+ var tree = try parser.parse(@embedFile("package.json"));
36
+ defer tree.deinit();
37
+ const version = tree.root.Object.get("version").?.String;
38
+ const description = tree.root.Object.get("description").?.String;
39
+ var repository = std.mem.split(u8, tree.root.Object.get("repository").?.String, ":");
40
+ std.debug.assert(std.mem.eql(u8, repository.first(), "github"));
41
+
42
+ const showdown =
43
+ b.option(bool, "showdown", "Enable Pokémon Showdown compatibility mode") orelse false;
44
+ const trace = b.option(bool, "trace", "Enable trace logs") orelse false;
45
+
46
+ const options = b.addOptions();
47
+ options.addOption(?bool, "showdown", showdown);
48
+ options.addOption(?bool, "trace", trace);
49
+
50
+ const name = if (showdown) "pkmn-showdown" else "pkmn";
51
+
52
+ var c = false;
53
+ if (node_headers) |headers| {
54
+ const addon = b.fmt("{s}.node", .{name});
55
+ const lib = b.addSharedLibrary(.{
56
+ .name = addon,
57
+ .root_source_file = .{ .path = "src/lib/binding/node.zig" },
58
+ .optimize = optimize,
59
+ .target = target,
60
+ });
61
+ lib.addOptions("build_options", options);
62
+ lib.setMainPkgPath("./");
63
+ lib.addSystemIncludePath(headers);
64
+ lib.linkLibC();
65
+ if (node_import_lib) |il| {
66
+ lib.addObjectFile(il);
67
+ } else if ((try std.zig.system.NativeTargetInfo.detect(target)).target.os.tag == .windows) {
68
+ try std.io.getStdErr().writeAll("Must provide --node-import-library path on Windows\n");
69
+ std.process.exit(1);
70
+ }
71
+ lib.linker_allow_shlib_undefined = true;
72
+ maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
73
+ if (pic) lib.force_pic = pic;
74
+ // Always emit to build/lib because this is where the driver code expects to find it
75
+ // TODO(ziglang/zig#2231): using the following used to work (though was hacky):
76
+ //
77
+ // lib.emit_bin = .{ .emit_to = b.fmt("build/lib/{s}", .{addon}) };
78
+ // b.getInstallStep().dependOn(&lib.step);
79
+ //
80
+ // But ziglang/zig#14647 broke this so we now need to do an install() and then manually
81
+ // rename the file ourself in install-pkmn-engine
82
+ lib.install();
83
+ } else if (wasm) {
84
+ const lib = b.addSharedLibrary(.{
85
+ .name = name,
86
+ .root_source_file = .{ .path = "src/lib/binding/wasm.zig" },
87
+ .optimize = switch (optimize) {
88
+ .ReleaseFast, .ReleaseSafe => .ReleaseSmall,
89
+ else => optimize,
90
+ },
91
+ .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
92
+ });
93
+ lib.addOptions("build_options", options);
94
+ lib.setMainPkgPath("./");
95
+ lib.stack_size = wasm_stack_size;
96
+ lib.rdynamic = true;
97
+ lib.strip = strip;
98
+ if (pic) lib.force_pic = pic;
99
+ const opt = b.findProgram(&.{"wasm-opt"}, &.{"./node_modules/.bin"}) catch null;
100
+ if (optimize != .Debug and opt != null) {
101
+ const out = b.fmt("build/lib/{s}.wasm", .{name});
102
+ const sh = b.addSystemCommand(&.{ opt.?, "-O4" });
103
+ sh.addArtifactArg(lib);
104
+ sh.addArg("-o");
105
+ sh.addFileSourceArg(.{ .path = out });
106
+ b.getInstallStep().dependOn(&sh.step);
107
+ }
108
+ lib.install();
109
+ } else if (dynamic) {
110
+ const lib = b.addSharedLibrary(.{
111
+ .name = name,
112
+ .root_source_file = .{ .path = "src/lib/binding/c.zig" },
113
+ .version = try std.builtin.Version.parse(version),
114
+ .optimize = optimize,
115
+ .target = target,
116
+ });
117
+ lib.addOptions("build_options", options);
118
+ lib.setMainPkgPath("./");
119
+ lib.addIncludePath("src/include");
120
+ maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
121
+ if (pic) lib.force_pic = pic;
122
+ lib.install();
123
+ c = true;
124
+ } else {
125
+ const lib = b.addStaticLibrary(.{
126
+ .name = name,
127
+ .root_source_file = .{ .path = "src/lib/binding/c.zig" },
128
+ .optimize = optimize,
129
+ .target = target,
130
+ });
131
+ lib.addOptions("build_options", options);
132
+ lib.setMainPkgPath("./");
133
+ lib.addIncludePath("src/include");
134
+ lib.bundle_compiler_rt = true;
135
+ maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
136
+ if (pic) lib.force_pic = pic;
137
+ lib.install();
138
+ c = true;
139
+ }
140
+
141
+ if (c) {
142
+ const header = b.addInstallFileWithDir(
143
+ .{ .path = "src/include/pkmn.h" },
144
+ .header,
145
+ "pkmn.h",
146
+ );
147
+ b.getInstallStep().dependOn(&header.step);
148
+
149
+ const pc = b.fmt("lib{s}.pc", .{name});
150
+ const file = try b.cache_root.join(b.allocator, &.{pc});
151
+ const pkgconfig_file = try std.fs.cwd().createFile(file, .{});
152
+
153
+ const dirname = comptime std.fs.path.dirname(@src().file) orelse ".";
154
+ const writer = pkgconfig_file.writer();
155
+ try writer.print(
156
+ \\prefix={0s}/{1s}
157
+ \\includedir=${{prefix}}/include
158
+ \\libdir=${{prefix}}/lib
159
+ \\
160
+ \\Name: lib{2s}
161
+ \\URL: https://github.com/{3s}
162
+ \\Description: {4s}
163
+ \\Version: {5s}
164
+ \\Cflags: -I${{includedir}}
165
+ \\Libs: -L${{libdir}} -l{2s}
166
+ , .{ dirname, b.install_path, name, repository.next().?, description, version });
167
+ defer pkgconfig_file.close();
168
+
169
+ b.installFile(file, b.fmt("share/pkgconfig/{s}", .{pc}));
170
+ }
171
+
172
+ const config = .{
173
+ .target = target,
174
+ .optimize = optimize,
175
+ .pic = pic,
176
+ .strip = strip,
177
+ .cmd = cmd,
178
+ };
179
+ const tests = TestStep.create(b, options, config);
180
+
181
+ var exes = std.ArrayList(*std.Build.CompileStep).init(b.allocator);
182
+ const tools: ToolConfig = .{
183
+ .general = config,
184
+ .tool = .{
185
+ .showdown = showdown,
186
+ .trace = trace,
187
+ .tests = if (tests.build) tests else null,
188
+ .exes = &exes,
189
+ },
190
+ };
191
+
192
+ var benchmark_config = tools;
193
+ benchmark_config.general.optimize = .ReleaseFast;
194
+ benchmark_config.general.strip = true;
195
+ const benchmark = tool(b, "src/test/benchmark.zig", benchmark_config);
196
+
197
+ var fuzz_config = tools;
198
+ fuzz_config.general.strip = false;
199
+ fuzz_config.tool.name = "fuzz";
200
+ const fuzz = tool(b, "src/test/benchmark.zig", fuzz_config);
201
+
202
+ const serde = tool(b, "src/tools/serde.zig", tools);
203
+ const protocol = tool(b, "src/tools/protocol.zig", tools);
204
+
205
+ const lint_exe =
206
+ b.addExecutable(.{ .name = "lint", .root_source_file = .{ .path = "src/tools/lint.zig" } });
207
+ if (tests.build) tests.step.dependOn(&lint_exe.step);
208
+ const lint = lint_exe.run();
209
+
210
+ b.step("benchmark", "Run benchmark code").dependOn(&benchmark.step);
211
+ b.step("fuzz", "Run fuzz tester").dependOn(&fuzz.step);
212
+ b.step("lint", "Lint source files").dependOn(&lint.step);
213
+ b.step("protocol", "Run protocol dump tool").dependOn(&protocol.step);
214
+ b.step("serde", "Run serialization/deserialization tool").dependOn(&serde.step);
215
+ b.step("test", "Run all tests").dependOn(&tests.step);
216
+ b.step("tools", "Install tools").dependOn(&ToolsStep.create(b, &exes).step);
217
+ }
218
+
219
+ fn maybeStrip(
220
+ b: *std.Build,
221
+ artifact: *std.Build.CompileStep,
222
+ step: *std.Build.Step,
223
+ strip: bool,
224
+ cmd: ?[]const u8,
225
+ ) void {
226
+ artifact.strip = strip;
227
+ if (!strip or cmd == null) return;
228
+ // Using `strip -r -u` for dynamic libraries is supposed to work on macOS but doesn't...
229
+ const mac = builtin.os.tag == .macos;
230
+ if (mac and artifact.isDynamicLibrary()) return;
231
+ // Assuming GNU strip, which complains "illegal pathname found in archive member"...
232
+ if (!mac and artifact.isStaticLibrary()) return;
233
+ const sh = b.addSystemCommand(&.{ cmd.?, if (mac) "-x" else "-s" });
234
+ sh.addArtifactArg(artifact);
235
+ step.dependOn(&sh.step);
236
+ }
237
+
238
+ const Config = struct {
239
+ target: std.zig.CrossTarget,
240
+ optimize: std.builtin.OptimizeMode,
241
+ pic: bool,
242
+ strip: bool,
243
+ cmd: ?[]const u8,
244
+ };
245
+
246
+ const TESTS = .{
247
+ "src/lib/common/test.zig",
248
+ "src/lib/gen1/test.zig",
249
+ "src/lib/gen2/test.zig",
250
+ };
251
+
252
+ const TestStep = struct {
253
+ step: std.Build.Step,
254
+ build: bool,
255
+
256
+ pub fn create(b: *std.Build, options: *std.Build.OptionsStep, config: Config) *TestStep {
257
+ const coverage = b.option([]const u8, "test-coverage", "Generate test coverage");
258
+ const test_file = b.option([]const u8, "test-file", "Input file for test");
259
+ const test_bin = b.option([]const u8, "test-bin", "Emit test binary to");
260
+ const test_filter =
261
+ b.option([]const u8, "test-filter", "Skip tests that do not match filter");
262
+ const test_no_exec =
263
+ b.option(bool, "test-no-exec", "Compiles test binary without running it") orelse false;
264
+
265
+ const self = b.allocator.create(TestStep) catch @panic("OOM");
266
+ const step = std.Build.Step.init(.{ .id = .custom, .name = "Run all tests", .owner = b });
267
+ self.* = TestStep{ .step = step, .build = test_filter == null };
268
+
269
+ const paths: []const []const u8 =
270
+ if (test_file) |t| &.{t} else if (coverage != null) &.{"src/lib/test.zig"} else &TESTS;
271
+ for (paths) |path| {
272
+ const tests = b.addTest(.{
273
+ .name = std.fs.path.basename(std.fs.path.dirname(path).?),
274
+ .root_source_file = .{ .path = path },
275
+ .optimize = config.optimize,
276
+ .target = config.target,
277
+ });
278
+ tests.setMainPkgPath("./");
279
+ tests.setFilter(test_filter);
280
+ tests.addOptions("build_options", options);
281
+ tests.single_threaded = true;
282
+ maybeStrip(b, tests, &tests.step, config.strip, config.cmd);
283
+ if (config.pic) tests.force_pic = config.pic;
284
+ if (test_bin) |bin| {
285
+ tests.name = std.fs.path.basename(bin);
286
+ if (std.fs.path.dirname(bin)) |dir| tests.setOutputDir(dir);
287
+ }
288
+ if (coverage) |c| {
289
+ tests.setExecCmd(&.{ "kcov", "--include-pattern=src/lib", c, null });
290
+ }
291
+ self.step.dependOn(if (test_no_exec) &tests.step else &tests.run().step);
292
+ }
293
+ return self;
294
+ }
295
+ };
296
+
297
+ const ToolConfig = struct {
298
+ general: Config,
299
+ tool: struct {
300
+ showdown: bool,
301
+ trace: bool,
302
+ tests: ?*TestStep,
303
+ name: ?[]const u8 = null,
304
+ exes: *std.ArrayList(*std.Build.CompileStep),
305
+ },
306
+ };
307
+
308
+ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) *std.Build.RunStep {
309
+ var name = config.tool.name orelse std.fs.path.basename(path);
310
+ const index = std.mem.lastIndexOfScalar(u8, name, '.');
311
+ if (index) |i| name = name[0..i];
312
+ if (config.tool.showdown) name = b.fmt("{s}-showdown", .{name});
313
+
314
+ const exe = b.addExecutable(.{
315
+ .name = name,
316
+ .root_source_file = .{ .path = path },
317
+ .target = config.general.target,
318
+ .optimize = config.general.optimize,
319
+ });
320
+ exe.addModule("pkmn", module(b, .{
321
+ .showdown = config.tool.showdown,
322
+ .trace = config.tool.trace,
323
+ }));
324
+ exe.single_threaded = true;
325
+ if (config.general.pic) exe.force_pic = config.general.pic;
326
+ if (config.tool.tests) |ts| ts.step.dependOn(&exe.step);
327
+ config.tool.exes.append(exe) catch @panic("OOM");
328
+
329
+ const run = exe.run();
330
+ maybeStrip(b, exe, &run.step, config.general.strip, config.general.cmd);
331
+ if (b.args) |args| run.addArgs(args);
332
+
333
+ return run;
334
+ }
335
+
336
+ const ToolsStep = struct {
337
+ step: std.Build.Step,
338
+
339
+ pub fn create(b: *std.Build, exes: *std.ArrayList(*std.Build.CompileStep)) *ToolsStep {
340
+ const self = b.allocator.create(ToolsStep) catch @panic("OOM");
341
+ const step = std.Build.Step.init(.{ .id = .custom, .name = "Install tools", .owner = b });
342
+ self.* = ToolsStep{ .step = step };
343
+ for (exes.items) |t| self.step.dependOn(&b.addInstallArtifact(t).step);
344
+ return self;
345
+ }
346
+ };
package/package.json ADDED
@@ -0,0 +1,202 @@
1
+ {
2
+ "name": "@pkmn/engine",
3
+ "version": "0.1.0-dev.02b7f810",
4
+ "description": "A minimal, complete, Pokémon battle simulation engine optimized for performance",
5
+ "repository": "github:pkmn/engine",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "main": "build/pkg/index.js",
9
+ "types": "build/pkg/index.d.ts",
10
+ "files": [
11
+ "build.zig",
12
+ "build/pkg/data.d.ts",
13
+ "build/pkg/data.js.map",
14
+ "build/pkg/addon.d.ts",
15
+ "build/pkg/addon.js.map",
16
+ "build/pkg/addon.js",
17
+ "build/pkg/data.js",
18
+ "build/pkg/data/ids.json",
19
+ "build/pkg/data/layout.json",
20
+ "build/pkg/data/protocol.json",
21
+ "build/pkg/gen1.d.ts",
22
+ "build/pkg/gen1.js.map",
23
+ "build/pkg/gen1.js",
24
+ "build/pkg/index.d.ts",
25
+ "build/pkg/index.js.map",
26
+ "build/pkg/index.js",
27
+ "build/pkg/protocol.d.ts",
28
+ "build/pkg/protocol.js.map",
29
+ "build/pkg/protocol.js",
30
+ "build/test/display.js.map",
31
+ "build/test/display.js",
32
+ "build/tools/debug.js.map",
33
+ "build/tools/debug.js",
34
+ "src/bin/install-pkmn-engine",
35
+ "src/lib/binding/node.zig",
36
+ "src/lib/binding/wasm.zig",
37
+ "src/lib/common/data.zig",
38
+ "src/lib/common/debug.zig",
39
+ "src/lib/common/options.zig",
40
+ "src/lib/common/protocol.zig",
41
+ "src/lib/common/rng.zig",
42
+ "src/lib/gen1/data.zig",
43
+ "src/lib/gen1/data/moves.zig",
44
+ "src/lib/gen1/data/species.zig",
45
+ "src/lib/gen1/data/types.zig",
46
+ "src/lib/gen1/helpers.zig",
47
+ "src/lib/gen1/mechanics.zig",
48
+ "src/lib/gen2/data.zig",
49
+ "src/lib/gen2/data/items.zig",
50
+ "src/lib/gen2/data/moves.zig",
51
+ "src/lib/gen2/data/species.zig",
52
+ "src/lib/gen2/data/types.zig",
53
+ "src/lib/gen2/helpers.zig",
54
+ "src/lib/gen2/mechanics.zig",
55
+ "src/lib/pkmn.zig",
56
+ "src/test/display/pkmn.html.tmpl"
57
+ ],
58
+ "engines": {
59
+ "node": ">=16.0.0"
60
+ },
61
+ "bin": {
62
+ "install-pkmn-engine": "src/bin/install-pkmn-engine",
63
+ "pkmn-debug": "src/bin/pkmn-debug"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "dependencies": {
69
+ "@pkmn/data": "^0.7.36",
70
+ "@pkmn/protocol": "^0.6.11"
71
+ },
72
+ "devDependencies": {
73
+ "@pkmn/eslint-config": "^3.0.0",
74
+ "@pkmn/img": "^0.2.8",
75
+ "@pkmn/sets": "^5.0.4",
76
+ "@pkmn/sim": "0.7.36",
77
+ "@types/html-minifier": "^4.0.2",
78
+ "@types/jest": "^29.5.0",
79
+ "@types/minimist": "^1.2.2",
80
+ "@types/mustache": "^4.2.2",
81
+ "@types/node": "^18.15.11",
82
+ "@vitest/coverage-c8": "^0.29.8",
83
+ "binaryen": "^112.0.0",
84
+ "eslint": "^8.37.0",
85
+ "html-minifier": "^4.0.0",
86
+ "json-stringify-pretty-compact": "3.0.0",
87
+ "minimist": "^1.2.8",
88
+ "mustache": "^4.2.0",
89
+ "source-map-support": "^0.5.21",
90
+ "trakr": "^0.2.0",
91
+ "typescript": "^5.0.3",
92
+ "vitest": "^0.29.8"
93
+ },
94
+ "scripts": {
95
+ "lint": "eslint --cache src --ext ts,js && eslint src/bin/*",
96
+ "fix": "eslint --fix src --ext ts,js && eslint --fix src/bin/*",
97
+ "compile": "tsc -p .",
98
+ "build": "npm run compile",
99
+ "test": "vitest src/pkg",
100
+ "test:integration": "vitest src/test",
101
+ "debug": "npm run compile && node build/tools/debug",
102
+ "fuzz": "npm run compile && node build/test/fuzz",
103
+ "generate": "npm run compile && node build/tools/generate",
104
+ "release": "npm run compile && node build/tools/release",
105
+ "benchmark": "npm run compile && node build/test/benchmark",
106
+ "integration": "npm run compile && node build/test/integration",
107
+ "postinstall": "node src/bin/install-pkmn-engine"
108
+ },
109
+ "eslintConfig": {
110
+ "extends": "@pkmn",
111
+ "ignorePatterns": [
112
+ "dist/",
113
+ "node_modules/",
114
+ "src/examples/zig",
115
+ "build/"
116
+ ],
117
+ "env": {
118
+ "es6": true,
119
+ "node": true,
120
+ "browser": true
121
+ },
122
+ "overrides": [
123
+ {
124
+ "files": [
125
+ "**/*.ts"
126
+ ],
127
+ "parserOptions": {
128
+ "project": [
129
+ "./tsconfig.json",
130
+ "./src/examples/js/tsconfig.json"
131
+ ]
132
+ }
133
+ },
134
+ {
135
+ "files": [
136
+ "src/pkg/index.ts",
137
+ "src/test/display.ts",
138
+ "src/test/integration.ts"
139
+ ],
140
+ "rules": {
141
+ "no-control-regex": "off",
142
+ "@typescript-eslint/no-empty-interface": "off",
143
+ "@typescript-eslint/no-shadow": "off"
144
+ }
145
+ },
146
+ {
147
+ "files": [
148
+ "src/pkg/addon.ts"
149
+ ],
150
+ "rules": {
151
+ "@typescript-eslint/no-var-requires": "off"
152
+ }
153
+ },
154
+ {
155
+ "files": [
156
+ "src/test/benchmark*.ts"
157
+ ],
158
+ "rules": {
159
+ "@typescript-eslint/no-unused-vars": "off"
160
+ }
161
+ },
162
+ {
163
+ "files": [
164
+ "src/test/*.test.ts"
165
+ ],
166
+ "rules": {
167
+ "jest/no-standalone-expect": "off"
168
+ }
169
+ },
170
+ {
171
+ "files": [
172
+ "src/test/showdown/**"
173
+ ],
174
+ "rules": {
175
+ "jest/expect-expect": [
176
+ "warn",
177
+ {
178
+ "assertFunctionNames": [
179
+ "expect",
180
+ "expectLog",
181
+ "verify"
182
+ ]
183
+ }
184
+ ]
185
+ }
186
+ },
187
+ {
188
+ "files": [
189
+ "src/tools/generate.ts"
190
+ ],
191
+ "rules": {
192
+ "@typescript-eslint/restrict-template-expressions": [
193
+ "error",
194
+ {
195
+ "allowBoolean": true
196
+ }
197
+ ]
198
+ }
199
+ }
200
+ ]
201
+ }
202
+ }