Skip to content

Commit ffce2de

Browse files
committed
Update ESLint
1 parent 3c25983 commit ffce2de

File tree

21 files changed

+596
-866
lines changed

21 files changed

+596
-866
lines changed

badge/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function emit(obj: any, event: string, ...args: any[]): void {
4040

4141
async function createTest(override?: Partial<BadgeOptions>): Promise<TestPair> {
4242
let pair = new TestPair()
43-
let client = new CrossTabClient<{}, TestLog<ClientMeta>>({
43+
let client = new CrossTabClient<object, TestLog<ClientMeta>>({
4444
server: pair.left,
4545
subprotocol: '1.0.0',
4646
time: new TestTime(),

client/index.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export interface ClientOptions {
127127
* ```
128128
*/
129129
export class Client<
130-
Headers extends object = {},
130+
Headers extends object = object,
131131
ClientLog extends Log = Log<ClientMeta>
132132
> {
133133
/**
@@ -249,7 +249,6 @@ export class Client<
249249
destroy(): void
250250

251251
on(event: 'user', listener: (userId: string) => void): Unsubscribe
252-
253252
/**
254253
* Subscribe for synchronization events. It implements Nano Events API.
255254
* Supported events:
@@ -329,7 +328,6 @@ export class Client<
329328
listener: ClientActionListener<TypeAction>,
330329
opts?: { event?: 'add' | 'clean' | 'preadd'; id?: string }
331330
): Unsubscribe
332-
333331
/**
334332
* @param actionCreator Action creator function.
335333
* @param callbacks Callbacks for action created by creator.

client/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ function unsubscribeChannel(client, unsubscribe) {
4545
}
4646

4747
export class Client {
48+
get connected() {
49+
return this.state !== 'disconnected' && this.state !== 'connecting'
50+
}
51+
52+
get state() {
53+
return this.node.state
54+
}
55+
4856
constructor(opts = {}) {
4957
this.options = opts
5058

@@ -402,12 +410,4 @@ export class Client {
402410
})
403411
})
404412
}
405-
406-
get connected() {
407-
return this.state !== 'disconnected' && this.state !== 'connecting'
408-
}
409-
410-
get state() {
411-
return this.node.state
412-
}
413413
}

client/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ function getPair(client: Client): TestPair {
6767
async function createDialog(
6868
opts: Partial<ClientOptions> = {},
6969
token: string | undefined = undefined
70-
): Promise<Client<{}, TestLog>> {
70+
): Promise<Client<object, TestLog>> {
7171
let pair = new TestPair()
7272

73-
let client = new Client<{}, TestLog>({
73+
let client = new Client<object, TestLog>({
7474
server: pair.left,
7575
subprotocol: '1.0.0',
7676
time: new TestTime(),
@@ -111,8 +111,8 @@ async function createDialog(
111111
return client
112112
}
113113

114-
function createClient(): Client<{}, TestLog> {
115-
let client = new Client<{}, TestLog>({
114+
function createClient(): Client<object, TestLog> {
115+
let client = new Client<object, TestLog>({
116116
server: 'wss://localhost:1337',
117117
subprotocol: '1.0.0',
118118
time: new TestTime(),

create-filter/index.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ it('subscribes to channels for remote stores', async () => {
167167
])
168168

169169
expect(
170-
await client.sent(async () => {
170+
await client.sent(() => {
171171
let local = createFilter(client, LocalPost, { projectId: '1' })
172172
let unbindLocal = local.listen(() => {})
173173
unbindLocal()
@@ -288,7 +288,7 @@ it('does not send since when subscribing to remote stores', async () => {
288288
let filter1 = createFilter(client, Post, {})
289289
await client.server.freezeProcessing(async () => {
290290
filter1.listen(() => {})
291-
delay(1)
291+
await delay(1)
292292
})
293293
await allTasks()
294294

@@ -308,7 +308,7 @@ it('does not send since when subscribing to remote stores', async () => {
308308
let filter2 = createFilter(client, Post, { projectId: '10' })
309309
await client.server.freezeProcessing(async () => {
310310
filter2.listen(() => {})
311-
delay(1)
311+
await delay(1)
312312
})
313313
await allTasks()
314314

@@ -347,7 +347,7 @@ it('sends since when subscribing to filter if actions are cached for remote offl
347347
let filter1 = createFilter(client, CachedPost, {})
348348
await client.server.freezeProcessing(async () => {
349349
filter1.listen(() => {})
350-
delay(1)
350+
await delay(1)
351351
})
352352
await filter1.loading
353353
await allTasks()
@@ -367,7 +367,7 @@ it('sends since when subscribing to filter if actions are cached for remote offl
367367
let filter2 = createFilter(client, CachedPost, { projectId: '10' })
368368
await client.server.freezeProcessing(async () => {
369369
filter2.listen(() => {})
370-
delay(1)
370+
await delay(1)
371371
})
372372
await filter2.loading
373373
await allTasks()
@@ -410,9 +410,10 @@ it('supports both offline and remote stores', async () => {
410410
})
411411

412412
let posts = createFilter(client, CachedPost, { projectId: '10' })
413-
await client.server.freezeProcessing(async () => {
413+
await client.server.freezeProcessing(() => {
414414
posts.listen(() => {})
415415
expect(posts.get().isLoading).toBe(true)
416+
return Promise.resolve()
416417
})
417418
await allTasks()
418419
expect(posts.get().isLoading).toBe(false)

cross-tab-client/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import type { ClientActionListener, ClientMeta } from '../client/index.js'
2626
* ```
2727
*/
2828
export class CrossTabClient<
29-
Headers extends object = {},
29+
Headers extends object = object,
3030
ClientLog extends Log = Log<ClientMeta>
3131
> extends Client<Headers, ClientLog> {
3232
/**

cross-tab-client/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ function isMemory(store) {
4747
}
4848

4949
export class CrossTabClient extends Client {
50+
set state(value) {
51+
this.leaderState = value
52+
}
53+
54+
get state() {
55+
return this.leaderState
56+
}
57+
5058
constructor(opts = {}) {
5159
super(opts)
5260
this.leaderState = this.node.state
@@ -212,12 +220,4 @@ export class CrossTabClient extends Client {
212220
return this.emitter.on(`${event}-${type}-${id}`, listener)
213221
}
214222
}
215-
216-
set state(value) {
217-
this.leaderState = value
218-
}
219-
220-
get state() {
221-
return this.leaderState
222-
}
223223
}

cross-tab-client/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ beforeEach(() => {
2929
setLocalStorage()
3030
})
3131

32-
let client: CrossTabClient<{}, TestLog>
32+
let client: CrossTabClient<object, TestLog>
3333
let originWebSocket = global.WebSocket
3434
afterEach(() => {
3535
client.destroy()
@@ -60,8 +60,8 @@ function emit(obj: any, event: string, ...args: any[]): void {
6060

6161
function createClient(
6262
overrides: Partial<ClientOptions> = {}
63-
): CrossTabClient<{}, TestLog> {
64-
let result = new CrossTabClient<{}, TestLog>({
63+
): CrossTabClient<object, TestLog> {
64+
let result = new CrossTabClient<object, TestLog>({
6565
server: 'wss://localhost:1337',
6666
subprotocol: '1.0.0',
6767
time: new TestTime(),
@@ -304,7 +304,7 @@ it('becomes follower on taken lock', () => {
304304
expect(connect.called).toBe(false)
305305
})
306306

307-
it('updates state if tab is a leader', async () => {
307+
it('updates state if tab is a leader', () => {
308308
client = createClient()
309309

310310
client.start()
@@ -490,7 +490,7 @@ it('ignores subprotocols from server', () => {
490490
expect(error).toBeUndefined()
491491
})
492492

493-
it('disables cross-tab communication on localStorage error', async () => {
493+
it('disables cross-tab communication on localStorage error', () => {
494494
client = createClient()
495495
client.start()
496496

eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,12 @@ export default [
2929
'no-console': 'off',
3030
'symbol-description': 'off'
3131
}
32+
},
33+
{
34+
files: ['indexed-store/index.test.ts'],
35+
rules: {
36+
'@typescript-eslint/no-namespace': 'off',
37+
'@typescript-eslint/prefer-promise-reject-errors': 'off'
38+
}
3239
}
3340
]

indexed-store/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ afterEach(async () => {
7272

7373
eachStoreCheck((desc, creator) => {
7474
it(
75-
`${desc}`,
75+
desc,
7676
creator(() => {
7777
store = new IndexedStore()
7878
return store

0 commit comments

Comments
 (0)