homebridge-plugin-utils 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -141,8 +141,12 @@ const tsRules = {
141
141
  "@typescript-eslint/no-explicit-any": "warn",
142
142
  "@typescript-eslint/no-floating-promises": ["warn", { "ignoreIIFE": true }],
143
143
  "@typescript-eslint/no-non-null-assertion": "warn",
144
+ "@typescript-eslint/no-unused-expressions": "warn",
145
+ "@typescript-eslint/no-unused-vars": "warn",
146
+ "@typescript-eslint/promise-function-async": "warn",
144
147
  "no-dupe-class-members": "off",
145
148
  "no-undef": "off",
149
+ "no-unused-expressions": "off",
146
150
  "no-unused-vars": "off"
147
151
  };
148
152
 
@@ -150,7 +154,8 @@ const tsRules = {
150
154
  const jsRules = {
151
155
 
152
156
  ...tsEslint.configs.disableTypeChecked,
153
- "@typescript-eslint/no-floating-promises": "off"
157
+ "@typescript-eslint/no-floating-promises": "off",
158
+ "require-await": "warn"
154
159
  };
155
160
 
156
161
  // Rules that exist across both JavaScript and TypeScript files.
@@ -209,6 +214,7 @@ const commonRules = {
209
214
  "no-await-in-loop": "warn",
210
215
  "no-console": "warn",
211
216
  "prefer-arrow-callback": "warn",
217
+ "prefer-const": "warn",
212
218
  "quotes": ["warn", "double", { "avoidEscape": true }],
213
219
  "sort-imports": "warn",
214
220
  "sort-keys": "warn",
@@ -336,7 +336,7 @@ export class webUiFeatureOptions {
336
336
  }
337
337
 
338
338
  // Show feature option information for a specific device, controller, or globally.
339
- async showDeviceOptions(deviceId) {
339
+ showDeviceOptions(deviceId) {
340
340
 
341
341
  homebridge.showSpinner();
342
342
 
@@ -742,7 +742,7 @@ export class webUiFeatureOptions {
742
742
  }
743
743
 
744
744
  // Default method for enumerating the device list in the sidebar.
745
- async #showSidebarDevices() {
745
+ #showSidebarDevices() {
746
746
 
747
747
  // Show the devices list only if we have actual devices to show.
748
748
  if(!this.devices?.length) {
package/dist/utils.d.ts CHANGED
@@ -28,4 +28,4 @@ export interface HomebridgePluginLogging {
28
28
  warn: (message: string, ...parameters: unknown[]) => void;
29
29
  }
30
30
  export declare function sleep(sleepTimer: number): Promise<NodeJS.Timeout>;
31
- export declare function retry(operation: () => Promise<boolean>, retryInterval: number): Promise<boolean>;
31
+ export declare function retry(operation: () => Promise<boolean>, retryInterval: number, totalRetries?: number): Promise<boolean>;
package/dist/utils.js CHANGED
@@ -3,16 +3,19 @@
3
3
  * utils.ts: Useful utility functions when writing TypeScript.
4
4
  */
5
5
  // Emulate a sleep function.
6
- export function sleep(sleepTimer) {
6
+ export async function sleep(sleepTimer) {
7
7
  return new Promise(resolve => setTimeout(resolve, sleepTimer));
8
8
  }
9
9
  // Retry an operation until we're successful.
10
- export async function retry(operation, retryInterval) {
10
+ export async function retry(operation, retryInterval, totalRetries) {
11
+ if ((totalRetries !== undefined) && (totalRetries < 0)) {
12
+ return false;
13
+ }
11
14
  // Try the operation that was requested.
12
15
  if (!(await operation())) {
13
16
  // If the operation wasn't successful, let's sleep for the requested interval and try again.
14
17
  await sleep(retryInterval);
15
- return retry(operation, retryInterval);
18
+ return retry(operation, retryInterval, (totalRetries === undefined) ? undefined : totalRetries--);
16
19
  }
17
20
  // We were successful - we're done.
18
21
  return true;
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH,4BAA4B;AAC5B,MAAM,UAAU,KAAK,CAAC,UAAkB;IAEtC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,6CAA6C;AAC7C,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,SAAiC,EAAE,aAAqB;IAElF,wCAAwC;IACxC,IAAG,CAAC,CAAC,MAAM,SAAS,EAAE,CAAC,EAAE,CAAC;QAExB,4FAA4F;QAC5F,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC;QAE3B,OAAO,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACzC,CAAC;IAED,mCAAmC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH,4BAA4B;AAC5B,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,UAAkB;IAE5C,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,6CAA6C;AAC7C,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,SAAiC,EAAE,aAAqB,EAAE,YAAqB;IAEzG,IAAG,CAAC,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,EAAE,CAAC;QAEtD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,wCAAwC;IACxC,IAAG,CAAC,CAAC,MAAM,SAAS,EAAE,CAAC,EAAE,CAAC;QAExB,4FAA4F;QAC5F,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC;QAE3B,OAAO,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,mCAAmC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-plugin-utils",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "displayName": "Homebridge Plugin Utilities",
5
5
  "description": "Opinionated utilities to provide common capabilities and create rich configuration webUI experiences for Homebridge plugins.",
6
6
  "author": {
@@ -40,11 +40,11 @@
40
40
  "main": "dist/index.js",
41
41
  "devDependencies": {
42
42
  "@stylistic/eslint-plugin": "2.1.0",
43
- "@types/node": "20.13.0",
43
+ "@types/node": "20.14.2",
44
44
  "eslint": "8.57.0",
45
45
  "shx": "^0.3.4",
46
46
  "typescript": "5.4.5",
47
- "typescript-eslint": "^7.11.0"
47
+ "typescript-eslint": "^7.12.0"
48
48
  },
49
49
  "dependencies": {
50
50
  "mqtt": "^5.7.0"