Skip to content

Commit 6d94b19

Browse files
authored
chore: fix require-await eslint rule issues (#1353)
Some fixes related to [require-await](https://typescript-eslint.io/rules/require-await/) eslint rule. The rule is not yet in our eslint rule set, but we may add it in PR #1171.
1 parent a3c5256 commit 6d94b19

9 files changed

Lines changed: 21 additions & 27 deletions

File tree

packages/broker/src/config/ConfigWizard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ const selectStoragePath = async (): Promise<StorageAnswers> => {
255255
}
256256

257257
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
258-
export const createStorageFile = async (config: any, answers: StorageAnswers): Promise<string> => {
258+
export const createStorageFile = (config: any, answers: StorageAnswers): string => {
259259
const dirPath = path.dirname(answers.storagePath)
260260
const dirExists = existsSync(dirPath)
261261
if (!dirExists) {
@@ -300,7 +300,7 @@ export const start = async (
300300
const pluginsAnswers = await getPluginAnswers()
301301
const config = getConfig(privateKey, pluginsAnswers)
302302
const storageAnswers = await getStorageAnswers()
303-
const storagePath = await createStorageFile(config, storageAnswers)
303+
const storagePath = createStorageFile(config, storageAnswers)
304304
logger.info('Welcome to the Streamr Network')
305305
const { mnemonic, networkExplorerUrl } = getNodeIdentity(privateKey)
306306
logger.info(`Your node's generated name is ${mnemonic}.`)

packages/broker/src/plugins/storage/StorageConfig.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,13 @@ export class StorageConfig {
6666
}
6767

6868
async start(): Promise<void> {
69-
await Promise.all([
70-
this.storagePoller.start(this.abortController.signal),
71-
this.storageEventListener.start()
72-
])
69+
this.storageEventListener.start()
70+
await this.storagePoller.start(this.abortController.signal)
7371
}
7472

75-
async destroy(): Promise<void> {
73+
destroy(): void {
7674
this.abortController.abort()
77-
await this.storageEventListener.destroy()
75+
this.storageEventListener.destroy()
7876
}
7977

8078
hasStreamPart(streamPart: StreamPartID): boolean {

packages/broker/src/plugins/storage/StorageEventListener.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export class StorageEventListener {
3939
}
4040
}
4141

42-
async start(): Promise<void> {
42+
start(): void {
4343
this.streamrClient.on('addToStorageNode', this.onAddToStorageNode)
4444
this.streamrClient.on('removeFromStorageNode', this.onRemoveFromStorageNode)
4545
}
4646

47-
async destroy(): Promise<void> {
47+
destroy(): void {
4848
this.streamrClient.off('addToStorageNode', this.onAddToStorageNode)
4949
this.streamrClient.off('removeFromStorageNode', this.onRemoveFromStorageNode)
5050
}

packages/broker/src/plugins/storage/StoragePlugin.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ export class StoragePlugin extends Plugin<StoragePluginConfig> {
6464
this.storageConfig!.getStreamParts().forEach((streamPart) => {
6565
node.unsubscribe(streamPart)
6666
})
67-
await Promise.all([
68-
this.cassandra!.close(),
69-
this.storageConfig!.destroy()
70-
])
67+
await this.cassandra!.close()
68+
this.storageConfig!.destroy()
7169
}
7270

7371
// eslint-disable-next-line class-methods-use-this

packages/broker/test/unit/ConfigWizard.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ describe('ConfigWizard', () => {
118118
it('should throw when no permissions on path', async () => {
119119
const dirPath = '/home/'
120120
const configPath = dirPath + 'test-config.json'
121-
await expect(createStorageFile(CONFIG, {
121+
expect(() => createStorageFile(CONFIG, {
122122
storagePath: configPath
123-
})).rejects.toThrow()
123+
})).toThrow()
124124
})
125125

126126
})

packages/broker/test/unit/plugins/storage/StorageConfig.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ describe(StorageConfig, () => {
6161
getStoredStreams.mockRejectedValue(new Error('results not available'))
6262
})
6363

64-
afterEach(async () => {
65-
await storageConfig?.destroy()
64+
afterEach(() => {
65+
storageConfig?.destroy()
6666
})
6767

6868
it('state starts empty', () => {
@@ -163,7 +163,7 @@ describe(StorageConfig, () => {
163163
it('updates do not occur after destroy has been invoked', async () => {
164164
await storageConfig.start()
165165
await wait(POLL_TIME)
166-
await storageConfig.destroy()
166+
storageConfig.destroy()
167167

168168
getStoredStreams.mockClear()
169169
getStoredStreams.mockResolvedValue({

packages/client/src/StreamMessageValidator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default class StreamMessageValidator {
6565
throw new ValidationError('Falsey argument passed to validate()!')
6666
}
6767

68-
await this.assertSignatureIsValid(streamMessage)
68+
this.assertSignatureIsValid(streamMessage)
6969

7070
switch (streamMessage.messageType) {
7171
case StreamMessageType.MESSAGE:
@@ -88,7 +88,7 @@ export default class StreamMessageValidator {
8888
* @param streamMessage the StreamMessage to validate.
8989
* @param verifyFn function(address, payload, signature): return true if the address and payload match the signature
9090
*/
91-
private async assertSignatureIsValid(streamMessage: StreamMessage): Promise<void> {
91+
private assertSignatureIsValid(streamMessage: StreamMessage): void {
9292
const payload = createSignaturePayload({
9393
messageId: streamMessage.getMessageID(),
9494
serializedContent: streamMessage.getSerializedContent(),

packages/client/src/subscribe/ResendSubscription.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ export class ResendSubscription extends Subscription {
3333
)
3434
this.pipe(this.resendThenRealtime.bind(this))
3535
this.pipe(this.orderMessages.transform())
36-
this.onBeforeFinally.listen(async () => {
37-
this.orderMessages.stop()
38-
})
36+
this.onBeforeFinally.listen(() => this.orderMessages.stop())
3937
}
4038

4139
private async getResent(): Promise<MessageStream> {

packages/client/src/subscribe/subscribePipeline.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const createSubscribePipeline = (opts: SubscriptionPipelineOptions): Mess
4545

4646
/* eslint-enable object-curly-newline */
4747

48-
const onError = async (error: Error | StreamMessageError, streamMessage?: StreamMessage) => {
48+
const onError = (error: Error | StreamMessageError, streamMessage?: StreamMessage) => {
4949
if (streamMessage) {
5050
ignoreMessages.add(streamMessage)
5151
}
@@ -95,11 +95,11 @@ export const createSubscribePipeline = (opts: SubscriptionPipelineOptions): Mess
9595
yield* msgChainUtil
9696
})
9797
// parse content
98-
.forEach(async (streamMessage: StreamMessage) => {
98+
.forEach((streamMessage: StreamMessage) => {
9999
streamMessage.getParsedContent()
100100
})
101101
// ignore any failed messages
102-
.filter(async (streamMessage: StreamMessage) => {
102+
.filter((streamMessage: StreamMessage) => {
103103
return !ignoreMessages.has(streamMessage)
104104
})
105105
.onBeforeFinally.listen(async () => {

0 commit comments

Comments
 (0)