Skip to content

Commit c05db7a

Browse files
committed
chore: conform to eslint rules
1 parent 7ffd841 commit c05db7a

File tree

18 files changed

+257
-474
lines changed

18 files changed

+257
-474
lines changed

assembly/serialize/swar/string.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { bs, sc } from "../../../lib/as-bs";
22
import { BACK_SLASH } from "../../custom/chars";
33
import { SERIALIZE_ESCAPE_TABLE } from "../../globals/tables";
44
import { OBJECT, TOTAL_OVERHEAD } from "rt/common";
5-
import { mask_to_string } from "../../util/masks";
65

76
// @ts-expect-error: @lazy is a valid decorator
87
@lazy const U00_MARKER = 13511005048209500;

bench/runners/assemblyscript.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// @ts-expect-error: readbuffer is defined in d8
2+
// @eslint-disable-next-line
13
const bytes = readbuffer("./build/" + arguments[0]);
4+
25
const module = new WebAssembly.Module(bytes);
36
let memory = null;
47
const { exports } = new WebAssembly.Instance(module, {
@@ -11,11 +14,11 @@ const { exports } = new WebAssembly.Instance(module, {
1114
},
1215
"Date.now": () => Date.now(),
1316
"performance.now": () => performance.now(),
14-
"writeFile": (fileName, data) => {
15-
fileName = __liftString(fileName)
17+
writeFile: (fileName, data) => {
18+
fileName = __liftString(fileName);
1619
data = __liftString(data);
1720
writeFile(fileName, data);
18-
}
21+
},
1922
},
2023
});
2124

@@ -31,4 +34,4 @@ function __liftString(pointer) {
3134
return string + String.fromCharCode(...memoryU16.subarray(start, end));
3235
}
3336

34-
exports.start();
37+
exports.start();
Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,15 @@
11
import { bench, blackbox, dumpToFile } from "../lib/bench";
22

3-
class ObjLarge {
4-
lorum: number = 4294967296;
5-
ipsum: boolean = true;
6-
dolor: Array<number> = [1, 2, 3, 4, 5];
7-
sit: string = "abcdefghijklmnopdasfqrstfuvwYZ1234567890;~!@#$%^&*()_+=-{}][\\|;\":'<>,./?";
8-
consectetur: number = 123456;
9-
adipiscing: boolean = false;
10-
elit: Array<number> = [6, 7, 8, 9, 10];
11-
sed: number = Number.MAX_VALUE;
12-
eiusmod: string = "abcdYZ12345890./?abcdYZ12345890./?abcdYZ12340./?";
13-
tempor: number = 999999;
14-
incididunt: boolean = true;
15-
ut: Array<number> = [16, 17, 18, 19, 20];
16-
labore: number = 3.1415926535;
17-
et: string = "xyzXYZ09876!@#";
18-
dolore: number = -123456;
19-
magna: boolean = false;
20-
aliqua: Array<number> = [21, 22, 23, 24, 25];
21-
argw: string = "abcdYZ12345890sdfw\"vie91kfESDFOK12i9i12dsf./?";
22-
}
23-
24-
const obj = new ObjLarge();
25-
263
const objStr = `{"lorum":4294967295,"ipsum":true,"dolor":[1,2,3,4,5],"sit":"abcdefghijklmnopdasfqrstfuvwYZ1234567890;~!@#$%^&*()_+=-{}][\\\\|;\\":'<>,./?","consectetur":123456,"adipiscing":false,"elit":[6,7,8,9,10],"sed":1.7976931348623157e+308,"eiusmod":"abcdYZ12345890./?abcdYZ12345890./?abcdYZ12340./?","tempor":999999,"incididunt":true,"ut":[16,17,18,19,20],"labore":3.1415926535,"et":"xyzXYZ09876!@#","dolore":-123456,"magna":false,"aliqua":[21,22,23,24,25],"argw":"abcdYZ12345890sdfw\\"vie91kfESDFOK12i9i12dsf./?"}`;
274

285
bench("Deserialize Small Object (1kb)", () => {
29-
// @ts-ignore
306
blackbox(JSON.parse(objStr));
317
}, 2_500_000, objStr.length << 1);
328
dumpToFile("small-obj", "deserialize");
339

3410
bench("Deserialize Medium Object (500kb)", () => {
3511
let ops = 500;
3612
while (ops > 0) {
37-
// @ts-ignore
3813
blackbox(JSON.parse(objStr));
3914
ops--;
4015
}
@@ -44,9 +19,8 @@ dumpToFile("medium-obj", "deserialize");
4419
bench("Deserialize Large Object (1000kb)", () => {
4520
let ops = 1000;
4621
while (ops > 0) {
47-
// @ts-ignore
4822
blackbox(JSON.parse(objStr));
4923
ops--;
5024
}
5125
}, 500, (objStr.length << 1) * 1000);
52-
dumpToFile("large-obj", "deserialize");
26+
dumpToFile("large-obj", "deserialize");

bug.mjs

Lines changed: 0 additions & 213 deletions
This file was deleted.

eslint.config.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
import js from "@eslint/js";
2+
import { defineConfig, globalIgnores } from "eslint/config";
23
import tseslint from "typescript-eslint";
4+
import globals from "globals";
35

4-
export default tseslint.config(
5-
{
6-
ignores: [
7-
"**/node_modules/**",
8-
"**/build/**",
9-
"**/lib/**",
10-
"**/dist/**",
11-
"**/*.wasm",
12-
"**/*.wat",
13-
"assembly/**",
14-
],
15-
},
6+
export default defineConfig(
7+
globalIgnores(["**/node_modules/**", "**/build/**", "**/lib/**", "**/dist/**", "**/*.wasm", "**/*.wat", "assembly/**"]),
168

179
js.configs.recommended,
1810

19-
...tseslint.configs.recommended,
11+
tseslint.configs.recommended,
2012

2113
{
2214
files: ["transform/src/**/*.ts"],
@@ -45,6 +37,11 @@ export default tseslint.config(
4537

4638
{
4739
files: ["**/*.js", "**/*.mjs"],
40+
languageOptions: {
41+
globals: {
42+
...globals.node,
43+
},
44+
},
4845
rules: {
4946
"no-unused-vars": [
5047
"error",
@@ -56,6 +53,21 @@ export default tseslint.config(
5653
},
5754
},
5855

56+
{
57+
files: ["bench/runners/**/*.js"],
58+
languageOptions: {
59+
globals: {
60+
readbuffer: "readonly",
61+
writeFile: "readonly",
62+
arguments: "readonly",
63+
...globals.browser,
64+
},
65+
},
66+
rules: {
67+
"no-console": "off",
68+
},
69+
},
70+
5971
{
6072
files: ["bench/**/*.js"],
6173
rules: {

lib/as-bs.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export namespace bs {
106106
/**
107107
* Proposes that the buffer size is should be greater than or equal to the proposed size.
108108
* If necessary, reallocates the buffer to the exact new size.
109-
* @param size - The size to propose.
109+
* @param size - The size to propose.w
110110
*/
111111
// @ts-expect-error: @inline is a valid decorator
112112
@inline export function proposeSize(size: u32): void {
@@ -143,12 +143,12 @@ export namespace bs {
143143
*/
144144
// @ts-expect-error: @inline is a valid decorator
145145
@inline export function resize(newSize: u32): void {
146-
// @ts-expect-error: __renew is a runtime builtin
147-
const newPtr = changetype<ArrayBuffer>(__renew(changetype<usize>(buffer), newSize));
148-
bufferSize = newSize;
149-
offset = changetype<usize>(newPtr);
150-
buffer = newPtr;
151-
stackSize = 0;
146+
// @ts-expect-error: __renew is a runtime builtin
147+
const newPtr = changetype<ArrayBuffer>(__renew(changetype<usize>(buffer), newSize));
148+
bufferSize = newSize;
149+
offset = changetype<usize>(newPtr);
150+
buffer = newPtr;
151+
stackSize = 0;
152152
}
153153

154154
/**

0 commit comments

Comments
 (0)