Skip to content

Commit

Permalink
Code enhancements and bug fixes
Browse files Browse the repository at this point in the history
### UPDATED
- Package dependencies.
- Re-configured ESLint linting options.
- Report URL changed.
- Minor changes to Config UI.
- During try catch, caught error objects will now be checked before serializing.

### FIXED
- Some types ended with `,` instead of `;`.
- Some types did not properly separated with `:`.
- Imports for React components should not end with `.js` file extension.
- The form select for setup verification method is missing the `key` prop.

### ADDED
- Security panel support for "DSC Impassa/SCW".
- Package version in title when debug information is sent to plugin author.
  • Loading branch information
mrjackyliang committed Jan 8, 2025
1 parent 3dfcc8b commit 93c1609
Show file tree
Hide file tree
Showing 26 changed files with 1,275 additions and 783 deletions.
143 changes: 0 additions & 143 deletions .eslintrc.json

This file was deleted.

91 changes: 91 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import javascriptPlugin from '@eslint/js';
import stylisticPlugin from '@stylistic/eslint-plugin';
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import importPlugin from 'eslint-plugin-import';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import globals from 'globals';

/**
* ESLint config.
*
* @type {import('eslint').Linter.Config[]}
*
* @since 1.0.0
*/
const eslintConfig = [
{
name: 'preferred-rules',
files: [
'**/*.js',
'**/*.mjs',
'**/*.cjs',
'**/*.jsx',
'**/*.ts',
'**/*.mts',
'**/*.cts',
'**/*.tsx',
],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
NodeJS: 'readonly',
},
parser: typescriptParser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
project: './tsconfig.json',
sourceType: 'module',
},
},
plugins: {
'@stylistic': stylisticPlugin,
'@typescript-eslint': typescriptPlugin,
'import': importPlugin,
'jsx-a11y': jsxA11yPlugin,
react: reactPlugin,
'react-hooks': reactHooksPlugin,
},
settings: {
'import/resolver': {
typescript: {
project: './tsconfig.json',
},
},
react: {
version: 'detect',
},
},
rules: {
...importPlugin.configs.recommended.rules,
...javascriptPlugin.configs.recommended.rules,
...jsxA11yPlugin.configs.recommended.rules,
...reactPlugin.configs.recommended.rules,
...reactHooksPlugin.configs.recommended.rules,
...stylisticPlugin.configs['recommended-flat'].rules,
...typescriptPlugin.configs.recommended.rules,
'@stylistic/arrow-parens': ['error', 'always'],
'@stylistic/brace-style': ['error', '1tbs'],
'@stylistic/comma-dangle': ['error', 'always-multiline'],
'@stylistic/member-delimiter-style': ['error', { singleline: { requireLast: true } }],
'@stylistic/multiline-ternary': ['off'],
'@stylistic/quote-props': ['error', 'as-needed'],
'@stylistic/quotes': ['error', 'single'],
'@stylistic/semi': ['error', 'always'],
'@typescript-eslint/no-explicit-any': ['off'],
'@typescript-eslint/no-unused-vars': ['error'],
'import/order': ['error', { alphabetize: { order: 'asc' } }],
'no-console': ['warn', { allow: ['error', 'info', 'warn'] }],
'no-irregular-whitespace': ['error', { skipComments: true }],
'no-unused-vars': ['off'],
},
},
];

export default eslintConfig;
59 changes: 31 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "homebridge-adt-pulse",
"displayName": "Homebridge ADT Pulse",
"version": "3.4.4",
"version": "3.4.5",
"description": "Homebridge security system platform for ADT Pulse",
"main": "./build/index.js",
"exports": "./build/index.js",
Expand Down Expand Up @@ -66,49 +66,52 @@
"node": ">=20"
},
"dependencies": {
"@faker-js/faker": "9.2.0",
"@homebridge/plugin-ui-utils": "1.0.3",
"@hookform/resolvers": "3.9.1",
"axios": "1.7.7",
"axios-cookiejar-support": "5.0.3",
"chalk": "5.3.0",
"@faker-js/faker": "9.3.0",
"@homebridge/plugin-ui-utils": "2.0.0",
"@hookform/resolvers": "3.10.0",
"axios": "1.7.9",
"axios-cookiejar-support": "5.0.5",
"chalk": "5.4.1",
"jsdom": "25.0.1",
"latest-version": "9.0.0",
"lodash": "4.17.21",
"luxon": "3.5.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-hook-form": "7.53.1",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-hook-form": "7.54.2",
"semver": "7.6.3",
"serialize-error": "11.0.3",
"serialize-error": "12.0.0",
"tough-cookie": "5.0.0",
"ua-parser-js": "2.0.0-beta.3",
"zod": "3.23.8"
"ua-parser-js": "2.0.0",
"zod": "3.24.1"
},
"devDependencies": {
"@eslint/js": "9.17.0",
"@stylistic/eslint-plugin": "2.12.1",
"@types/jsdom": "21.1.7",
"@types/lodash": "4.17.13",
"@types/lodash": "4.17.14",
"@types/luxon": "3.4.2",
"@types/node": "22.9.0",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@types/node": "22.10.5",
"@types/react": "19.0.3",
"@types/react-dom": "19.0.2",
"@types/semver": "7.5.8",
"@types/tough-cookie": "4.0.5",
"@typescript-eslint/eslint-plugin": "7.17.0",
"@typescript-eslint/parser": "7.17.0",
"@vitejs/plugin-react": "4.3.3",
"eslint": "8.56.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "18.0.0",
"@typescript-eslint/eslint-plugin": "8.19.1",
"@typescript-eslint/parser": "8.19.1",
"@vitejs/plugin-react": "4.3.4",
"eslint": "9.17.0",
"eslint-import-resolver-typescript": "3.7.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-jsx-a11y": "6.10.2",
"eslint-plugin-react": "7.37.2",
"homebridge": "1.8.4",
"eslint-plugin-react": "7.37.3",
"eslint-plugin-react-hooks": "5.1.0",
"globals": "15.14.0",
"homebridge": "1.8.5",
"npm-run-all": "4.1.5",
"rimraf": "6.0.1",
"tsconfig-replace-paths": "0.0.14",
"typescript": "5.5.4",
"vite": "5.4.10",
"vite-tsconfig-paths": "5.1.0"
"typescript": "5.7.2",
"vite": "6.0.7",
"vite-tsconfig-paths": "5.1.4"
}
}
8 changes: 4 additions & 4 deletions src/config-ui/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HomebridgePluginUiServer, RequestError } from '@homebridge/plugin-ui-utils';
import _ from 'lodash';
import { serializeError } from 'serialize-error';
import { isErrorLike, serializeError } from 'serialize-error';

import { ADTPulseAuth } from '@/lib/auth.js';
import { configServerLogin, configServerRequestCode, configServerValidate } from '@/lib/schema.js';
Expand Down Expand Up @@ -223,7 +223,7 @@ class ADTPulseConfigServer extends HomebridgePluginUiServer {
info: response.info,
};
} catch (error) {
const serializedError = serializeError(error);
const serializedError = (isErrorLike(error)) ? serializeError(error) : serializeError(new Error('Unknown error'));

debugLog(null, 'server.ts / ADTPulseConfigServer.requestCode()', 'error', 'Method encountered an error during execution');

Expand Down Expand Up @@ -307,7 +307,7 @@ class ADTPulseConfigServer extends HomebridgePluginUiServer {
info: null,
};
} catch (error) {
const serializedError = serializeError(error);
const serializedError = (isErrorLike(error)) ? serializeError(error) : serializeError(new Error('Unknown error'));

debugLog(null, 'server.ts / ADTPulseConfigServer.validate()', 'error', 'Method encountered an error during execution');

Expand Down Expand Up @@ -386,7 +386,7 @@ class ADTPulseConfigServer extends HomebridgePluginUiServer {
},
};
} catch (error) {
const serializedError = serializeError(error);
const serializedError = (isErrorLike(error)) ? serializeError(error) : serializeError(new Error('Unknown error'));

debugLog(null, 'server.ts / ADTPulseConfigServer.generateConfig()', 'error', 'Method encountered an error during execution');

Expand Down
Loading

0 comments on commit 93c1609

Please sign in to comment.