Skip to content

Commit e642f7c

Browse files
authored
fix(ignore): Sync eslint settings from zhc (#23951)
* fix(ignore): Sync eslint settings from zhc * u
1 parent c6ca472 commit e642f7c

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

eslint.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default tseslint.config(
2020
'@typescript-eslint/no-explicit-any': 'error',
2121
'@typescript-eslint/no-unused-vars': 'error',
2222
'array-bracket-spacing': ['error', 'never'],
23-
'no-return-await': 'error',
23+
'@typescript-eslint/return-await': ['error', 'always'],
2424
'object-curly-spacing': ['error', 'never'],
2525
'@typescript-eslint/no-floating-promises': 'error',
2626
},

lib/controller.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class Controller {
165165
logger.error('Check https://www.zigbee2mqtt.io/guide/installation/20_zigbee2mqtt-fails-to-start.html for possible solutions');
166166
logger.error('Exiting...');
167167
logger.error((error as Error).stack!);
168-
return this.exit(1);
168+
return await this.exit(1);
169169
}
170170

171171
// Disable some legacy options on new network creation
@@ -211,7 +211,7 @@ export class Controller {
211211
} catch (error) {
212212
logger.error(`MQTT failed to connect, exiting... (${(error as Error).message})`);
213213
await this.zigbee.stop();
214-
return this.exit(1);
214+
return await this.exit(1);
215215
}
216216

217217
// Call extensions
@@ -279,12 +279,12 @@ export class Controller {
279279
}
280280

281281
this.sdNotify?.stopWatchdogMode();
282-
return this.exit(code, restart);
282+
return await this.exit(code, restart);
283283
}
284284

285285
async exit(code: number, restart = false): Promise<void> {
286286
await logger.end();
287-
return this.exitCallback(code, restart);
287+
return await this.exitCallback(code, restart);
288288
}
289289

290290
@bind async onZigbeeAdapterDisconnected(): Promise<void> {

lib/extension/bridge.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export default class Bridge extends Extension {
141141

142142
// Zigbee events
143143
const publishEvent = async (type: string, data: KeyValue): Promise<void> =>
144-
this.mqtt.publish('bridge/event', stringify({type, data}), {retain: false, qos: 0});
144+
await this.mqtt.publish('bridge/event', stringify({type, data}), {retain: false, qos: 0});
145145
this.eventBus.onDeviceJoined(this, async (data) => {
146146
this.lastJoinedDeviceIeeeAddr = data.device.ieeeAddr;
147147
await this.publishDevices();
@@ -213,11 +213,11 @@ export default class Bridge extends Extension {
213213
*/
214214

215215
@bind async deviceOptions(message: KeyValue | string): Promise<MQTTResponse> {
216-
return this.changeEntityOptions('device', message);
216+
return await this.changeEntityOptions('device', message);
217217
}
218218

219219
@bind async groupOptions(message: KeyValue | string): Promise<MQTTResponse> {
220-
return this.changeEntityOptions('group', message);
220+
return await this.changeEntityOptions('group', message);
221221
}
222222

223223
@bind async bridgeOptions(message: KeyValue | string): Promise<MQTTResponse> {
@@ -256,11 +256,11 @@ export default class Bridge extends Extension {
256256
}
257257

258258
@bind async deviceRemove(message: string | KeyValue): Promise<MQTTResponse> {
259-
return this.removeEntity('device', message);
259+
return await this.removeEntity('device', message);
260260
}
261261

262262
@bind async groupRemove(message: string | KeyValue): Promise<MQTTResponse> {
263-
return this.removeEntity('group', message);
263+
return await this.removeEntity('group', message);
264264
}
265265

266266
@bind async healthCheck(message: string | KeyValue): Promise<MQTTResponse> {
@@ -289,11 +289,11 @@ export default class Bridge extends Extension {
289289
}
290290

291291
@bind async deviceRename(message: string | KeyValue): Promise<MQTTResponse> {
292-
return this.renameEntity('device', message);
292+
return await this.renameEntity('device', message);
293293
}
294294

295295
@bind async groupRename(message: string | KeyValue): Promise<MQTTResponse> {
296-
return this.renameEntity('group', message);
296+
return await this.renameEntity('group', message);
297297
}
298298

299299
@bind async restart(message: string | KeyValue): Promise<MQTTResponse> {

lib/extension/frontend.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default class Frontend extends Extension {
113113
this.wss?.close();
114114
/* istanbul ignore else */
115115
if (this.server) {
116-
return new Promise((cb: () => void) => this.server!.close(cb));
116+
return await new Promise((cb: () => void) => this.server!.close(cb));
117117
}
118118
}
119119

lib/extension/homeassistant.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ export default class HomeAssistant extends Extension {
485485
this.eventBus.onDeviceInterview(this, this.onZigbeeEvent);
486486
this.eventBus.onDeviceMessage(this, this.onZigbeeEvent);
487487
this.eventBus.onScenesChanged(this, this.onScenesChanged);
488-
this.eventBus.onEntityOptionsChanged(this, async (data) => this.discover(data.entity));
489-
this.eventBus.onExposesChanged(this, async (data) => this.discover(data.device));
488+
this.eventBus.onEntityOptionsChanged(this, async (data) => await this.discover(data.entity));
489+
this.eventBus.onExposesChanged(this, async (data) => await this.discover(data.device));
490490

491491
this.mqtt.subscribe(this.statusTopic);
492492
this.mqtt.subscribe(DEFAULT_STATUS_TOPIC);

lib/extension/networkMap.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export default class NetworkMap extends Extension {
220220
} catch {
221221
// Network is possibly congested, sleep 5 seconds to let the network settle.
222222
await utils.sleep(5);
223-
return request();
223+
return await request();
224224
}
225225
};
226226

@@ -233,7 +233,7 @@ export default class NetworkMap extends Extension {
233233
await utils.sleep(1); // sleep 1 second between each scan to reduce stress on network.
234234

235235
try {
236-
const result = await requestWithRetry<zh.LQI>(async () => device.zh.lqi());
236+
const result = await requestWithRetry<zh.LQI>(async () => await device.zh.lqi());
237237
lqis.set(device, result);
238238
logger.debug(`LQI succeeded for '${device.name}'`);
239239
} catch (error) {
@@ -244,7 +244,7 @@ export default class NetworkMap extends Extension {
244244

245245
if (includeRoutes) {
246246
try {
247-
const result = await requestWithRetry<zh.RoutingTable>(async () => device.zh.routingTable());
247+
const result = await requestWithRetry<zh.RoutingTable>(async () => await device.zh.routingTable());
248248
routingTables.set(device, result);
249249
logger.debug(`Routing table succeeded for '${device.name}'`);
250250
} catch (error) {

lib/mqtt.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default class MQTT {
8080
options.rejectUnauthorized = false;
8181
}
8282

83-
return new Promise((resolve, reject) => {
83+
return await new Promise((resolve, reject) => {
8484
this.client = mqtt.connect(mqttSettings.server, options);
8585
// https://github.com/Koenkk/zigbee2mqtt/issues/9822
8686
this.client.stream.setMaxListeners(0);
@@ -206,7 +206,7 @@ export default class MQTT {
206206
actualOptions.retain = false;
207207
}
208208

209-
return new Promise<void>((resolve) => {
209+
return await new Promise<void>((resolve) => {
210210
this.client.publish(topic, payload, actualOptions, () => resolve());
211211
});
212212
}

lib/util/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function getZigbee2MQTTVersion(includeCommitHash = true): Promise<{commitH
5353
return {version: packageJSON.version, commitHash: undefined};
5454
}
5555

56-
return new Promise((resolve) => {
56+
return await new Promise((resolve) => {
5757
const version = packageJSON.version;
5858

5959
git.getLastCommit((err: Error, commit: {shortHash: string}) => {

lib/zigbee.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,15 @@ export default class Zigbee {
199199
}
200200

201201
async getCoordinatorVersion(): Promise<zh.CoordinatorVersion> {
202-
return this.herdsman.getCoordinatorVersion();
202+
return await this.herdsman.getCoordinatorVersion();
203203
}
204204

205205
isStopping(): boolean {
206206
return this.herdsman.isStopping();
207207
}
208208

209209
async backup(): Promise<void> {
210-
return this.herdsman.backup();
210+
return await this.herdsman.backup();
211211
}
212212

213213
async coordinatorCheck(): Promise<{missingRouters: Device[]}> {
@@ -216,7 +216,7 @@ export default class Zigbee {
216216
}
217217

218218
async getNetworkParameters(): Promise<zh.NetworkParameters> {
219-
return this.herdsman.getNetworkParameters();
219+
return await this.herdsman.getNetworkParameters();
220220
}
221221

222222
async reset(type: 'soft' | 'hard'): Promise<void> {
@@ -386,11 +386,11 @@ export default class Zigbee {
386386
}
387387

388388
async touchlinkFactoryResetFirst(): Promise<boolean> {
389-
return this.herdsman.touchlinkFactoryResetFirst();
389+
return await this.herdsman.touchlinkFactoryResetFirst();
390390
}
391391

392392
async touchlinkFactoryReset(ieeeAddr: string, channel: number): Promise<boolean> {
393-
return this.herdsman.touchlinkFactoryReset(ieeeAddr, channel);
393+
return await this.herdsman.touchlinkFactoryReset(ieeeAddr, channel);
394394
}
395395

396396
async addInstallCode(installCode: string): Promise<void> {
@@ -402,7 +402,7 @@ export default class Zigbee {
402402
}
403403

404404
async touchlinkScan(): Promise<{ieeeAddr: string; channel: number}[]> {
405-
return this.herdsman.touchlinkScan();
405+
return await this.herdsman.touchlinkScan();
406406
}
407407

408408
createGroup(ID: number): Group {

0 commit comments

Comments
 (0)