diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index ab834d3..0000000 --- a/.eslintrc +++ /dev/null @@ -1,34 +0,0 @@ -{ - "parser": "@typescript-eslint/parser", - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended" // uses the recommended rules from the @typescript-eslint/eslint-plugin - ], - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module" - }, - "ignorePatterns": [ - "dist" - ], - "rules": { - "quotes": ["warn", "single"], - "indent": ["warn", 2, { "SwitchCase": 1 }], - "semi": ["warn", "always"], - "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 }], - "lines-between-class-members": ["warn", "always", {"exceptAfterSingleLine": true}], - "@typescript-eslint/semi": ["warn"], - "@typescript-eslint/member-delimiter-style": ["warn"] - } -} \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..b001663 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,54 @@ +import tsParser from '@typescript-eslint/parser'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import js from '@eslint/js'; +import { FlatCompat } from '@eslint/eslintrc'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +export default [{ + ignores: ['**/dist'], +}, ...compat.extends( + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', +), { + languageOptions: { + parser: tsParser, + ecmaVersion: 2018, + sourceType: 'module', + }, + + rules: { + quotes: ['warn', 'single'], + + indent: ['warn', 2, { + SwitchCase: 1, + }], + semi: ['warn', 'always'], + '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'], + 'no-non-null-assertion': ['off'], + 'comma-spacing': ['error'], + + 'no-multi-spaces': ['warn', { + ignoreEOLComments: true, + }], + + 'lines-between-class-members': ['warn', 'always', { + exceptAfterSingleLine: true, + }], + }, +}]; \ No newline at end of file diff --git a/src/color.ts b/src/color.ts index 64331ac..d790db0 100644 --- a/src/color.ts +++ b/src/color.ts @@ -99,12 +99,12 @@ export class Color { const q = 1 - f * s; const t = 1 - (1 - f) * s; switch (i % 6) { - case 0: g = t, b = p; break; - case 1: r = q, b = p; break; - case 2: r = p, b = t; break; - case 3: r = p, g = q; break; - case 4: r = t, g = p; break; - case 5: g = p, b = q; break; + case 0: g = t; b = p; break; + case 1: r = q; b = p; break; + case 2: r = p; b = t; break; + case 3: r = p; g = q; break; + case 4: r = t; g = p; break; + case 5: g = p; b = q; break; } // apply gamma correction @@ -262,12 +262,12 @@ export class Color { const q = v * (1 - f * s); const t = v * (1 - (1 - f) * s); switch (i % 6) { - case 0: r = v, g = t, b = p; break; - case 1: r = q, g = v, b = p; break; - case 2: r = p, g = v, b = t; break; - case 3: r = p, g = q, b = v; break; - case 4: r = t, g = p, b = v; break; - case 5: r = v, g = p, b = q; break; + case 0: r = v; g = t; b = p; break; + case 1: r = q; g = v; b = p; break; + case 2: r = p; g = v; b = t; break; + case 3: r = p; g = q; b = v; break; + case 4: r = t; g = p; b = v; break; + case 5: r = v; g = p; b = q; break; } return { r, diff --git a/src/tasmotaAccessory.ts b/src/tasmotaAccessory.ts index 4ffc0b1..abbddd1 100644 --- a/src/tasmotaAccessory.ts +++ b/src/tasmotaAccessory.ts @@ -102,7 +102,7 @@ export class TasmotaAccessory { try { obj = JSON.parse(message); this.updateStatus(obj); - } catch (err) { + } catch { this.updateStatus({ message }); } }); diff --git a/src/zigbee2TasmotaAccessory.ts b/src/zigbee2TasmotaAccessory.ts index ca11f8e..3ae150a 100644 --- a/src/zigbee2TasmotaAccessory.ts +++ b/src/zigbee2TasmotaAccessory.ts @@ -125,7 +125,7 @@ export abstract class Zigbee2TasmotaAccessory { this.statusUpdate(devObj); } } - } catch (err) { + } catch { this.platform.log.error('SENSOR message parse error: %s', message); } }