Skip to content

Commit 5023711

Browse files
authored
Merge pull request #15 from jsonjoy-com/linter
Linter
2 parents 36c3132 + 154cd4f commit 5023711

Some content is hidden

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

50 files changed

+211
-126
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"scripts": {
4242
"prettier": "prettier --ignore-path .gitignore --write \"src/**/*.{ts,tsx,js,jsx}\"",
4343
"prettier:check": "prettier --ignore-path .gitignore --list-different 'src/**/*.{ts,tsx,js,jsx}'",
44-
"lint": "yarn tslint",
45-
"tslint": "tslint 'src/**/*.{js,jsx,ts,tsx}' -t verbose --project .",
44+
"lint": "oxlint ./src/",
45+
"lint:fix": "oxlint ./src/ --fix --fix-suggestions",
4646
"clean": "rimraf lib typedocs coverage gh-pages yarn-error.log db dist",
4747
"build": "tsc --project tsconfig.build.json --module commonjs --target es2020 --outDir lib",
4848
"jest": "node -r ts-node/register ./node_modules/.bin/jest",
@@ -107,6 +107,7 @@
107107
"jest": "^29.7.0",
108108
"nano-theme": "^1.4.2",
109109
"nice-ui": "^1.9.2",
110+
"oxlint": "^0.9.9",
110111
"prettier": "^3.2.5",
111112
"react": "^18.3.1",
112113
"react-dom": "^18.3.1",

src/__tests__/e2e/demo-client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export const setupDemoServerStreamingClient = (codec: RpcCodec) => {
4444
const contentType = 'application/x.' + protocolSpecifier;
4545
const client = new StreamingRpcClient({
4646
send: async (messages) => {
47-
const port = +(process.env.PORT || 9999);
4847
const url = `http${secure ? 's' : ''}://${host}/rpc`;
4948
codec.req.encoder.writer.reset();
5049
codec.msg.encodeBatch(codec.req, messages);

src/__tests__/e2e/json-crdt-server/clients.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (process.env.TEST_E2E) {
2525
for (const codec of list) {
2626
const setup: ApiTestSetup = async () => setupFetchRpcClient(codec);
2727
describe(`protocol: application/x.${codec.specifier()}`, () => {
28-
runUtilTests(setup, {staticOnly: true});
28+
runUtilTests(setup);
2929
runPubsubTests(setup, {staticOnly: true});
3030
runPresenceTests(setup, {staticOnly: true});
3131
runBlockTests(setup, {staticOnly: true});
@@ -39,7 +39,7 @@ if (process.env.TEST_E2E) {
3939
for (const codec of list) {
4040
const setup: ApiTestSetup = async () => setupStreamingRpcClient(codec);
4141
describe(`protocol: application/x.${codec.specifier()}`, () => {
42-
runUtilTests(setup, {staticOnly: true});
42+
runUtilTests(setup);
4343
runPubsubTests(setup, {staticOnly: true});
4444
runPresenceTests(setup, {staticOnly: true});
4545
runBlockTests(setup, {staticOnly: true});

src/__tests__/e2e/json-crdt-server/demo-server.spec.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@ if (process.env.TEST_E2E && process.env.TEST_E2E_DEMO_SERVER) {
2222
});
2323
});
2424

25-
// describe('FetchRpcClient', () => {
26-
// const codec = cborCodec();
27-
// const setup: ApiTestSetup = async () => setupDemoServerFetchClient(codec);
28-
// describe(`protocol: application/x.${codec.specifier()}`, () => {
29-
// runUtilTests(setup, {staticOnly: true});
30-
// runPubsubTests(setup, {staticOnly: true});
31-
// runPresenceTests(setup, {staticOnly: true});
32-
// runBlockTests(setup, {staticOnly: true});
33-
// });
34-
// });
25+
describe('FetchRpcClient', () => {
26+
const codec = cborCodec();
27+
const setup: ApiTestSetup = async () => setupDemoServerFetchClient(codec);
28+
describe(`protocol: application/x.${codec.specifier()}`, () => {
29+
runUtilTests(setup);
30+
runPubsubTests(setup, {staticOnly: true});
31+
runPresenceTests(setup, {staticOnly: true});
32+
runBlockTests(setup, {staticOnly: true});
33+
});
34+
});
3535

36-
// describe('StreamingRpcClient', () => {
37-
// const codec = cborCodec();
38-
// const setup: ApiTestSetup = async () => setupDemoServerStreamingClient(codec);
39-
// describe(`protocol: application/x.${codec.specifier()}`, () => {
40-
// runUtilTests(setup, {staticOnly: true});
41-
// runPubsubTests(setup, {staticOnly: true});
42-
// runPresenceTests(setup, {staticOnly: true});
43-
// runBlockTests(setup, {staticOnly: true});
44-
// });
45-
// });
36+
describe('StreamingRpcClient', () => {
37+
const codec = cborCodec();
38+
const setup: ApiTestSetup = async () => setupDemoServerStreamingClient(codec);
39+
describe(`protocol: application/x.${codec.specifier()}`, () => {
40+
runUtilTests(setup);
41+
runPubsubTests(setup, {staticOnly: true});
42+
runPresenceTests(setup, {staticOnly: true});
43+
runBlockTests(setup, {staticOnly: true});
44+
});
45+
});
4646
} else {
4747
test.skip('set TEST_E2E=1 env var to run this test suite', () => {});
4848
}

src/__tests__/e2e/run.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const startServer = async () => {
2323
const cp = spawn('yarn', [`demo:e2e:${suite}:${server}`], {
2424
shell: true,
2525
});
26-
process.on('exit', (code) => {
26+
process.on('exit', () => {
2727
cp.kill();
2828
});
2929
cp.stdout.on('data', (data) => {
@@ -58,7 +58,7 @@ const runTests = async () => {
5858
},
5959
stdio: 'inherit',
6060
});
61-
process.on('exit', (code) => {
61+
process.on('exit', () => {
6262
cp.kill();
6363
});
6464
cp.on('close', (code) => {

src/__tests__/e2e/sample-api/clients.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (process.env.TEST_E2E) {
1818
for (const codec of list) {
1919
const setup: ApiTestSetup = async () => setupFetchRpcClient(codec);
2020
describe(`protocol: application/x.${codec.specifier()}`, () => {
21-
runApiTests(setup, {staticOnly: true});
21+
runApiTests(setup);
2222
});
2323
}
2424
});
@@ -28,7 +28,7 @@ if (process.env.TEST_E2E) {
2828
for (const codec of list) {
2929
const setup: ApiTestSetup = async () => setupStreamingRpcClient(codec);
3030
describe(`protocol: application/x.${codec.specifier()}`, () => {
31-
runApiTests(setup, {staticOnly: true});
31+
runApiTests(setup);
3232
});
3333
}
3434
});

src/__tests__/json-crdt-server/block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
184184
text: 'Hell',
185185
});
186186
const patch1 = model.api.flush();
187-
const newResult = await call('block.new', {
187+
await call('block.new', {
188188
id,
189189
batch: {
190190
patches: [

src/__tests__/json-crdt-server/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {JsonCrdtTestSetup} from '../../__demos__/json-crdt-server/__tests__/setup';
22
import type {ApiTestSetup} from '../../common/rpc/__tests__/runApiTests';
33

4-
export const runUtilTests = (_setup: ApiTestSetup, params: {staticOnly?: true} = {}) => {
4+
export const runUtilTests = (_setup: ApiTestSetup) => {
55
const setup = _setup as JsonCrdtTestSetup;
66

77
describe('util.*', () => {

src/browser/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/common/channel/__tests__/PersistentChannel.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ describe('.stop()', () => {
104104
await new Promise((r) => setTimeout(r, 1));
105105
expect(onSend).toHaveBeenCalledTimes(2);
106106
expect(onClose).toHaveBeenCalledTimes(1);
107+
expect(channel).toBe(undefined);
107108
});
108109
});
109110

@@ -126,6 +127,7 @@ describe('.send$() method', () => {
126127
expect(onSend).toHaveBeenCalledTimes(1);
127128
expect(onSend).toHaveBeenCalledWith('asdf');
128129
expect(persistent.open$.getValue()).toBe(true);
130+
expect(channel).not.toBe(undefined);
129131
});
130132

131133
test('buffers and sends message out once channel is connected', async () => {
@@ -144,6 +146,7 @@ describe('.send$() method', () => {
144146
await future;
145147
expect(onSend).toHaveBeenCalledTimes(1);
146148
expect(onSend).toHaveBeenCalledWith(new Uint8Array([1, 2, 3]));
149+
expect(channel).not.toBe(undefined);
147150
});
148151

149152
test('does not send messages once .stop() is executed', async () => {
@@ -161,10 +164,11 @@ describe('.send$() method', () => {
161164
await firstValueFrom(persistent.send$('foo').pipe(take(1)));
162165
expect(onSend).toHaveBeenCalledTimes(2);
163166
persistent.stop();
164-
const a = of(firstValueFrom(persistent.send$('bar').pipe(take(1))));
167+
of(firstValueFrom(persistent.send$('bar').pipe(take(1))));
165168
await new Promise((r) => setTimeout(r, 1));
166169
ws()._open();
167170
await new Promise((r) => setTimeout(r, 1));
168171
expect(onSend).toHaveBeenCalledTimes(2);
172+
expect(channel).toBe(undefined);
169173
});
170174
});

0 commit comments

Comments
 (0)