From 763f51279cc7dc4512877a3d575ef1b21a36d8d4 Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Tue, 29 Aug 2023 18:41:51 +0300 Subject: [PATCH] Mark expected floating promises with the `void` operator Update @balena/lint from 7.0.2 to 7.1.1 Change-type: patch See: https://github.com/balena-io/pinejs/pull/682#discussion_r1308867996 --- init.ts | 7 +++---- package-lock.json | 8 ++++---- package.json | 2 +- src/features/device-heartbeat/index.ts | 12 ++++-------- src/features/device-logs/lib/backends/redis.ts | 15 +++++---------- .../hooks/cache-invalidation.ts | 3 +-- src/features/device-provisioning/register.ts | 6 ++---- .../hooks/device-types-cache-invalidation.ts | 6 ++---- test/13_loki-backend.ts | 6 ++---- 9 files changed, 24 insertions(+), 41 deletions(-) diff --git a/init.ts b/init.ts index 019345bd30..295c824bd5 100644 --- a/init.ts +++ b/init.ts @@ -138,8 +138,7 @@ async function onInitHooks() { }); // Pre-fetch the device types and populate the cache w/o blocking the API startup - // eslint-disable-next-line @typescript-eslint/no-floating-promises - getAccessibleDeviceTypes(sbvrUtils.api.resin); + void getAccessibleDeviceTypes(sbvrUtils.api.resin); await sbvrUtils.db.transaction((tx) => createAll(tx, permissionNames, auth.ROLES, auth.KEYS, {}), @@ -257,5 +256,5 @@ const init = async () => { process.exit(1); } }; -// eslint-disable-next-line @typescript-eslint/no-floating-promises -init(); + +void init(); diff --git a/package-lock.json b/package-lock.json index a7811a5fbb..c22b998214 100644 --- a/package-lock.json +++ b/package-lock.json @@ -97,7 +97,7 @@ "validator": "^13.9.0" }, "devDependencies": { - "@balena/lint": "^7.0.2", + "@balena/lint": "^7.1.1", "@types/chai": "^4.3.4", "@types/mocha": "^10.0.1", "@types/mockery": "^1.4.30", @@ -2853,9 +2853,9 @@ } }, "node_modules/@balena/lint": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@balena/lint/-/lint-7.0.2.tgz", - "integrity": "sha512-oG0S5DQxjyoVan6j9wnFBQGSFzaqzKCEzSjelSNIVmIGdhDwfTr7WDBGZzoLVpkg4FMpsFPnoWnY/pe/59BAjA==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@balena/lint/-/lint-7.1.1.tgz", + "integrity": "sha512-3h9M+0G4vCfH9bt4xxA8tLDUTn4Px83eBpU9WvD1/1uTnb2RtUa1dMxcX7ZhDs9Aw3waz8ewEzib8vSu2thtHA==", "dev": true, "dependencies": { "@types/eslint": "^8.44.2", diff --git a/package.json b/package.json index 78606da9b6..8d96b1f4d3 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "validator": "^13.9.0" }, "devDependencies": { - "@balena/lint": "^7.0.2", + "@balena/lint": "^7.1.1", "@types/chai": "^4.3.4", "@types/mocha": "^10.0.1", "@types/mockery": "^1.4.30", diff --git a/src/features/device-heartbeat/index.ts b/src/features/device-heartbeat/index.ts index b4125d2d86..abbd5e7d27 100644 --- a/src/features/device-heartbeat/index.ts +++ b/src/features/device-heartbeat/index.ts @@ -195,8 +195,7 @@ export class DeviceOnlineStateManager extends EventEmitter<{ }); // create the RedisMQ queue and start consuming messages... - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this.rsmq + void this.rsmq .createQueueAsync({ qname: DeviceOnlineStateManager.EXPIRED_QUEUE }) .catch((err) => { if (err.name !== 'queueExists') { @@ -211,8 +210,7 @@ export class DeviceOnlineStateManager extends EventEmitter<{ } private setupQueueStatsEmitter(interval: number) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - setTimeout(interval, undefined, { ref: false }).then(async () => { + void setTimeout(interval, undefined, { ref: false }).then(async () => { try { const startAt = Date.now(); const queueAttributes = await this.rsmq.getQueueAttributesAsync({ @@ -282,8 +280,7 @@ export class DeviceOnlineStateManager extends EventEmitter<{ private consume() { // pull a message from the queue... - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this.rsmq + void this.rsmq .receiveMessageAsync({ qname: DeviceOnlineStateManager.EXPIRED_QUEUE, vt: DeviceOnlineStateManager.RSMQ_READ_TIMEOUT, // prevent other consumers seeing the same message (if any) preventing multiple API agents from processing it... @@ -308,8 +305,7 @@ export class DeviceOnlineStateManager extends EventEmitter<{ deviceId, DeviceOnlineStates.Timeout, ); - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this.scheduleChangeOfStateForDevice( + void this.scheduleChangeOfStateForDevice( deviceId, await this.getDeviceOnlineState(deviceId), DeviceOnlineStates.Timeout, diff --git a/src/features/device-logs/lib/backends/redis.ts b/src/features/device-logs/lib/backends/redis.ts index 390c4ab5f5..6b5a90dc1c 100644 --- a/src/features/device-logs/lib/backends/redis.ts +++ b/src/features/device-logs/lib/backends/redis.ts @@ -183,15 +183,12 @@ export class RedisBackend implements DeviceLogsBackend { const key = this.getKey(ctx); if (!this.subscriptions.listenerCount(key)) { const subscribersKey = this.getKey(ctx, 'subscribers'); - // eslint-disable-next-line @typescript-eslint/no-floating-promises - pubSub[SUBSCRIBECMD](key); + void pubSub[SUBSCRIBECMD](key); // Increment the subscribers counter to recognize we've subscribed - // eslint-disable-next-line @typescript-eslint/no-floating-promises - redis.incrSubscribers(subscribersKey); + void redis.incrSubscribers(subscribersKey); // Start a heartbeat to ensure the subscribers counter stays alive whilst we're subscribed this.subscriptionHeartbeats[key] = setInterval(() => { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - redis.expire(subscribersKey, LOGS_SUBSCRIPTION_EXPIRY_SECONDS); + void redis.expire(subscribersKey, LOGS_SUBSCRIPTION_EXPIRY_SECONDS); }, LOGS_SUBSCRIPTION_EXPIRY_HEARTBEAT_SECONDS); } this.subscriptions.on(key, subscription); @@ -205,8 +202,7 @@ export class RedisBackend implements DeviceLogsBackend { // Clear the heartbeat clearInterval(this.subscriptionHeartbeats[key]); // And decrement the subscribers counter - // eslint-disable-next-line @typescript-eslint/no-floating-promises - redis.decrSubscribers(subscribersKey).then((n) => { + void redis.decrSubscribers(subscribersKey).then((n) => { if (n < 0) { captureException( new Error(), @@ -214,8 +210,7 @@ export class RedisBackend implements DeviceLogsBackend { ); } }); - // eslint-disable-next-line @typescript-eslint/no-floating-promises - pubSub[UNSUBSCRIBECMD](key); + void pubSub[UNSUBSCRIBECMD](key); } } diff --git a/src/features/device-provisioning/hooks/cache-invalidation.ts b/src/features/device-provisioning/hooks/cache-invalidation.ts index fbc63fb117..59a5d3ea7f 100644 --- a/src/features/device-provisioning/hooks/cache-invalidation.ts +++ b/src/features/device-provisioning/hooks/cache-invalidation.ts @@ -31,8 +31,7 @@ const setupCacheInvalidation = ( tx.on('end', () => { for (const affectedItem of affectedItems) { // Run in the background as this is not a reason to fail the request - // eslint-disable-next-line @typescript-eslint/no-floating-promises - (async () => { + void (async () => { try { await cache.delete(affectedItem[keyProperty]); } catch (err) { diff --git a/src/features/device-provisioning/register.ts b/src/features/device-provisioning/register.ts index 6801549a03..e3234b2b03 100644 --- a/src/features/device-provisioning/register.ts +++ b/src/features/device-provisioning/register.ts @@ -70,8 +70,7 @@ export const register: RequestHandler = async (req, res) => { // TODO: Replace this manual rollback on request closure with a more generic/automated version onFinished(res, () => { if (!tx.isClosed()) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - tx.rollback(); + void tx.rollback(); } }); @@ -106,8 +105,7 @@ export const register: RequestHandler = async (req, res) => { // Clear the device existence cache for the just registered device // in case it tried to communicate with the API before registering - // eslint-disable-next-line @typescript-eslint/no-floating-promises - checkDeviceExistsIsFrozen.delete(response.uuid); + void checkDeviceExistsIsFrozen.delete(response.uuid); res.status(201).json(response); } catch (err) { diff --git a/src/features/device-types/hooks/device-types-cache-invalidation.ts b/src/features/device-types/hooks/device-types-cache-invalidation.ts index dd928ffbd5..f7e169a48d 100644 --- a/src/features/device-types/hooks/device-types-cache-invalidation.ts +++ b/src/features/device-types/hooks/device-types-cache-invalidation.ts @@ -5,8 +5,7 @@ hooks.addPureHook('POST', 'resin', 'application', { POSTRUN: async ({ request }) => { if (request.values.is_host) { // no need to wait for the cache invalidation - // eslint-disable-next-line @typescript-eslint/no-floating-promises - getDeviceTypes.delete(); + void getDeviceTypes.delete(); } }, }); @@ -16,8 +15,7 @@ hooks.addPureHook('PATCH', 'resin', 'application', { const affectedIds = request.affectedIds!; if (request.values.is_host && affectedIds.length !== 0) { // no need to wait for the cache invalidation - // eslint-disable-next-line @typescript-eslint/no-floating-promises - getDeviceTypes.delete(); + void getDeviceTypes.delete(); } }, }); diff --git a/test/13_loki-backend.ts b/test/13_loki-backend.ts index deba12deb3..a39127454d 100644 --- a/test/13_loki-backend.ts +++ b/test/13_loki-backend.ts @@ -99,8 +99,7 @@ describe('loki backend', () => { const loki = new LokiBackend(); const log = createLog(); const incomingLog = await new Bluebird(async (resolve) => { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - loki.subscribe(ctx, resolve); + void loki.subscribe(ctx, resolve); await setTimeout(100); // wait for the subscription to connect await loki.publish(ctx, [_.clone(log)]); }).timeout(5000, 'Subscription did not receive log'); @@ -112,8 +111,7 @@ describe('loki backend', () => { const loki = new LokiBackend(); await new Bluebird(async (resolve) => { let countLogs = 0; - // eslint-disable-next-line @typescript-eslint/no-floating-promises - loki.subscribe(ctx, () => { + void loki.subscribe(ctx, () => { countLogs += 1; if (countLogs === 5) { resolve();