Skip to content

Commit 0fde13a

Browse files
committed
*: bump eslint
1 parent 06eddc9 commit 0fde13a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1311
-1046
lines changed

.github/workflows/lint-test-build.yml

Lines changed: 8 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ jobs:
1818
key: datasets-${{ hashFiles('datasets/**') }}
1919
- run: datasets/populate
2020

21-
lint-lib:
21+
lint-most:
22+
needs: [build-cli, build-lib, build-lib-node, build-lib-web, build-server, build-webapp]
2223
runs-on: ubuntu-latest
2324
steps:
2425
- uses: actions/checkout@v4
@@ -32,97 +33,8 @@ jobs:
3233
~/.cache/Cypress
3334
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
3435
- run: npm ci
35-
- run: npm --workspace=discojs run lint
36-
37-
lint-lib-node:
38-
needs: build-lib
39-
runs-on: ubuntu-latest
40-
steps:
41-
- uses: actions/checkout@v4
42-
- uses: actions/setup-node@v4
43-
with:
44-
node-version-file: .nvmrc
45-
- uses: actions/cache@v4
46-
with:
47-
path: |
48-
~/.npm
49-
~/.cache/Cypress
50-
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
51-
- run: npm ci
52-
- run: npm --workspace=discojs run build
53-
- run: npm --workspace=discojs-node run lint
54-
55-
lint-lib-web:
56-
needs: build-lib
57-
runs-on: ubuntu-latest
58-
steps:
59-
- uses: actions/checkout@v4
60-
- uses: actions/setup-node@v4
61-
with:
62-
node-version-file: .nvmrc
63-
- uses: actions/cache@v4
64-
with:
65-
path: |
66-
~/.npm
67-
~/.cache/Cypress
68-
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
69-
- run: npm ci
70-
- run: npm --workspace=discojs run build
71-
- run: npm --workspace=discojs-web run lint
72-
73-
lint-server:
74-
needs: [build-lib, build-lib-node]
75-
runs-on: ubuntu-latest
76-
steps:
77-
- uses: actions/checkout@v4
78-
- uses: actions/setup-node@v4
79-
with:
80-
node-version-file: .nvmrc
81-
- uses: actions/cache@v4
82-
with:
83-
path: |
84-
~/.npm
85-
~/.cache/Cypress
86-
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
87-
- run: npm ci
88-
- run: npm --workspace={discojs,discojs-node} run build
89-
- run: npm --workspace=server run lint
90-
91-
lint-cli:
92-
needs: [build-lib, build-lib-node, build-server]
93-
runs-on: ubuntu-latest
94-
steps:
95-
- uses: actions/checkout@v4
96-
- uses: actions/setup-node@v4
97-
with:
98-
node-version-file: .nvmrc
99-
- uses: actions/cache@v4
100-
with:
101-
path: |
102-
~/.npm
103-
~/.cache/Cypress
104-
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
105-
- run: npm ci
106-
- run: npm --workspace={discojs,discojs-node,server} run build
107-
- run: npm --workspace=cli run lint
108-
109-
lint-webapp:
110-
needs: [build-lib, build-lib-web]
111-
runs-on: ubuntu-latest
112-
steps:
113-
- uses: actions/checkout@v4
114-
- uses: actions/setup-node@v4
115-
with:
116-
node-version-file: .nvmrc
117-
- uses: actions/cache@v4
118-
with:
119-
path: |
120-
~/.npm
121-
~/.cache/Cypress
122-
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
123-
- run: npm ci
124-
- run: npm --workspace={discojs,discojs-web} run build
125-
- run: npm --workspace=webapp run lint
36+
- run: npm --workspaces run build
37+
- run: npm run lint
12638

12739
lint-docs-examples:
12840
needs: [build-lib, build-lib-node, build-server]
@@ -283,73 +195,8 @@ jobs:
283195
- run: npm run build
284196
working-directory: docs/examples
285197

286-
test-lib:
287-
needs: [build-lib, download-datasets]
288-
runs-on: ubuntu-latest
289-
steps:
290-
- uses: actions/checkout@v4
291-
- uses: actions/cache@v4
292-
with:
293-
path: datasets
294-
key: datasets-${{ hashFiles('datasets/**') }}
295-
- uses: actions/setup-node@v4
296-
with:
297-
node-version-file: .nvmrc
298-
- uses: actions/cache@v4
299-
with:
300-
path: |
301-
~/.npm
302-
~/.cache/Cypress
303-
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
304-
- run: npm ci
305-
- run: npm --workspace=discojs test
306-
307-
test-lib-node:
308-
needs: [build-lib, download-datasets]
309-
runs-on: ubuntu-latest
310-
steps:
311-
- uses: actions/checkout@v4
312-
- uses: actions/cache@v4
313-
with:
314-
path: datasets
315-
key: datasets-${{ hashFiles('datasets/**') }}
316-
- uses: actions/setup-node@v4
317-
with:
318-
node-version-file: .nvmrc
319-
- uses: actions/cache@v4
320-
with:
321-
path: |
322-
~/.npm
323-
~/.cache/Cypress
324-
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
325-
- run: npm ci
326-
- run: npm --workspace=discojs run build
327-
- run: npm --workspace=discojs-node test
328-
329-
test-lib-web:
330-
needs: [build-lib]
331-
runs-on: ubuntu-latest
332-
steps:
333-
- uses: actions/checkout@v4
334-
- uses: actions/cache@v4
335-
with:
336-
path: datasets
337-
key: datasets-${{ hashFiles('datasets/**') }}
338-
- uses: actions/setup-node@v4
339-
with:
340-
node-version-file: .nvmrc
341-
- uses: actions/cache@v4
342-
with:
343-
path: |
344-
~/.npm
345-
~/.cache/Cypress
346-
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
347-
- run: npm ci
348-
- run: npm --workspace=discojs run build
349-
- run: npm --workspace=discojs-web test
350-
351-
test-server:
352-
needs: [build-lib, build-lib-node, download-datasets]
198+
test-most:
199+
needs: [build-lib, build-lib-node, build-lib-web, build-server, download-datasets]
353200
runs-on: ubuntu-latest
354201
steps:
355202
- uses: actions/checkout@v4
@@ -367,8 +214,8 @@ jobs:
367214
~/.cache/Cypress
368215
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
369216
- run: npm ci
370-
- run: npm --workspace={discojs,discojs-node} run build
371-
- run: npm --workspace=server test
217+
- run: npm --workspace={discojs,discojs-{node,web},server} run build
218+
- run: npx vitest --run
372219

373220
test-webapp:
374221
needs: [build-lib, build-lib-web, download-datasets]

cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"train_gpt": "npm run build && node dist/train_gpt.js",
1111
"hellaswag_gpt": "npm run build && node dist/hellaswag_gpt.js",
1212
"build": "tsc --build",
13-
"lint": "eslint .",
1413
"test": ": nothing"
1514
},
1615
"author": "",

discojs-node/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"scripts": {
88
"watch": "nodemon --ext ts --ignore dist --watch ../discojs/dist --watch . --exec npm run",
99
"build": "tsc --build",
10-
"lint": "eslint .",
1110
"test": "cd .. && vitest --run --project=discojs-node"
1211
},
1312
"repository": {

discojs-web/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"scripts": {
88
"watch": "nodemon --ext ts --ignore dist --watch ../discojs/dist --watch . --exec npm run",
99
"build": "tsc --build",
10-
"lint": "eslint .",
1110
"test": "cd .. && vitest --run --project=discojs-web"
1211
},
1312
"repository": {

discojs-web/src/loaders/csv.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export function load(file: File): Dataset<Partial<Record<string, string>>> {
2424
skipEmptyLines: true, // TODO needed to avoid parsing last empty line
2525
complete(results) {
2626
if (results.errors.length > 0) {
27-
reject(results.errors);
27+
const error = results.errors[0]
28+
reject(new Error(error.message));
2829
return;
2930
}
3031

discojs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"scripts": {
88
"watch": "nodemon --ext ts --ignore dist --exec npm run",
99
"build": "tsc --build",
10-
"lint": "eslint .",
1110
"test": "cd .. && vitest --run --project=discojs"
1211
},
1312
"repository": {

discojs/src/client/event_connection.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import createDebug from "debug";
22
import WebSocket from "isomorphic-ws";
33
import * as msgpack from "@msgpack/msgpack";
4-
54
import type { Peer, SignalData } from './decentralized/peer.js'
6-
import { type NodeID } from './types.js'
5+
import type { NodeID } from './types.js'
76
import * as decentralizedMessages from './decentralized/messages.js'
87
import { type, type NarrowMessage, type Message } from './messages.js'
98
import { timeout } from './utils.js'
@@ -130,7 +129,7 @@ export class WebSocketServer extends EventEmitter<{ [K in type]: NarrowMessage<K
130129
disconnect(): Promise<void> {
131130
return new Promise((resolve, reject) => {
132131
this.socket.onclose = () => resolve()
133-
this.socket.onerror = (e) => reject(e.message)
132+
this.socket.onerror = (e) => reject(new Error(e.message))
134133
this.socket.close()
135134
})
136135
}

discojs/src/dataset/dataset.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe("dataset", () => {
169169
expect(sequences.last()?.size).to.equal(contextLength + 1)
170170
sequences = sequences.pop()
171171
let i = 0
172-
for await (const tokens of sequences) {
172+
for (const tokens of sequences) {
173173
// each sequence has length contextLength + 1 (for the label)
174174
expect(tokens.toArray()).to.deep.equal(
175175
expectedTokens.slice(i, i + contextLength + 1).toArray()

discojs/src/serialization/model.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ describe('serialization', () => {
6565
await getRawWeights(model),
6666
await getRawWeights(decoded)
6767
)
68-
assert.deepEqual(
69-
model.config,
70-
(decoded as models.GPT).config
71-
)
68+
assert.deepEqual(model.config, decoded.config);
7269
})
7370
})

discojs/src/utils/async_iterator.spec.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
3-
import { split, gather } from "./async_iterator.js";
2+
import { gather, split } from "./async_iterator.js";
43

54
// Array.fromAsync not yet widely used (2024)
65
async function arrayFromAsync<T>(iter: AsyncIterable<T>): Promise<T[]> {
@@ -40,24 +39,16 @@ describe("split", () => {
4039

4140
it("throws returned when iterator throws", async () => {
4241
const [gen, ret] = split(
43-
// eslint-disable-next-line require-yield, @typescript-eslint/require-await
44-
(async function* () {
42+
(
43+
// eslint-disable-next-line @typescript-eslint/require-await
44+
async function* () {
4545
throw new Error();
4646
})(),
4747
);
4848

49-
try {
49+
await expect(async () => {
5050
for await (const _ of gen);
51-
} catch {
52-
// expected
53-
}
54-
55-
try {
56-
await ret;
57-
} catch {
58-
return; // all good
59-
}
60-
61-
expect(false, "should have thrown").to.be.true;
51+
}).rejects.toThrow();
52+
await expect(ret).rejects.toThrow();
6253
});
6354
});

0 commit comments

Comments
 (0)