From a64ca86a0a18513f78a7e5f02a938f6083a26a29 Mon Sep 17 00:00:00 2001 From: Alexander Herlin Date: Thu, 20 Jun 2024 22:58:48 +0200 Subject: [PATCH] Fix import issues and update configurations --- .eslintrc | 75 ++++++++--------------------------- CHANGELOG.md | 4 ++ package.json | 5 ++- src/index.ts | 4 +- src/plejdApi.ts | 2 +- src/plejdPlatform.ts | 14 +++---- src/plejdPlatformAccessory.ts | 20 +++++----- src/plejdService.ts | 6 +-- tsconfig.json | 2 +- 9 files changed, 47 insertions(+), 85 deletions(-) diff --git a/.eslintrc b/.eslintrc index 1519264..55a9cac 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,69 +13,26 @@ "dist" ], "rules": { - "quotes": [ - "warn", - "single" - ], - "indent": [ - "warn", - 2, - { - "SwitchCase": 1 - } - ], - "semi": [ - "off" - ], + "quotes": ["warn", "single"], + "indent": ["warn", 2, { "SwitchCase": 1 }], + "semi": ["off"], + "comma-dangle": ["warn", "always-multiline"], "dot-notation": "off", "eqeqeq": "warn", - "curly": [ - "warn", - "all" - ], - "brace-style": [ - "warn" - ], - "prefer-arrow-callback": [ - "warn" - ], - "max-len": [ - "warn", - 140 - ], - "no-console": [ - "warn" - ], // use the provided Homebridge log method instead - "no-non-null-assertion": [ - "off" - ], - "comma-spacing": [ - "error" - ], - "no-multi-spaces": [ - "warn", - { - "ignoreEOLComments": true - } - ], - "no-trailing-spaces": [ - "warn" - ], - "lines-between-class-members": [ - "warn", - "always", - { - "exceptAfterSingleLine": true - } - ], + "curly": ["warn", "all"], + "brace-style": ["warn"], + "prefer-arrow-callback": ["warn"], + "max-len": ["warn", 140], + "no-console": ["warn"], // use the provided Homebridge log method instead + "no-non-null-assertion": ["off"], + "comma-spacing": ["error"], + "no-multi-spaces": ["warn", { "ignoreEOLComments": true }], + "no-trailing-spaces": ["warn"], + "lines-between-class-members": ["warn", "always", {"exceptAfterSingleLine": true}], "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/semi": [ - "warn" - ], - "@typescript-eslint/member-delimiter-style": [ - "warn" - ] + "@typescript-eslint/semi": ["warn"], + "@typescript-eslint/member-delimiter-style": ["warn"] } } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index adf1849..8125f36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ #### 1.3.6 (2024-06-20) +Fix import issues and update configurations + +#### 1.3.6 (2024-06-20) + Update dependencies #### 1.3.5 (2024-03-14) diff --git a/package.json b/package.json index cd067ce..ba53ac4 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,10 @@ "displayName": "Plejd", "name": "homebridge-plejd", "author": "Herlix", - "version": "1.3.6", + "version": "1.3.7", "description": "HomeKit support for the Plejd BLE platform using Homebridge", "license": "Apache-2.0", + "type": "module", "repository": { "type": "git", "url": "git@github.com:Herlix/homebridge-plejd.git" @@ -22,7 +23,7 @@ "lint": "eslint src/**.ts --max-warnings=0", "watch": "npm run build && npm link && nodemon", "build": "rimraf ./dist && tsc", - "prepublishOnly": "npm run lint && npm run build" + "prepublishOnly": "npm run build" }, "keywords": ["homebridge-plugin", "plejd"], "dependencies": { diff --git a/src/index.ts b/src/index.ts index 4595987..9c98f4b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { API } from "homebridge"; -import { PLATFORM_NAME, PLUGIN_NAME } from "./settings"; -import { PlejdPlatform } from "./plejdPlatform"; +import { PLATFORM_NAME, PLUGIN_NAME } from "./settings.js"; +import { PlejdPlatform } from "./plejdPlatform.js"; /** * This method registers the platform with Homebridge diff --git a/src/plejdApi.ts b/src/plejdApi.ts index aa46a83..7a7feae 100644 --- a/src/plejdApi.ts +++ b/src/plejdApi.ts @@ -1,7 +1,7 @@ import axios from "axios"; import EventEmitter from "events"; import { Logger } from "homebridge"; -import { Site } from "./model/plejdSite"; +import { Site } from "./model/plejdSite.js"; const API_APP_ID = "zHtVqXt8k4yFyk2QGmgp48D9xZr2G94xWYnF4dak"; const API_BASE_URL = "https://cloud.plejd.com/parse/"; diff --git a/src/plejdPlatform.ts b/src/plejdPlatform.ts index cc383aa..21d769e 100644 --- a/src/plejdPlatform.ts +++ b/src/plejdPlatform.ts @@ -13,13 +13,13 @@ import { PLEJD_ADDONS, PLEJD_LIGHTS, PLUGIN_NAME, -} from "./settings"; -import { PlejdPlatformAccessoryHandler } from "./plejdPlatformAccessory"; -import { UserInputConfig } from "./model/userInputConfig"; -import { Device } from "./model/device"; -import { PlejdService } from "./plejdService"; -import PlejdRemoteApi from "./plejdApi"; -import { Site } from "./model/plejdSite"; +} from "./settings.js"; +import { PlejdPlatformAccessoryHandler } from "./plejdPlatformAccessory.js"; +import { UserInputConfig } from "./model/userInputConfig.js"; +import { Device } from "./model/device.js"; +import { PlejdService } from "./plejdService.js"; +import PlejdRemoteApi from "./plejdApi.js"; +import { Site } from "./model/plejdSite.js"; export class PlejdPlatform implements DynamicPlatformPlugin { public readonly Service: typeof Service; diff --git a/src/plejdPlatformAccessory.ts b/src/plejdPlatformAccessory.ts index bfd6f14..1ce1172 100644 --- a/src/plejdPlatformAccessory.ts +++ b/src/plejdPlatformAccessory.ts @@ -1,8 +1,8 @@ -import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge'; -import { Device } from './model/device'; +import { Service, PlatformAccessory, CharacteristicValue } from "homebridge"; +import { Device } from "./model/device.js"; -import { PlejdPlatform } from './plejdPlatform'; -import { PLATFORM_NAME } from './settings'; +import { PlejdPlatform } from "./plejdPlatform.js"; +import { PLATFORM_NAME } from "./settings.js"; interface DeviceState { isOn: boolean; @@ -75,7 +75,7 @@ export class PlejdPlatformAccessoryHandler { updateState = (isOn: boolean, brightness?: number) => { this.state.isOn = isOn; - this.platform.log.debug('updateState | Sending isOn', isOn); + this.platform.log.debug("updateState | Sending isOn", isOn); this.service .getCharacteristic(this.platform.Characteristic.On) .updateValue(isOn); @@ -83,7 +83,7 @@ export class PlejdPlatformAccessoryHandler { if (brightness) { this.state.brightness = Math.round(brightness); this.platform.log.debug( - 'update state | Sending brightness', + "update state | Sending brightness", this.state.brightness, ); this.service @@ -99,8 +99,8 @@ export class PlejdPlatformAccessoryHandler { const newVal = value as boolean; this.platform.log.info( `Updating state | ${this.device.name} | to ${ - newVal ? 'On' : 'off' - } | from ${this.state.isOn ? 'On' : 'Off'}`, + newVal ? "On" : "off" + } | from ${this.state.isOn ? "On" : "Off"}`, ); this.updateState(newVal, this.state.brightness); this.platform.plejdService?.updateState( @@ -112,7 +112,7 @@ export class PlejdPlatformAccessoryHandler { private getOn = async (): Promise => { this.platform.log.debug( - 'Get Characteristic On', + "Get Characteristic On", this.device.name, this.state.isOn, ); @@ -134,7 +134,7 @@ export class PlejdPlatformAccessoryHandler { private getBrightness = async (): Promise => { this.platform.log.debug( - 'Get Characteristic Brightness', + "Get Characteristic Brightness", this.device.name, this.state.brightness, ); diff --git a/src/plejdService.ts b/src/plejdService.ts index d4ffe39..4b3679f 100644 --- a/src/plejdService.ts +++ b/src/plejdService.ts @@ -1,14 +1,14 @@ import { Logger } from "homebridge"; -import { UserInputConfig } from "./model/userInputConfig"; +import { UserInputConfig } from "./model/userInputConfig.js"; import { plejdChalResp as plejdCharResp, plejdEncodeDecode, reverseBuffer, -} from "./plejdUtils"; +} from "./plejdUtils.js"; import { randomBytes } from "crypto"; import noble from "@abandonware/noble"; -import { PLEJD_WRITE_TIMEOUT } from "./settings"; +import { PLEJD_WRITE_TIMEOUT } from "./settings.js"; const NOBLE_IS_POWER_ON = "oweredOn"; diff --git a/tsconfig.json b/tsconfig.json index 6ceae25..d8c5d83 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,6 @@ "strict": true, "target": "ES2022" }, - "include": ["eslint.config.mjs", "homebridge-ui", "src"], + "include": ["eslint.config.mjs", "homebridge-ui", "src/**/*.ts"], "exclude": ["**/*.spec.ts"] }