Skip to content

Commit

Permalink
fix(ignore): Sync eslint settings from zhc (#23951)
Browse files Browse the repository at this point in the history
* fix(ignore): Sync eslint settings from zhc

* u
  • Loading branch information
Koenkk authored Sep 12, 2024
1 parent c6ca472 commit e642f7c
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default tseslint.config(
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'array-bracket-spacing': ['error', 'never'],
'no-return-await': 'error',
'@typescript-eslint/return-await': ['error', 'always'],
'object-curly-spacing': ['error', 'never'],
'@typescript-eslint/no-floating-promises': 'error',
},
Expand Down
8 changes: 4 additions & 4 deletions lib/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class Controller {
logger.error('Check https://www.zigbee2mqtt.io/guide/installation/20_zigbee2mqtt-fails-to-start.html for possible solutions');
logger.error('Exiting...');
logger.error((error as Error).stack!);
return this.exit(1);
return await this.exit(1);
}

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

// Call extensions
Expand Down Expand Up @@ -279,12 +279,12 @@ export class Controller {
}

this.sdNotify?.stopWatchdogMode();
return this.exit(code, restart);
return await this.exit(code, restart);
}

async exit(code: number, restart = false): Promise<void> {
await logger.end();
return this.exitCallback(code, restart);
return await this.exitCallback(code, restart);
}

@bind async onZigbeeAdapterDisconnected(): Promise<void> {
Expand Down
14 changes: 7 additions & 7 deletions lib/extension/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default class Bridge extends Extension {

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

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

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

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

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

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

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

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

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

@bind async restart(message: string | KeyValue): Promise<MQTTResponse> {
Expand Down
2 changes: 1 addition & 1 deletion lib/extension/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class Frontend extends Extension {
this.wss?.close();
/* istanbul ignore else */
if (this.server) {
return new Promise((cb: () => void) => this.server!.close(cb));
return await new Promise((cb: () => void) => this.server!.close(cb));
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/extension/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ export default class HomeAssistant extends Extension {
this.eventBus.onDeviceInterview(this, this.onZigbeeEvent);
this.eventBus.onDeviceMessage(this, this.onZigbeeEvent);
this.eventBus.onScenesChanged(this, this.onScenesChanged);
this.eventBus.onEntityOptionsChanged(this, async (data) => this.discover(data.entity));
this.eventBus.onExposesChanged(this, async (data) => this.discover(data.device));
this.eventBus.onEntityOptionsChanged(this, async (data) => await this.discover(data.entity));
this.eventBus.onExposesChanged(this, async (data) => await this.discover(data.device));

this.mqtt.subscribe(this.statusTopic);
this.mqtt.subscribe(DEFAULT_STATUS_TOPIC);
Expand Down
6 changes: 3 additions & 3 deletions lib/extension/networkMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export default class NetworkMap extends Extension {
} catch {
// Network is possibly congested, sleep 5 seconds to let the network settle.
await utils.sleep(5);
return request();
return await request();
}
};

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

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

if (includeRoutes) {
try {
const result = await requestWithRetry<zh.RoutingTable>(async () => device.zh.routingTable());
const result = await requestWithRetry<zh.RoutingTable>(async () => await device.zh.routingTable());
routingTables.set(device, result);
logger.debug(`Routing table succeeded for '${device.name}'`);
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions lib/mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class MQTT {
options.rejectUnauthorized = false;
}

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

return new Promise<void>((resolve) => {
return await new Promise<void>((resolve) => {
this.client.publish(topic, payload, actualOptions, () => resolve());
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function getZigbee2MQTTVersion(includeCommitHash = true): Promise<{commitH
return {version: packageJSON.version, commitHash: undefined};
}

return new Promise((resolve) => {
return await new Promise((resolve) => {
const version = packageJSON.version;

git.getLastCommit((err: Error, commit: {shortHash: string}) => {
Expand Down
12 changes: 6 additions & 6 deletions lib/zigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ export default class Zigbee {
}

async getCoordinatorVersion(): Promise<zh.CoordinatorVersion> {
return this.herdsman.getCoordinatorVersion();
return await this.herdsman.getCoordinatorVersion();
}

isStopping(): boolean {
return this.herdsman.isStopping();
}

async backup(): Promise<void> {
return this.herdsman.backup();
return await this.herdsman.backup();
}

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

async getNetworkParameters(): Promise<zh.NetworkParameters> {
return this.herdsman.getNetworkParameters();
return await this.herdsman.getNetworkParameters();
}

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

async touchlinkFactoryResetFirst(): Promise<boolean> {
return this.herdsman.touchlinkFactoryResetFirst();
return await this.herdsman.touchlinkFactoryResetFirst();
}

async touchlinkFactoryReset(ieeeAddr: string, channel: number): Promise<boolean> {
return this.herdsman.touchlinkFactoryReset(ieeeAddr, channel);
return await this.herdsman.touchlinkFactoryReset(ieeeAddr, channel);
}

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

async touchlinkScan(): Promise<{ieeeAddr: string; channel: number}[]> {
return this.herdsman.touchlinkScan();
return await this.herdsman.touchlinkScan();
}

createGroup(ID: number): Group {
Expand Down

0 comments on commit e642f7c

Please sign in to comment.