Skip to content

Commit ad6de1e

Browse files
authored
chore: Fix remaining lints, add to CI (#510)
1 parent 3d8b119 commit ad6de1e

File tree

11 files changed

+76
-45
lines changed

11 files changed

+76
-45
lines changed

.github/workflows/lint.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 10
15+
defaults:
16+
run:
17+
working-directory: ./typescript/packages
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Setup Deno
21+
uses: denoland/setup-deno@v2
22+
with:
23+
deno-version: "2.2.2"
24+
- name: Cache dependencies
25+
uses: actions/cache@v3
26+
with:
27+
path: |
28+
~/.deno
29+
~/.cache/deno
30+
key: ${{ runner.os }}-deno-${{ hashFiles('**/deno.json') }}
31+
- name: Lint
32+
working-directory: typescript/packages
33+
run: deno lint

typescript/packages/common-cli/arena.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ export class ArenaClient {
7373
return response.json();
7474
}
7575

76-
async getChannel(slug: string): Promise<Channel> {
76+
getChannel(slug: string): Promise<Channel> {
7777
return this.fetch<Channel>(`/channels/${slug}`);
7878
}
7979

80-
async getChannelContents(
80+
getChannelContents(
8181
slug: string,
8282
params: { page?: number; per?: number } = {},
8383
): Promise<Channel["contents"]> {
@@ -91,7 +91,7 @@ export class ArenaClient {
9191
);
9292
}
9393

94-
async createChannel(
94+
createChannel(
9595
params: { title: string; status?: Channel["status"] },
9696
): Promise<Channel> {
9797
return this.fetch<Channel>("/channels", {
@@ -100,7 +100,7 @@ export class ArenaClient {
100100
});
101101
}
102102

103-
async updateChannel(
103+
updateChannel(
104104
slug: string,
105105
params: {
106106
title?: string;
@@ -123,7 +123,7 @@ export class ArenaClient {
123123
});
124124
}
125125

126-
async getCollaborators(slug: string): Promise<User[]> {
126+
getCollaborators(slug: string): Promise<User[]> {
127127
return this.fetch<User[]>(`/channels/${slug}/collaborators`);
128128
}
129129
}

typescript/packages/common-cli/gmail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const updateLimit = handler<{ detail: { value: string } }, { limit: number }>(
7878
);
7979

8080
const googleUpdater = handler<
81-
{},
81+
NonNullable<unknown>,
8282
{ emails: Email[]; auth: Auth; settings: { labels: string; limit: number } }
8383
>((_event, state) => {
8484
console.log("googleUpdater!");

typescript/packages/common-html/test/html-recipes.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe("recipes with HTML", () => {
4242
<div>
4343
<h1>{title}</h1>
4444
<ul>
45-
{items.map((item) => <li>{item.title}</li>)}
45+
{items.map((item, i) => <li key={i.toString()}>{item.title}</li>)}
4646
</ul>
4747
</div>
4848
),

typescript/packages/common-memory/consumer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class MemoryConsumerSession<
152152
if (command.the === "task/return") {
153153
const invocation = this.invocations.get(id);
154154
this.invocations.delete(id);
155-
invocation?.return(command.is as {});
155+
invocation?.return(command.is as NonNullable<unknown>);
156156
} // If it is an effect it can be for one specific subscription, yet we may
157157
// have other subscriptions that will be affected. There for we simply
158158
// pass effect to each one and they can detect if it concerns them.
@@ -301,7 +301,7 @@ class ConsumerInvocation<Ability extends The, Protocol extends Proto> {
301301
this.promise = new Promise<ConsumerResultFor<Ability, Protocol>>(
302302
(resolve) => (receive = resolve),
303303
);
304-
this.return = receive as typeof receive & {};
304+
this.return = receive as typeof receive & NonNullable<unknown>;
305305
}
306306

307307
refer() {

typescript/packages/common-memory/entity.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fromJSON, refer } from "merkle-reference";
22

3-
export interface Entity<T extends null | {}> {
3+
export interface Entity<T extends null | NonNullable<unknown>> {
44
"@": ToString<Entity<T>>;
55
}
66

@@ -9,16 +9,16 @@ export interface Entity<T extends null | {}> {
99
*/
1010
export type ToString<T> = string & { toString(): ToString<T> };
1111

12-
export const entity = <T extends null | {}>(
13-
description: {} | null,
12+
export const entity = <T extends null | NonNullable<unknown>>(
13+
description: NonNullable<unknown> | null,
1414
): Entity<T> => {
1515
return { "@": refer(description).toJSON()["/"] };
1616
};
1717

18-
export const toString = <T extends null | {}>(entity: Entity<T>): string =>
18+
export const toString = <T extends null | NonNullable<unknown>>(entity: Entity<T>): string =>
1919
`@${entity["@"]}`;
2020

21-
export const fromString = <T extends null | {}>(
21+
export const fromString = <T extends null | NonNullable<unknown>>(
2222
source: string | ToString<Entity<T>>,
2323
): Entity<T> => {
2424
if (!source.startsWith("@")) {
@@ -37,7 +37,7 @@ export const fromString = <T extends null | {}>(
3737
/**
3838
* Asserts type of the `source` to be an `Entity`.
3939
*/
40-
export const is = <T extends null | {}>(
40+
export const is = <T extends null | NonNullable<unknown>>(
4141
source: unknown | Entity<T>,
4242
): source is Entity<T> =>
4343
source != null && typeof (source as { ["@"]?: string })["@"] === "string";

typescript/packages/common-memory/interface.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export interface AuthorizationError extends Error {
8080
export type Call<
8181
Ability extends The = The,
8282
Of extends DID = DID,
83-
Args extends {} = {},
83+
Args extends NonNullable<unknown> = NonNullable<unknown>,
8484
> = {
8585
cmd: Ability;
8686
sub: Of;
@@ -91,7 +91,7 @@ export type Call<
9191
export type Command<
9292
Ability extends The = The,
9393
Of extends DID = DID,
94-
In extends {} = {},
94+
In extends NonNullable<unknown> = NonNullable<unknown>,
9595
> = {
9696
cmd: Ability;
9797
sub: Of;
@@ -103,7 +103,7 @@ export type Command<
103103
export type Invocation<
104104
Ability extends The = The,
105105
Of extends DID = DID,
106-
In extends {} = {},
106+
In extends NonNullable<unknown> = NonNullable<unknown>,
107107
> = {
108108
iss: DID;
109109
aud?: DID;
@@ -161,7 +161,7 @@ export type Protocol<Space extends MemorySpace = MemorySpace> = {
161161

162162
export type Proto = {
163163
[Subject: DID]: {
164-
[Namespace: string]: {};
164+
[Namespace: string]: NonNullable<unknown>;
165165
};
166166
};
167167

@@ -175,8 +175,8 @@ export type InferProtoMethods<
175175
Prefix extends string = "",
176176
> = {
177177
[Name in keyof Methods & string]: Methods[Name] extends (
178-
input: infer In extends {},
179-
) => Task<infer Out extends {}, infer Effect> ?
178+
input: infer In extends NonNullable<unknown>,
179+
) => Task<infer Out extends NonNullable<unknown>, infer Effect> ?
180180
| {
181181
[The in `${Prefix}/${Name}`]: Method<
182182
Protocol,
@@ -195,8 +195,8 @@ export type InferProtoMethods<
195195
export type Method<
196196
Protocol,
197197
Ability extends The,
198-
In extends {},
199-
Out extends {},
198+
In extends NonNullable<unknown>,
199+
Out extends NonNullable<unknown>,
200200
Effect,
201201
> = {
202202
The: Ability;
@@ -243,7 +243,7 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends
243243
(k: infer I) => void ? I
244244
: never;
245245

246-
export type Provider<Protocol extends {}> = {
246+
export type Provider<Protocol extends NonNullable<unknown>> = {
247247
perform(command: ProviderCommand<Protocol>): AwaitResult<Unit, SystemError>;
248248
};
249249

@@ -341,7 +341,7 @@ export type ConsumerResultFor<Ability, Protocol extends Proto> = MethodFor<
341341

342342
export interface InvocationView<
343343
Source extends Invocation,
344-
Return extends {},
344+
Return extends NonNullable<unknown>,
345345
Effect,
346346
> extends Invocation<Source["cmd"], Source["sub"], Source["args"]> {
347347
return(result: Await<Return>): void;
@@ -353,8 +353,8 @@ export interface InvocationView<
353353
export type Task<Return, Command = never> = Iterable<Command, Return>;
354354

355355
export type Job<
356-
Command extends {} = {},
357-
Return extends {} | null = {} | null,
356+
Command extends NonNullable<unknown> = NonNullable<unknown>,
357+
Return extends NonNullable<unknown> | null = NonNullable<unknown> | null,
358358
Effect = unknown,
359359
> = {
360360
invoke: Command;
@@ -378,7 +378,7 @@ export type SessionTask<Space extends MemorySpace> =
378378
| UnwatchTask<Space>
379379
| WatchTask<Space>;
380380

381-
export type Receipt<Command extends {}, Result extends {} | null, Effect> =
381+
export type Receipt<Command extends NonNullable<unknown>, Result extends NonNullable<unknown> | null, Effect> =
382382
| {
383383
the: "task/return";
384384
of: InvocationURL<Reference<Command>>;
@@ -391,13 +391,13 @@ export type Receipt<Command extends {}, Result extends {} | null, Effect> =
391391
is: Effect;
392392
});
393393

394-
export type Effect<Of extends {}, Command> = {
394+
export type Effect<Of extends NonNullable<unknown>, Command> = {
395395
of: Reference<Of>;
396396
run: Command;
397397
is?: undefined;
398398
};
399399

400-
export type Return<Of extends {}, Result extends {} | null> = {
400+
export type Return<Of extends NonNullable<unknown>, Result extends NonNullable<unknown> | null> = {
401401
of: Reference<Of>;
402402
is: Result;
403403
run?: undefined;
@@ -730,7 +730,7 @@ export type Selection<Space extends MemorySpace = MemorySpace> = {
730730
[space in Space]: FactSelection;
731731
};
732732

733-
export type Unit = {};
733+
export type Unit = NonNullable<unknown>;
734734

735735
/**
736736
* Generic type used to annotate underlying type with a context of the replica.

typescript/packages/common-memory/receipt.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import { Receipt } from "./interface.ts";
33
/**
44
* Formats receipt to a string representation.
55
*/
6-
export const toString = <Command extends {}, Result extends {}, Effect>(
6+
export const toString = <Command extends NonNullable<unknown>, Result extends NonNullable<unknown>, Effect>(
77
receipt: Receipt<Command, Result, Effect>,
88
) => JSON.stringify(receipt);
99

1010
/**
1111
* Parses receipt from a string representation.
1212
*/
13-
export const fromString = <Command extends {}, Result extends {}, Effect>(
13+
export const fromString = <Command extends NonNullable<unknown>, Result extends NonNullable<unknown>, Effect>(
1414
source: string,
1515
): Receipt<Command, Result, Effect> => JSON.parse(source);
1616

1717
export const fromStringStream = <
18-
Command extends {},
19-
Result extends {},
18+
Command extends NonNullable<unknown>,
19+
Result extends NonNullable<unknown>,
2020
Effect,
2121
>() =>
2222
new TransformStream<string, Receipt<Command, Result, Effect>>({
@@ -26,8 +26,8 @@ export const fromStringStream = <
2626
});
2727

2828
export const toStringStream = <
29-
Command extends {},
30-
Result extends {},
29+
Command extends NonNullable<unknown>,
30+
Result extends NonNullable<unknown>,
3131
Effect,
3232
>() =>
3333
new TransformStream<Receipt<Command, Result, Effect>, string>({

typescript/packages/common-memory/test/space-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ test(
10181018
},
10191019
);
10201020

1021-
test("list empty store", DB, async (session) => {
1021+
test("list empty store", DB, (session) => {
10221022
const result = session.query({
10231023
cmd: "/memory/query",
10241024
iss: alice.did(),

typescript/packages/common-memory/test/stress-debug.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @ts-nocheck
2-
31
import {
42
assert,
53
assertEquals,

0 commit comments

Comments
 (0)