Skip to content

Commit c194617

Browse files
committed
chore: lint
1 parent 235d7ec commit c194617

File tree

11 files changed

+34
-101
lines changed

11 files changed

+34
-101
lines changed

eslint.config.mts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ export default defineConfig([globalIgnores([
3030
...base,
3131
{
3232
extends: [
33-
...compat.extends("plugin:@typescript-eslint/recommended"),
34-
...compat.extends("plugin:@typescript-eslint/recommended-requiring-type-checking"),
3533
...compat.extends("plugin:prettier/recommended"),
3634
],
3735

src/Signal/lid-mapping.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class LIDMappingStore {
145145
if (Object.keys(usyncFetch).length > 0) {
146146
const result = await this.pnToLIDFunc?.(Object.keys(usyncFetch)) // this function already adds LIDs to mapping
147147
if (result && result.length > 0) {
148-
this.storeLIDPNMappings(result)
148+
await this.storeLIDPNMappings(result)
149149
for (const pair of result) {
150150
const pnDecoded = jidDecode(pair.pn)
151151
const pnUser = pnDecoded?.user

src/Socket/Client/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export abstract class AbstractSocketClient extends EventEmitter {
1616
this.setMaxListeners(0)
1717
}
1818

19-
abstract connect(): Promise<void>
20-
abstract close(): Promise<void>
19+
abstract connect(): void
20+
abstract close(): void
2121
abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean
2222
}

src/Socket/Client/websocket.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class WebSocketClient extends AbstractSocketClient {
1818
return this.socket?.readyState === WebSocket.CONNECTING
1919
}
2020

21-
async connect(): Promise<void> {
21+
connect() {
2222
if (this.socket) {
2323
return
2424
}
@@ -40,7 +40,7 @@ export class WebSocketClient extends AbstractSocketClient {
4040
}
4141
}
4242

43-
async close(): Promise<void> {
43+
close() {
4444
if (!this.socket) {
4545
return
4646
}

src/Socket/messages-recv.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
145145
logger.debug({ messageKey }, 'already requested resend')
146146
return
147147
} else {
148-
placeholderResendCache.set(messageKey?.id!, true)
148+
await placeholderResendCache.set(messageKey?.id!, true)
149149
}
150150

151151
await delay(5000)
@@ -164,10 +164,10 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
164164
peerDataOperationRequestType: proto.Message.PeerDataOperationRequestType.PLACEHOLDER_MESSAGE_RESEND
165165
}
166166

167-
setTimeout(() => {
167+
setTimeout(async () => {
168168
if (placeholderResendCache.get(messageKey?.id!)) {
169169
logger.debug({ messageKey }, 'PDO message without response after 15 seconds. Phone possibly offline')
170-
placeholderResendCache.del(messageKey?.id!)
170+
await placeholderResendCache.del(messageKey?.id!)
171171
}
172172
}, 15_000)
173173

@@ -403,14 +403,14 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
403403

404404
// Use the new retry count for the rest of the logic
405405
const key = `${msgId}:${msgKey?.participant}`
406-
msgRetryCache.set(key, retryCount)
406+
await msgRetryCache.set(key, retryCount)
407407
} else {
408408
// Fallback to old system
409409
const key = `${msgId}:${msgKey?.participant}`
410410
let retryCount = (await msgRetryCache.get<number>(key)) || 0
411411
if (retryCount >= maxMsgRetryCount) {
412412
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing')
413-
msgRetryCache.del(key)
413+
await msgRetryCache.del(key)
414414
return
415415
}
416416

@@ -1031,7 +1031,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
10311031
if (!ids[i]) continue
10321032

10331033
if (msg && (await willSendMessageAgain(ids[i], participant))) {
1034-
updateSendMessageAgainCount(ids[i], participant)
1034+
await updateSendMessageAgainCount(ids[i], participant)
10351035
const msgRelayOpts: MessageRelayOptions = { messageId: ids[i] }
10361036

10371037
if (sendToAll) {
@@ -1122,7 +1122,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
11221122
if (ids[0] && key.participant && (await willSendMessageAgain(ids[0], key.participant))) {
11231123
if (key.fromMe) {
11241124
try {
1125-
updateSendMessageAgainCount(ids[0], key.participant)
1125+
await updateSendMessageAgainCount(ids[0], key.participant)
11261126
logger.debug({ attrs, key }, 'recv retry request')
11271127
await sendMessagesAgain(key, ids, retryNode!)
11281128
} catch (error: unknown) {
@@ -1257,7 +1257,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
12571257
logger.debug(`[handleMessage] Attempting retry request for failed decryption`)
12581258

12591259
// Handle both pre-key and normal retries in single mutex
1260-
retryMutex.mutex(async () => {
1260+
await retryMutex.mutex(async () => {
12611261
try {
12621262
if (!ws.isOpen) {
12631263
logger.debug({ node }, 'Connection closed, skipping retry')
@@ -1499,7 +1499,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
14991499

15001500
const offlineNodeProcessor = makeOfflineNodeProcessor()
15011501

1502-
const processNode = (
1502+
const processNode = async (
15031503
type: MessageType,
15041504
node: BinaryNode,
15051505
identifier: string,
@@ -1510,31 +1510,31 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
15101510
if (isOffline) {
15111511
offlineNodeProcessor.enqueue(type, node)
15121512
} else {
1513-
processNodeWithBuffer(node, identifier, exec)
1513+
await processNodeWithBuffer(node, identifier, exec)
15141514
}
15151515
}
15161516

15171517
// recv a message
1518-
ws.on('CB:message', (node: BinaryNode) => {
1519-
processNode('message', node, 'processing message', handleMessage)
1518+
ws.on('CB:message', async (node: BinaryNode) => {
1519+
await processNode('message', node, 'processing message', handleMessage)
15201520
})
15211521

15221522
ws.on('CB:call', async (node: BinaryNode) => {
1523-
processNode('call', node, 'handling call', handleCall)
1523+
await processNode('call', node, 'handling call', handleCall)
15241524
})
15251525

1526-
ws.on('CB:receipt', node => {
1527-
processNode('receipt', node, 'handling receipt', handleReceipt)
1526+
ws.on('CB:receipt', async node => {
1527+
await processNode('receipt', node, 'handling receipt', handleReceipt)
15281528
})
15291529

15301530
ws.on('CB:notification', async (node: BinaryNode) => {
1531-
processNode('notification', node, 'handling notification', handleNotification)
1531+
await processNode('notification', node, 'handling notification', handleNotification)
15321532
})
15331533
ws.on('CB:ack,class:message', (node: BinaryNode) => {
15341534
handleBadAck(node).catch(error => onUnexpectedError(error, 'handling bad ack'))
15351535
})
15361536

1537-
ev.on('call', ([call]) => {
1537+
ev.on('call', async ([call]) => {
15381538
if (!call) {
15391539
return
15401540
}
@@ -1562,7 +1562,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
15621562
}
15631563

15641564
const protoMsg = proto.WebMessageInfo.fromObject(msg) as WAMessage
1565-
upsertMessage(protoMsg, call.offline ? 'append' : 'notify')
1565+
await upsertMessage(protoMsg, call.offline ? 'append' : 'notify')
15661566
}
15671567
})
15681568

src/Socket/messages-send.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
946946
const tcTokenBuffer = contactTcTokenData[destinationJid]?.token
947947

948948
if (tcTokenBuffer) {
949-
(stanza.content as BinaryNode[]).push({
949+
;(stanza.content as BinaryNode[]).push({
950950
tag: 'tctoken',
951951
attrs: {},
952952
content: tcTokenBuffer
@@ -1198,8 +1198,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
11981198
additionalNodes
11991199
})
12001200
if (config.emitOwnEvents) {
1201-
process.nextTick(() => {
1202-
processingMutex.mutex(() => upsertMessage(fullMsg, 'append'))
1201+
process.nextTick(async () => {
1202+
await processingMutex.mutex(() => upsertMessage(fullMsg, 'append'))
12031203
})
12041204
}
12051205

src/Socket/socket.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export const makeSocket = (config: SocketConfig) => {
435435
}
436436
}).finish()
437437
)
438-
noise.finishInit()
438+
await noise.finishInit()
439439
startKeepAliveRequest()
440440
}
441441

@@ -566,8 +566,8 @@ export const makeSocket = (config: SocketConfig) => {
566566
}
567567
}
568568

569-
const onMessageReceived = (data: Buffer) => {
570-
noise.decodeFrame(data, frame => {
569+
const onMessageReceived = async (data: Buffer) => {
570+
await noise.decodeFrame(data, frame => {
571571
// reset ping timeout
572572
lastDateRecv = new Date()
573573

@@ -968,9 +968,9 @@ export const makeSocket = (config: SocketConfig) => {
968968
end(new Boom('Multi-device beta not joined', { statusCode: DisconnectReason.multideviceMismatch }))
969969
})
970970

971-
ws.on('CB:ib,,offline_preview', (node: BinaryNode) => {
971+
ws.on('CB:ib,,offline_preview', async (node: BinaryNode) => {
972972
logger.info('offline preview received', JSON.stringify(node))
973-
sendNode({
973+
await sendNode({
974974
tag: 'ib',
975975
attrs: {},
976976
content: [{ tag: 'offline_batch', attrs: { count: '100' } }]

src/Utils/auth-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function makeCacheableSignalKeyStore(
7575
const item = fetched[id]
7676
if (item) {
7777
data[id] = item
78-
cache.set(getUniqueId(type, id), item as SignalDataTypeMap[keyof SignalDataTypeMap])
78+
await cache.set(getUniqueId(type, id), item)
7979
}
8080
}
8181
}

src/Utils/baileys-event-stream.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/Utils/event-buffer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ export const makeEventBuffer = (logger: ILogger): BaileysBufferableEventEmitter
153153

154154
return {
155155
process(handler) {
156-
const listener = (map: BaileysEventData) => {
157-
handler(map)
156+
const listener = async (map: BaileysEventData) => {
157+
await handler(map)
158158
}
159159

160160
ev.on('event', listener)

0 commit comments

Comments
 (0)