Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit b66fb85

Browse files
committed
style: fix eslint
1 parent 99d1b17 commit b66fb85

File tree

15 files changed

+31
-38
lines changed

15 files changed

+31
-38
lines changed

src/Connection.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const STATE = {
131131

132132
/* eslint-disable no-underscore-dangle, no-param-reassign */
133133
function SocketConnector(connection: Connection) {
134+
// eslint-disable-next-line prefer-const
134135
let next: Todo
135136
let socket: Todo
136137
let startedConnecting = false
@@ -463,15 +464,13 @@ export default class Connection extends EventEmitter {
463464

464465
this.isWaiting = true
465466
return new Promise((resolve, reject) => {
466-
let onError: Todo
467-
let onDone: Todo
468467
const onConnected = () => {
469468
this.off('done', onDone)
470469
this.off('error', onError)
471470
this.off('_error', onError)
472471
resolve(undefined)
473472
}
474-
onDone = (err: Todo) => {
473+
const onDone = (err: Todo) => {
475474
this.off('error', onError)
476475
this.off('_error', onError)
477476
this.off('connected', onConnected)
@@ -481,7 +480,7 @@ export default class Connection extends EventEmitter {
481480
resolve(undefined)
482481
}
483482
}
484-
onError = (err: Todo) => {
483+
const onError = (err: Todo) => {
485484
this.off('done', onDone)
486485
this.off('connected', onConnected)
487486
reject(err)
@@ -587,12 +586,11 @@ export default class Connection extends EventEmitter {
587586
}
588587

589588
return new Promise((resolve, reject) => {
590-
let onError: Todo
591589
const onDisconnected = () => {
592590
this.off('error', onError)
593591
resolve(undefined)
594592
}
595-
onError = (err: Todo) => {
593+
const onError = (err: Todo) => {
596594
this.off('disconnected', onDisconnected)
597595
reject(err)
598596
}
@@ -768,7 +766,6 @@ export default class Connection extends EventEmitter {
768766
// @ts-expect-error
769767
onError,
770768
}) {
771-
let onDoneHandler: Todo
772769
const cleanUp = async () => {
773770
this
774771
.off('connecting', onConnecting)
@@ -781,7 +778,7 @@ export default class Connection extends EventEmitter {
781778
}
782779
}
783780

784-
onDoneHandler = async (...args: Todo[]) => {
781+
const onDoneHandler = async (...args: Todo[]) => {
785782
// @ts-expect-error
786783
cleanUp(...args)
787784
// @ts-expect-error

src/StreamrClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ export class StreamrClient extends EventEmitter { // eslint-disable-line no-rede
332332
/**
333333
* @category Important
334334
*/
335-
async publish(streamObjectOrId: StreamPartDefinition, content: object, timestamp?: number|string|Date, partitionKey?: string) {
335+
async publish(streamObjectOrId: StreamPartDefinition, content: Record<string, unknown>, timestamp?: number|string|Date, partitionKey?: string) {
336336
return this.publisher.publish(streamObjectOrId, content, timestamp, partitionKey)
337337
}
338338

src/dataunion/DataUnion.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class DataUnion {
161161
* Get the tx promise for withdrawing all your earnings
162162
* @returns await on call .wait to actually send the tx
163163
*/
164-
private async getWithdrawAllTx(sendToMainnet: boolean = true): Promise<ContractTransaction> {
164+
private async getWithdrawAllTx(sendToMainnet = true): Promise<ContractTransaction> {
165165
const signer = await this.client.ethereum.getSidechainSigner()
166166
const address = await signer.getAddress()
167167
const duSidechain = await this.getContracts().getSidechainContract(this.contractAddress)
@@ -202,7 +202,7 @@ export class DataUnion {
202202
* @param recipientAddress - the address to receive the tokens
203203
* @returns await on call .wait to actually send the tx
204204
*/
205-
private async getWithdrawAllToTx(recipientAddress: EthereumAddress, sendToMainnet: boolean = true): Promise<ContractTransaction> {
205+
private async getWithdrawAllToTx(recipientAddress: EthereumAddress, sendToMainnet = true): Promise<ContractTransaction> {
206206
const signer = await this.client.ethereum.getSidechainSigner()
207207
const address = await signer.getAddress()
208208
const duSidechain = await this.getContracts().getSidechainContract(this.contractAddress)
@@ -363,7 +363,7 @@ export class DataUnion {
363363
/**
364364
* Add a new data union secret
365365
*/
366-
async createSecret(name: string = 'Untitled Data Union Secret'): Promise<string> {
366+
async createSecret(name = 'Untitled Data Union Secret'): Promise<string> {
367367
const url = getEndpointUrl(this.client.options.restUrl, 'dataunions', this.contractAddress, 'secrets')
368368
const res = await authFetch<{secret: string}>(
369369
url,
@@ -433,7 +433,7 @@ export class DataUnion {
433433
* @param memberAddress - the other member who gets their tokens out of the Data Union
434434
* @returns await on call .wait to actually send the tx
435435
*/
436-
private async getWithdrawAllToMemberTx(memberAddress: EthereumAddress, sendToMainnet: boolean = true): Promise<ContractTransaction> {
436+
private async getWithdrawAllToMemberTx(memberAddress: EthereumAddress, sendToMainnet = true): Promise<ContractTransaction> {
437437
const a = getAddress(memberAddress) // throws if bad address
438438
const duSidechain = await this.getContracts().getSidechainContract(this.contractAddress)
439439
return duSidechain.withdrawAll(a, sendToMainnet)
@@ -475,7 +475,7 @@ export class DataUnion {
475475
memberAddress: EthereumAddress,
476476
recipientAddress: EthereumAddress,
477477
signature: string,
478-
sendToMainnet: boolean = true,
478+
sendToMainnet = true,
479479
) {
480480
const duSidechain = await this.getContracts().getSidechainContract(this.contractAddress)
481481
return duSidechain.withdrawAllToSigned(memberAddress, recipientAddress, sendToMainnet, signature)
@@ -669,7 +669,7 @@ export class DataUnion {
669669
/**
670670
* @returns null if message was already transported, ELSE the mainnet AMB signature execution transaction receipt
671671
*/
672-
async transportMessage(messageHash: AmbMessageHash, pollingIntervalMs: number = 1000, retryTimeoutMs: number = 300000) {
672+
async transportMessage(messageHash: AmbMessageHash, pollingIntervalMs = 1000, retryTimeoutMs = 300000) {
673673
const helper = this.getContracts()
674674
const [sidechainAmb, mainnetAmb] = await Promise.all([
675675
helper.getSidechainAmb(),

src/rest/StreamEndpoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export class StreamEndpoints {
265265
return result
266266
}
267267

268-
async publishHttp(streamObjectOrId: Stream|string, data: any, requestOptions: any = {}, keepAlive: boolean = true) {
268+
async publishHttp(streamObjectOrId: Stream|string, data: any, requestOptions: any = {}, keepAlive = true) {
269269
let streamId
270270
if (streamObjectOrId instanceof Stream) {
271271
streamId = streamObjectOrId.id

src/rest/authFetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const debug = Debug('StreamrClient:utils:authfetch') // TODO: could use the debu
6767
let ID = 0
6868

6969
/** @internal */
70-
export default async function authFetch<T extends object>(url: string, session?: Session, opts?: any, requireNewToken = false): Promise<T> {
70+
export default async function authFetch<T>(url: string, session?: Session, opts?: any, requireNewToken = false): Promise<T> {
7171
ID += 1
7272
const timeStart = Date.now()
7373
const id = ID

src/stream/Encryption.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ function GroupKeyObjectFromProps(data: GroupKeyProps | GroupKeyObject) {
5757
return data
5858
}
5959

60-
interface GroupKey extends GroupKeyObject {}
61-
62-
// eslint-disable-next-line no-redeclare
63-
class GroupKey {
60+
class GroupKey implements GroupKeyObject {
6461
static InvalidGroupKeyError = InvalidGroupKeyError
6562

6663
static validate(maybeGroupKey: GroupKey) {
@@ -119,7 +116,7 @@ class GroupKey {
119116
this.hex = Buffer.from(this.data).toString('hex')
120117
}
121118

122-
// eslint-disable-next-line no-extra-semi
119+
// eslint-disable-next-line @typescript-eslint/no-extra-semi
123120
;(this.constructor as typeof GroupKey).validate(this)
124121
}
125122

@@ -356,7 +353,7 @@ export default class EncryptionUtil extends EncryptionUtilBase {
356353
constructor(options: {
357354
privateKey: string,
358355
publicKey: string,
359-
} | {} = {}) {
356+
} | Record<string, never> = {}) {
360357
super()
361358
if ('privateKey' in options && 'publicKey' in options) {
362359
EncryptionUtil.validatePrivateKey(options.privateKey)

src/stream/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export class Stream {
276276
return json.map((item: any) => new StorageNode(item.storageNodeAddress))
277277
}
278278

279-
async publish(content: object, timestamp?: number|string|Date, partitionKey?: string) {
279+
async publish(content: Record<string, unknown>, timestamp?: number|string|Date, partitionKey?: string) {
280280
return this._client.publish(this.id, content, timestamp, partitionKey)
281281
}
282282
}

src/stream/utils.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ export async function waitForMatchingMessage({
110110
return false
111111
}
112112
}
113-
let onDisconnected: Todo
113+
const onDisconnected = () => {
114+
cleanup()
115+
// @ts-expect-error
116+
resolve() // noop
117+
}
114118
const onResponse = (res: Todo) => {
115119
if (!tryMatch(res)) { return }
116120
// clean up err handler
@@ -143,12 +147,6 @@ export async function waitForMatchingMessage({
143147

144148
connection.on(ControlMessage.TYPES.ErrorResponse, onErrorResponse)
145149

146-
onDisconnected = () => {
147-
cleanup()
148-
// @ts-expect-error
149-
resolve() // noop
150-
}
151-
152150
connection.once('disconnected', onDisconnected)
153151
})
154152

src/subscribe/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ export class Subscriber {
622622
}
623623
}
624624

625+
// eslint-disable-next-line prefer-const
625626
let resendSubscribeSub: Todo
626627

627628
let lastResentMsgId: Todo

src/utils/PushQueue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default class PushQueue<T> {
8181
error?: Error// queued error
8282
nextQueue: (ReturnType<typeof Defer>)[] = [] // queued promises for next()
8383
finished = false
84-
pending: number = 0
84+
pending = 0
8585
ended = false
8686
_onEnd: PushQueueOptions['onEnd']
8787
_onEndCalled = false
@@ -196,7 +196,7 @@ export default class PushQueue<T> {
196196
return this.throw(new AbortError())
197197
}
198198

199-
async next(...args:[] | [unknown]) {
199+
async next(...args: [] | [unknown]) {
200200
return this.iterator.next(...args)
201201
}
202202

0 commit comments

Comments
 (0)