diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c7c6685725..fa47fae25b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,12 +35,13 @@ jobs: - name: Install dependencies run: npm install - - name: Run linters - run: npm run lint - - name: Run Build run: npm run build + # For linting need some build time generated file + - name: Run linters + run: npm run lint + - name: Run Build Web run: npm run build:web diff --git a/eslint.config.mjs b/eslint.config.mjs index 11ad278b01c..fab49434f08 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -12,7 +12,6 @@ const globalIgnores = [ export const typescriptRules = { '@typescript-eslint/no-unnecessary-type-assertion': 'off', - '@typescript-eslint/no-unsafe-argument': 'off', '@typescript-eslint/no-unsafe-assignment': 'off', '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-unsafe-enum-comparison': 'off', diff --git a/packages/kboot/src/kboot.ts b/packages/kboot/src/kboot.ts index 8e45df2c709..fd06dc752e9 100644 --- a/packages/kboot/src/kboot.ts +++ b/packages/kboot/src/kboot.ts @@ -172,7 +172,7 @@ export class KBoot { } catch (error) { logger(`Reset command error message: "${error.message}"`); - if (RESET_IGNORED_ERRORS.includes(error.message)) { + if (RESET_IGNORED_ERRORS.includes(error.message as string)) { logger('Ignoring missing response from reset command.'); await this.close() diff --git a/packages/mcumgr/src/mcumgr.ts b/packages/mcumgr/src/mcumgr.ts index 03297fe53a6..bde90a07a4c 100644 --- a/packages/mcumgr/src/mcumgr.ts +++ b/packages/mcumgr/src/mcumgr.ts @@ -126,7 +126,7 @@ export class McuManager { async sendCommand(op: MGMT_OP_TYPE, group: MGMT_GROUP_TYPE, id: MGMT_OPERATION_TYPE, data?: unknown): Promise> { logger('Start send command: %o', {op, group, id, data}); - let encodedData = []; + let encodedData: number[] = []; if (typeof data !== 'undefined') { // the command data is cbor encoded const buffer = cbor.encode(data); diff --git a/packages/mcumgr/src/util/cbor.ts b/packages/mcumgr/src/util/cbor.ts index d57975d04d8..a3d84c68529 100644 --- a/packages/mcumgr/src/util/cbor.ts +++ b/packages/mcumgr/src/util/cbor.ts @@ -19,7 +19,7 @@ export function encode(value: unknown) { let lastLength: number; let offset = 0; - function prepareWrite(length: number) { + function prepareWrite(length: number): DataView { let newByteLength = data.byteLength; const requiredLength = offset + length; while (newByteLength < requiredLength) @@ -39,25 +39,25 @@ export function encode(value: unknown) { function commitWrite(_?: unknown) { offset += lastLength; } - function writeFloat64(value) { + function writeFloat64(value: number): void { commitWrite(prepareWrite(8).setFloat64(offset, value)); } - function writeUint8(value) { + function writeUint8(value: number): void { commitWrite(prepareWrite(1).setUint8(offset, value)); } - function writeUint8Array(value) { + function writeUint8Array(value: number[] | Uint8Array): void { const dataView = prepareWrite(value.length); for (let i = 0; i < value.length; ++i) dataView.setUint8(offset + i, value[i]); commitWrite(); } - function writeUint16(value) { + function writeUint16(value: number): void { commitWrite(prepareWrite(2).setUint16(offset, value)); } - function writeUint32(value) { + function writeUint32(value: number): void { commitWrite(prepareWrite(4).setUint32(offset, value)); } - function writeUint64(value) { + function writeUint64(value: number): void { const low = value % POW_2_32; const high = (value - low) / POW_2_32; const dataView = prepareWrite(8); @@ -65,7 +65,7 @@ export function encode(value: unknown) { dataView.setUint32(offset + 4, low); commitWrite(); } - function writeTypeAndLength(type, length) { + function writeTypeAndLength(type: number, length: number): void { if (length < 24) { writeUint8(type << 5 | length); } else if (length < 0x100) { @@ -83,8 +83,9 @@ export function encode(value: unknown) { } } - function encodeItem(value) { - let i; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function encodeItem(value: any): void { + let i: number; if (value === false) return writeUint8(0xf4); @@ -108,7 +109,7 @@ export function encode(value: unknown) { } case "string": { - const utf8data = []; + const utf8data: number[] = []; for (i = 0; i < value.length; ++i) { let charCode = value.charCodeAt(i); if (charCode < 0x80) { @@ -137,7 +138,7 @@ export function encode(value: unknown) { } default: { - let length; + let length: number; if (Array.isArray(value)) { length = value.length; writeTypeAndLength(4, length); @@ -147,7 +148,7 @@ export function encode(value: unknown) { writeTypeAndLength(2, value.length); writeUint8Array(value); } else { - const keys = Object.keys(value); + const keys = Object.keys(value as Record); length = keys.length; writeTypeAndLength(5, length); for (i = 0; i < length; ++i) { @@ -181,11 +182,11 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function, if (typeof simpleValue !== "function") simpleValue = function() { return undefined; }; - function commitRead(length, value) { + function commitRead(length: number, value: T): T { offset += length; return value; } - function readArrayBuffer(length) { + function readArrayBuffer(length: number): Uint8Array { return commitRead(length, new Uint8Array(data, offset, length)); } function readFloat16() { @@ -207,22 +208,22 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function, tempDataView.setUint32(0, sign << 16 | exponent << 13 | fraction << 13); return tempDataView.getFloat32(0); } - function readFloat32() { + function readFloat32(): number { return commitRead(4, dataView.getFloat32(offset)); } - function readFloat64() { + function readFloat64(): number { return commitRead(8, dataView.getFloat64(offset)); } - function readUint8() { + function readUint8(): number { return commitRead(1, dataView.getUint8(offset)); } - function readUint16() { + function readUint16(): number { return commitRead(2, dataView.getUint16(offset)); } - function readUint32() { + function readUint32(): number { return commitRead(4, dataView.getUint32(offset)); } - function readUint64() { + function readUint64(): number { return readUint32() * POW_2_32 + readUint32(); } function readBreak() { @@ -231,7 +232,7 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function, offset += 1; return true; } - function readLength(additionalInformation) { + function readLength(additionalInformation: number): number { if (additionalInformation < 24) return additionalInformation; if (additionalInformation === 24) @@ -246,7 +247,7 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function, return -1; throw "Invalid length encoding"; } - function readIndefiniteStringLength(majorType) { + function readIndefiniteStringLength(majorType: number): number { const initialByte = readUint8(); if (initialByte === 0xff) return -1; @@ -256,7 +257,7 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function, return length; } - function appendUtf16Data(utf16data, length) { + function appendUtf16Data(utf16data: Array, length: number): void { for (let i = 0; i < length; ++i) { let value = readUint8(); if (value & 0x80) { @@ -292,8 +293,8 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function, const initialByte = readUint8(); const majorType = initialByte >> 5; const additionalInformation = initialByte & 0x1f; - let i; - let length; + let i: number; + let length: number; if (majorType === 7) { switch (additionalInformation) { @@ -321,7 +322,7 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function, case 2: { if (length < 0) { - const elements = []; + const elements: Uint8Array[] = []; let fullArrayLength = 0; while ((length = readIndefiniteStringLength(majorType)) >= 0) { fullArrayLength += length; @@ -339,7 +340,7 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function, } case 3: { - const utf16data = []; + const utf16data: number[] = []; if (length < 0) { while ((length = readIndefiniteStringLength(majorType)) >= 0) appendUtf16Data(utf16data, length); diff --git a/packages/test-serializer/test/test-convert-user-config-npm-script.test.ts b/packages/test-serializer/test/test-convert-user-config-npm-script.test.ts index c1c9d97b814..96f15c69de7 100644 --- a/packages/test-serializer/test/test-convert-user-config-npm-script.test.ts +++ b/packages/test-serializer/test/test-convert-user-config-npm-script.test.ts @@ -4,9 +4,9 @@ import path from 'node:path'; import { after, before, describe, it } from 'node:test'; describe('convert-user-config-to-bin npm script', () => { - let rootDirPath; - let tmpDirPath; - let tmpConfigPath; + let rootDirPath: string; + let tmpDirPath: string; + let tmpConfigPath: string; before(() => { rootDirPath = path.join(import.meta.dirname, '..', '..', '..'); diff --git a/packages/uhk-agent/src/services/app.service.ts b/packages/uhk-agent/src/services/app.service.ts index da2939d2da3..4bc70df5458 100644 --- a/packages/uhk-agent/src/services/app.service.ts +++ b/packages/uhk-agent/src/services/app.service.ts @@ -15,11 +15,15 @@ export class AppService extends MainServiceBase { private rootDir: string) { super(logService, win); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.app.getAppStartInfo, this.handleAppStartInfo.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.app.exit, this.exit.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.app.openConfigFolder, this.openConfigFolder.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.app.openUrl, this.openUrl.bind(this)); - ipcMain.handle(IpcEvents.app.getConfig, async (event, key) => { + ipcMain.handle(IpcEvents.app.getConfig, async (event, key: string) => { logService.misc(`[AppService] get-config: ${key}`); const config = await settings.get(key); @@ -28,7 +32,7 @@ export class AppService extends MainServiceBase { return config; }); - ipcMain.handle(IpcEvents.app.setConfig, async (event, key, value) => { + ipcMain.handle(IpcEvents.app.setConfig, async (event, key: string, value: never) => { logService.misc(`[AppService] set-config of "${key}": ${value}`); await settings.set(key, value); }); diff --git a/packages/uhk-agent/src/services/device.service.ts b/packages/uhk-agent/src/services/device.service.ts index 63ca80b6a6d..ea145994fbc 100644 --- a/packages/uhk-agent/src/services/device.service.ts +++ b/packages/uhk-agent/src/services/device.service.ts @@ -47,6 +47,7 @@ import { UHK_80_DEVICE, UHK_80_DEVICE_LEFT, UHK_DEVICE_IDS, + UHK_DEVICE_IDS_TYPE, UHK_DONGLE, UHK_MODULE_IDS, UHK_MODULES, @@ -210,6 +211,7 @@ export class DeviceService { }); }); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.device.toggleI2cDebugging, this.toggleI2cDebugging.bind(this)); ipcMain.on(IpcEvents.device.isRightHalfZephyrLoggingEnabled, (...args) => { @@ -257,6 +259,7 @@ export class DeviceService { }); }); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.device.startConnectionPoller, this.startPollUhkDevice.bind(this)); ipcMain.on(IpcEvents.device.startDonglePairing, (...args) => { @@ -314,8 +317,11 @@ export class DeviceService { }); }); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.device.getUserConfigFromHistory, this.getUserConfigFromHistory.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.device.deleteUserConfigHistory, this.deleteUserConfigHistory.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.device.loadUserConfigHistory, this.loadUserConfigFromHistory.bind(this)); logService.misc('[DeviceService] init success'); @@ -834,8 +840,8 @@ export class DeviceService { try { await this.stopPollUhkDevice(); const arg = args[0]; - const userConfig = arg.userConfig; - const deviceId = arg.deviceId; + const userConfig: Object = arg.userConfig; + const deviceId: UHK_DEVICE_IDS_TYPE = arg.deviceId; const firmwarePathData: TmpFirmware = getDefaultFirmwarePath(this.rootDir); const packageJson = await getFirmwarePackageJson(firmwarePathData); @@ -944,7 +950,10 @@ export class DeviceService { } } - public async deleteHostConnection(event: Electron.IpcMainEvent, args): Promise { + public async deleteHostConnection( + event: Electron.IpcMainEvent, + args: [{ isConnectedDongleAddress: boolean, index: number, address: string }] + ): Promise { const {isConnectedDongleAddress, index, address} = args[0]; this.logService.misc('[DeviceService] delete host connection', { isConnectedDongleAddress, index, address }); @@ -1010,7 +1019,7 @@ export class DeviceService { event.sender.send(IpcEvents.device.eraseBleSettingsReply, response); } - public async execShellCommand(_: Electron.IpcMainEvent, [command]): Promise { + public async execShellCommand(_: Electron.IpcMainEvent, [command]: [string]): Promise { this.logService.misc(`[DeviceService] execute shell command (escaped): ${escapeZephyrControlChars(command)}`); try { @@ -1381,7 +1390,7 @@ export class DeviceService { return Promise.resolve(); } - private async getUserConfigFromHistory(event: Electron.IpcMainEvent, [filename]): Promise { + private async getUserConfigFromHistory(event: Electron.IpcMainEvent, [filename]: [string]): Promise { const response: UploadFileData = { filename, data: await getUserConfigFromHistoryAsync(filename), @@ -1391,7 +1400,7 @@ export class DeviceService { event.sender.send(IpcEvents.device.getUserConfigFromHistoryReply, response); } - private async deleteUserConfigHistory(event: Electron.IpcMainEvent, [deviceUniqueId]): Promise { + private async deleteUserConfigHistory(event: Electron.IpcMainEvent, [deviceUniqueId]: [number]): Promise { const response = await deleteUserConfigHistory(deviceUniqueId); event.sender.send(IpcEvents.device.deleteUserConfigHistoryReply, response); diff --git a/packages/uhk-agent/src/services/logger.service.ts b/packages/uhk-agent/src/services/logger.service.ts index 6208034f16f..3e0a18ccc26 100644 --- a/packages/uhk-agent/src/services/logger.service.ts +++ b/packages/uhk-agent/src/services/logger.service.ts @@ -31,6 +31,7 @@ export class ElectronLogService extends LogService { // eslint-disable-next-line @typescript-eslint/no-explicit-any error(...args: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument log.error(...args); } @@ -40,6 +41,7 @@ export class ElectronLogService extends LogService { return; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.log(...args); } @@ -49,9 +51,9 @@ export class ElectronLogService extends LogService { return; } - if (LOG_WRITE_REG_EXP.test(args[0])) { + if (LOG_WRITE_REG_EXP.test(args[0] as string)) { this.log('%c' + args.join(' '), 'color:blue'); - } else if (LOG_READ_REG_EXP.test(args[0])) { + } else if (LOG_READ_REG_EXP.test(args[0] as string)) { let errorCodeStartIndex = 0; let errorCodeEndIndex = 2; @@ -66,6 +68,7 @@ export class ElectronLogService extends LogService { this.log('%c' + args.join(' '), 'color:red'); } } else { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.log(...args); } } @@ -80,6 +83,7 @@ export class ElectronLogService extends LogService { // eslint-disable-next-line @typescript-eslint/no-explicit-any protected log(...args: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument log.log(...args); } } diff --git a/packages/uhk-agent/src/services/sudo.service.ts b/packages/uhk-agent/src/services/sudo.service.ts index f5a44f61e59..9ee70515f3b 100644 --- a/packages/uhk-agent/src/services/sudo.service.ts +++ b/packages/uhk-agent/src/services/sudo.service.ts @@ -15,6 +15,7 @@ export class SudoService { private deviceService: DeviceService, private rootDir: string) { this.logService.misc('[SudoService] App root dir: ', this.rootDir); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ipcMain.on(IpcEvents.device.setPrivilegeOnLinux, this.setPrivilege.bind(this)); } diff --git a/packages/uhk-agent/src/services/zephyr-log.service.ts b/packages/uhk-agent/src/services/zephyr-log.service.ts index 6f84731df0e..ad41e233127 100644 --- a/packages/uhk-agent/src/services/zephyr-log.service.ts +++ b/packages/uhk-agent/src/services/zephyr-log.service.ts @@ -102,7 +102,7 @@ export class ZephyrLogService { this.options.logService.misc(`[ZephyrLogService | ${this.options.uhkDeviceProduct.logName}] Disabled`); } - private async execShellCommand(_: Electron.IpcMainEvent, [command]): Promise { + private async execShellCommand(_: Electron.IpcMainEvent, [command]: [string]): Promise { this.options.logService.misc(`[ZephyrLogService | execute shell command (escaped): ${escapeZephyrControlChars(command)}`); try { @@ -337,7 +337,7 @@ export class ZephyrLogService { this.options.logService.misc(`[ZephyrLogService | ${this.options.uhkDeviceProduct.logName}] stopped`); } - private async toggleZephyrLogging(_: Electron.IpcMainEvent, [enabled]): Promise { + private async toggleZephyrLogging(_: Electron.IpcMainEvent, [enabled]: [boolean]): Promise { this.options.logService.misc(`[ZephyrLogService | ${this.options.uhkDeviceProduct.logName}] Toggle zephyr logging => ${enabled}`); try { diff --git a/packages/uhk-agent/src/util/create-png.ts b/packages/uhk-agent/src/util/create-png.ts index 5387990b21f..8e2cc082579 100644 --- a/packages/uhk-agent/src/util/create-png.ts +++ b/packages/uhk-agent/src/util/create-png.ts @@ -56,5 +56,6 @@ export function createPNG(width: number, height: number, pixelData: Buffer>> 0; // Convert to unsigned 32-bit } diff --git a/packages/uhk-agent/src/util/window.ts b/packages/uhk-agent/src/util/window.ts index 887d107df80..117af8f34c5 100644 --- a/packages/uhk-agent/src/util/window.ts +++ b/packages/uhk-agent/src/util/window.ts @@ -29,7 +29,7 @@ export const loadWindowState = (logger: LogService): Partial => { logger.misc('[WindowState] load settings'); try { // eslint-disable-next-line @typescript-eslint/no-explicit-any - const loadedState = settings.getSync(WINDOWS_SETTINGS_KEY) as any; + const loadedState: WindowState = settings.getSync(WINDOWS_SETTINGS_KEY) as any; logger.misc('[WindowState] loaded settings', loadedState); if (!loadedState) { @@ -70,7 +70,7 @@ export const saveWindowState = (win: electron.BrowserWindow, logger: LogService) }; logger.misc('[WindowState] save settings:', state); - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument settings.setSync(WINDOWS_SETTINGS_KEY, state as any); logger.misc('[WindowState] save settings success'); }; diff --git a/packages/uhk-common/package.json b/packages/uhk-common/package.json index a8bb5479440..46a8a40516d 100644 --- a/packages/uhk-common/package.json +++ b/packages/uhk-common/package.json @@ -16,7 +16,7 @@ "build:generate-versions": "node ./scripts/generate-versions.mjs", "build:tsc": "tsc --project src/tsconfig.build.json", "build:user-config": "tsx ./scripts/generate-user-configs.ts", - "clean": "rimraf ./node_modules ./dist user-config.json ./src/user-config-60.ts ./src/user-config-80.ts", + "clean": "rimraf ./node_modules ./dist user-config.json ./src/user-config-60.ts ./src/user-config-80.ts ./src/util/versions.ts", "test": "node --loader=ts-node/esm --test \"**/*.test.ts\"", "lint": "eslint" }, diff --git a/packages/uhk-common/src/config-serializer/config-items/host-connection.ts b/packages/uhk-common/src/config-serializer/config-items/host-connection.ts index aef9695073d..58e6ce7afa1 100644 --- a/packages/uhk-common/src/config-serializer/config-items/host-connection.ts +++ b/packages/uhk-common/src/config-serializer/config-items/host-connection.ts @@ -145,7 +145,7 @@ export class HostConnection { this.type = buffer.readUInt8(); if (this.hasAddress()) { - const address = []; + const address: number[] = []; for (let i = 0; i < BLE_ADDRESS_LENGTH; i++) { address.push(buffer.readUInt8()); @@ -170,7 +170,7 @@ export class HostConnection { this.type = buffer.readUInt8(); if (this.hasAddress()) { - const address = []; + const address: number[] = []; for (let i = 0; i < BLE_ADDRESS_LENGTH; i++) { address.push(buffer.readUInt8()); diff --git a/packages/uhk-common/src/config-serializer/config-items/key-action/helper.ts b/packages/uhk-common/src/config-serializer/config-items/key-action/helper.ts index b31f2590199..5f9a9152c37 100644 --- a/packages/uhk-common/src/config-serializer/config-items/key-action/helper.ts +++ b/packages/uhk-common/src/config-serializer/config-items/key-action/helper.ts @@ -5,7 +5,7 @@ import { Macro } from '../macro.js'; import { SerialisationInfo } from '../serialisation-info.js'; import { KeyAction, KeyActionId, keyActionType } from './key-action.js'; import { KeyLabelAction } from './key-label-action.js'; -import { KeystrokeAction } from './keystroke-action.js'; +import { JsonObjectKeystrokeAction, KeystrokeAction } from './keystroke-action.js'; import { NoneBlockAction } from './none-block-action.js'; import { OtherAction } from './other-action.js'; import { SwitchLayerAction } from './switch-layer-action.js'; @@ -152,7 +152,7 @@ export class Helper { case keyActionType.KeyLabelAction: return new KeyLabelAction().fromJsonObject(keyAction) case keyActionType.KeystrokeAction: { - const keystrokeAction = new KeystrokeAction().fromJsonObject(keyAction, serialisationInfo); + const keystrokeAction = new KeystrokeAction().fromJsonObject(keyAction as JsonObjectKeystrokeAction, serialisationInfo); if (isValidKeystrokeAction(keystrokeAction)) { return keystrokeAction; } diff --git a/packages/uhk-common/src/config-serializer/config-items/macro-action/helper.ts b/packages/uhk-common/src/config-serializer/config-items/macro-action/helper.ts index 3b15a49dfda..b2d1d36182d 100644 --- a/packages/uhk-common/src/config-serializer/config-items/macro-action/helper.ts +++ b/packages/uhk-common/src/config-serializer/config-items/macro-action/helper.ts @@ -1,8 +1,8 @@ import { UhkBuffer } from '../../uhk-buffer.js'; import { SerialisationInfo } from '../serialisation-info.js'; import { MacroAction, MacroActionId, macroActionType } from './macro-action.js'; -import { KeyMacroAction } from './key-macro-action.js'; -import { MouseButtonMacroAction } from './mouse-button-macro-action.js'; +import { JsObjectKeyMacroAction, KeyMacroAction } from './key-macro-action.js'; +import { JsObjectMouseButtonMacroAction, MouseButtonMacroAction } from './mouse-button-macro-action.js'; import { MoveMouseMacroAction } from './move-mouse-macro-action.js'; import { ScrollMouseMacroAction } from './scroll-mouse-macro-action.js'; import { DelayMacroAction } from './delay-macro-action.js'; @@ -73,9 +73,9 @@ export class Helper { static fromJSONObject(macroAction: any, serialisationInfo: SerialisationInfo): MacroAction { switch (macroAction.macroActionType) { case macroActionType.KeyMacroAction: - return new KeyMacroAction().fromJsonObject(macroAction, serialisationInfo); + return new KeyMacroAction().fromJsonObject(macroAction as JsObjectKeyMacroAction, serialisationInfo); case macroActionType.MouseButtonMacroAction: - return new MouseButtonMacroAction().fromJsonObject(macroAction, serialisationInfo); + return new MouseButtonMacroAction().fromJsonObject(macroAction as JsObjectMouseButtonMacroAction, serialisationInfo); case macroActionType.MoveMouseMacroAction: return new MoveMouseMacroAction().fromJsonObject(macroAction, serialisationInfo); case macroActionType.ScrollMouseMacroAction: diff --git a/packages/uhk-common/src/config-serializer/config-items/macro.ts b/packages/uhk-common/src/config-serializer/config-items/macro.ts index 59c1041a5c1..0c508a84507 100644 --- a/packages/uhk-common/src/config-serializer/config-items/macro.ts +++ b/packages/uhk-common/src/config-serializer/config-items/macro.ts @@ -105,6 +105,7 @@ export class Macro { this.isPrivate = jsonObject.isPrivate; this.name = jsonObject.name; this.macroActions = jsonObject.macroActions.map((macroAction) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return MacroActionHelper.createMacroAction(macroAction, serialisationInfo); }); } diff --git a/packages/uhk-common/src/config-serializer/config-items/scancode-checker.ts b/packages/uhk-common/src/config-serializer/config-items/scancode-checker.ts index 3fdd13b86da..1e481ebbf38 100644 --- a/packages/uhk-common/src/config-serializer/config-items/scancode-checker.ts +++ b/packages/uhk-common/src/config-serializer/config-items/scancode-checker.ts @@ -38,7 +38,7 @@ function fillScancodeMap(): void { for (const child of scanGroup.children) { const additional = child.additional as any; if (additional && additional.scancode) { - scancodeMap.set(additional.scancode, child); + scancodeMap.set(additional.scancode as number, child); } else { scancodeMap.set(Number.parseInt(child.id), child); diff --git a/packages/uhk-common/src/log/log-user-config-helper.ts b/packages/uhk-common/src/log/log-user-config-helper.ts index cc03243179f..bc9b7d16d9d 100644 --- a/packages/uhk-common/src/log/log-user-config-helper.ts +++ b/packages/uhk-common/src/log/log-user-config-helper.ts @@ -1,9 +1,10 @@ import { UserConfiguration } from '../config-serializer/config-items/user-configuration.js'; -export function logUserConfigHelper(logger: Function, message: string, config: UserConfiguration | string): void { - if (typeof config === 'string' || !config.toJsonObject) { +export function logUserConfigHelper(logger: Function, message: string, config: UserConfiguration | string | Object): void { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (typeof config === 'string' || !(config as any).toJsonObject) { config = new UserConfiguration().fromJsonObject(config); } - logger(message, JSON.stringify(config.toJsonObject(), null, 2)); + logger(message, JSON.stringify((config as UserConfiguration).toJsonObject(), null, 2)); } diff --git a/packages/uhk-common/src/log/logger.service.ts b/packages/uhk-common/src/log/logger.service.ts index 440ef618aa4..8b5d5fd0be3 100644 --- a/packages/uhk-common/src/log/logger.service.ts +++ b/packages/uhk-common/src/log/logger.service.ts @@ -17,7 +17,7 @@ export class LogService { this._usbReportId = reportId; } - config(message: string, config: UserConfiguration | string): void { + config(message: string, config: UserConfiguration | string | Object): void { if (!this._options.config) { return; } @@ -26,6 +26,7 @@ export class LogService { } error(...args: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument console.error(...args); } @@ -34,6 +35,7 @@ export class LogService { return; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.log(...args); } @@ -42,6 +44,7 @@ export class LogService { return; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.log(...args); } @@ -50,10 +53,12 @@ export class LogService { return; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.log(...args); } protected log(...args: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument console.log(...args); } } diff --git a/packages/uhk-common/src/util/helpers.ts b/packages/uhk-common/src/util/helpers.ts index 8e5482e9308..538ee464367 100644 --- a/packages/uhk-common/src/util/helpers.ts +++ b/packages/uhk-common/src/util/helpers.ts @@ -6,7 +6,7 @@ import { UHK_EEPROM_SIZE } from './constants.js'; import { shouldUpgradeAgent } from './should-upgrade-agent.js'; export const getHardwareConfigFromDeviceResponse = (json: string): HardwareConfiguration => { - const data = JSON.parse(json); + const data: number[] = JSON.parse(json); const hardwareConfig = new HardwareConfiguration(); hardwareConfig.fromBinary(UhkBuffer.fromArray(data)); @@ -32,7 +32,7 @@ export interface ParsedUserConfiguration { export const getUserConfigFromDeviceResponse = (json: string): ParsedUserConfiguration => { try { - const data = JSON.parse(json); + const data: number[] = JSON.parse(json); const uhkBuffer = UhkBuffer.fromArray(data) const userConfigMajorVersion = uhkBuffer.readUInt16(); const userConfigMinorVersion = uhkBuffer.readUInt16(); diff --git a/packages/uhk-smart-macro/index.ts b/packages/uhk-smart-macro/index.ts new file mode 100644 index 00000000000..4df73b330ff --- /dev/null +++ b/packages/uhk-smart-macro/index.ts @@ -0,0 +1 @@ +export * from './src/index.js'; diff --git a/packages/uhk-usb/src/uhk-hid-device.ts b/packages/uhk-usb/src/uhk-hid-device.ts index 570c0b858b4..b76863da208 100644 --- a/packages/uhk-usb/src/uhk-hid-device.ts +++ b/packages/uhk-usb/src/uhk-hid-device.ts @@ -597,7 +597,7 @@ export class UhkHidDevice { } async sendKbootCommandToModule(module: ModuleSlotToI2cAddress, command: KbootCommands, maxTry = 1): Promise { - let transfer; + let transfer: Buffer; this.logService.usbOps(`[UhkHidDevice] USB[T]: Send KbootCommand ${mapI2cAddressToModuleName(module)} ${KbootCommands[command].toString()}`); if (command === KbootCommands.idle) { transfer = Buffer.from([UsbCommand.SendKbootCommandToModule, command]); @@ -652,7 +652,7 @@ export class UhkHidDevice { const count = Math.min(remainingNewConnections, MAX_BLE_ADDRESSES_IN_NEW_PAIRING_RESPONSE); for (let i = 0; i < count; i++) { - const address = []; + const address: number[] = []; for (let i = 0; i < BLE_ADDRESS_LENGTH; i++) { address.push(uhkBuffer.readUInt8()); } diff --git a/packages/uhk-usb/src/uhk-operations.ts b/packages/uhk-usb/src/uhk-operations.ts index d83121b429e..76315f2f894 100644 --- a/packages/uhk-usb/src/uhk-operations.ts +++ b/packages/uhk-usb/src/uhk-operations.ts @@ -452,7 +452,8 @@ export class UhkOperations { reportProgress(0); this.logService.usbOps('[DeviceOperation] USB[T]: Write user configuration to keyboard'); let shouldRecalculateLength = false; - // eslint-disable-next-line @typescript-eslint/no-explicit-any + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument const uhkBuffer = UhkBuffer.fromArray(buffer as any) const userConfiguration = new UserConfiguration() userConfiguration.fromBinary(uhkBuffer) @@ -970,7 +971,7 @@ export class UhkOperations { }; } - public async setVariable(variable: UsbVariables, value: number): Promise { + public async setVariable(variable: UsbVariables, value: boolean | number): Promise { this.logService.usbOps('[DeviceOperation] USB[T]: Set Variable'); await this.device.write(Buffer.from([UsbCommand.SetVariable, variable, value])); await this.waitUntilKeyboardBusy(); diff --git a/packages/uhk-usb/src/utils/snooze.ts b/packages/uhk-usb/src/utils/snooze.ts index 0ce4060360f..e9979651283 100644 --- a/packages/uhk-usb/src/utils/snooze.ts +++ b/packages/uhk-usb/src/utils/snooze.ts @@ -1 +1 @@ -export const snooze = ms => new Promise(resolve => setTimeout(resolve, ms)); +export const snooze = (ms: number) : Promise => new Promise(resolve => setTimeout(resolve, ms)); diff --git a/packages/uhk-usb/src/utils/usb-device-json-formatter.ts b/packages/uhk-usb/src/utils/usb-device-json-formatter.ts index e8ed0a1fd90..886637b54bd 100644 --- a/packages/uhk-usb/src/utils/usb-device-json-formatter.ts +++ b/packages/uhk-usb/src/utils/usb-device-json-formatter.ts @@ -1,7 +1,6 @@ import { toHexString } from 'uhk-common'; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function usbDeviceJsonFormatter(key: any, value: any): any { +export function usbDeviceJsonFormatter(key: string, value: number | undefined | null): string | number | undefined | null { if (value === undefined || value === null) { return value } diff --git a/packages/uhk-web/src/app/components/back-to/back-to.component.ts b/packages/uhk-web/src/app/components/back-to/back-to.component.ts index 29ef106c123..eec3d5fae9b 100644 --- a/packages/uhk-web/src/app/components/back-to/back-to.component.ts +++ b/packages/uhk-web/src/app/components/back-to/back-to.component.ts @@ -22,7 +22,7 @@ export class BackToComponent implements OnDestroy { private cdRef: ChangeDetectorRef) { this.routeSubscription = route.queryParams.subscribe(params => { if (params.backUrl) { - const backUrl = new URL(params.backUrl, window.location.origin); + const backUrl = new URL(params.backUrl as string, window.location.origin); this.backUrl = backUrl.pathname; this.backText = params.backText; this.queryParams = {}; diff --git a/packages/uhk-web/src/app/components/device/firmware-file-upload/firmware-file-upload.component.ts b/packages/uhk-web/src/app/components/device/firmware-file-upload/firmware-file-upload.component.ts index b1455155dd7..9076606a691 100644 --- a/packages/uhk-web/src/app/components/device/firmware-file-upload/firmware-file-upload.component.ts +++ b/packages/uhk-web/src/app/components/device/firmware-file-upload/firmware-file-upload.component.ts @@ -46,7 +46,7 @@ export class FirmwareFileUploadComponent { target.value = null; }; - fileReader.readAsArrayBuffer(files[0]); + fileReader.readAsArrayBuffer(files[0] as Blob); } onClick(): void { diff --git a/packages/uhk-web/src/app/components/device/led-settings/fade-timeout-slider.component.ts b/packages/uhk-web/src/app/components/device/led-settings/fade-timeout-slider.component.ts index b8dc1f7f8d4..6e2d4cb3f75 100644 --- a/packages/uhk-web/src/app/components/device/led-settings/fade-timeout-slider.component.ts +++ b/packages/uhk-web/src/app/components/device/led-settings/fade-timeout-slider.component.ts @@ -74,7 +74,7 @@ export class FadeTimeoutSliderComponent implements ControlValueAccessor{ }, tooltips: [ { - to: (value) => { + to: (value: number) => { return this.formatToValue(value); } } diff --git a/packages/uhk-web/src/app/components/file-upload/file-upload.component.ts b/packages/uhk-web/src/app/components/file-upload/file-upload.component.ts index c35de5af47f..f1cbb74f885 100644 --- a/packages/uhk-web/src/app/components/file-upload/file-upload.component.ts +++ b/packages/uhk-web/src/app/components/file-upload/file-upload.component.ts @@ -32,6 +32,6 @@ export class FileUploadComponent { target.value = null; }.bind(this); - fileReader.readAsArrayBuffer(files[0]); + fileReader.readAsArrayBuffer(files[0] as Blob); } } diff --git a/packages/uhk-web/src/app/components/keyboard/slider/keyboard-slider.component.ts b/packages/uhk-web/src/app/components/keyboard/slider/keyboard-slider.component.ts index 4a14292314b..fb9cd39f1fb 100644 --- a/packages/uhk-web/src/app/components/keyboard/slider/keyboard-slider.component.ts +++ b/packages/uhk-web/src/app/components/keyboard/slider/keyboard-slider.component.ts @@ -74,11 +74,11 @@ export class KeyboardSliderComponent implements OnChanges { } else if (this.visibleLayerName === LayerNames.A) { this.bLayer = this.layers.find(layer => layer.id === this.currentLayer.id); this.visibleLayerName = LayerNames.B; - this.onLayerChange(layerChange.previousValue, layerChange.currentValue); + this.onLayerChange(layerChange.previousValue as LayerOption, layerChange.currentValue as LayerOption); } else { this.aLayer = this.layers.find(layer => layer.id === this.currentLayer.id); this.visibleLayerName = LayerNames.A; - this.onLayerChange(layerChange.previousValue, layerChange.currentValue); + this.onLayerChange(layerChange.previousValue as LayerOption, layerChange.currentValue as LayerOption); } } } diff --git a/packages/uhk-web/src/app/components/keymap/edit/keymap-edit.component.ts b/packages/uhk-web/src/app/components/keymap/edit/keymap-edit.component.ts index 0d0712ac83f..149f4a35b32 100644 --- a/packages/uhk-web/src/app/components/keymap/edit/keymap-edit.component.ts +++ b/packages/uhk-web/src/app/components/keymap/edit/keymap-edit.component.ts @@ -88,7 +88,7 @@ export class KeymapEditComponent implements OnDestroy { .pipe( map(params => params.abbr) ) - .subscribe(abbr => { + .subscribe((abbr: string | undefined) => { if (abbr) { abbr = decodeURIComponent(abbr) } diff --git a/packages/uhk-web/src/app/components/keymap/header/keymap-header.component.ts b/packages/uhk-web/src/app/components/keymap/header/keymap-header.component.ts index a5df886fa60..ae45c7d605d 100644 --- a/packages/uhk-web/src/app/components/keymap/header/keymap-header.component.ts +++ b/packages/uhk-web/src/app/components/keymap/header/keymap-header.component.ts @@ -67,7 +67,7 @@ export class KeymapHeaderComponent implements OnChanges, OnDestroy { if (changes['keymap']) { this.setKeymapTitle(); this.setAbbreviation(); - this.keymapName.writeValue(changes.keymap.currentValue.name); + this.keymapName.writeValue(changes.keymap.currentValue.name as string); } if (changes['deletable']) { this.setTrashTitle(); diff --git a/packages/uhk-web/src/app/components/layers/layers.component.ts b/packages/uhk-web/src/app/components/layers/layers.component.ts index c5a0aa52e50..b26184a9a07 100644 --- a/packages/uhk-web/src/app/components/layers/layers.component.ts +++ b/packages/uhk-web/src/app/components/layers/layers.component.ts @@ -80,7 +80,7 @@ export class LayersComponent { this.pasteLayer.emit(); } - onColorSelected(index): void { + onColorSelected(index: number): void { this.toggleColorFromPalette.emit(index); } diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/command/macro-command-editor.component.ts b/packages/uhk-web/src/app/components/macro/action-editor/tab/command/macro-command-editor.component.ts index 66e326bc1a7..7e7d4d7f521 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/command/macro-command-editor.component.ts +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/command/macro-command-editor.component.ts @@ -275,7 +275,7 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA }).pipe( debounceTime(MACRO_CHANGE_DEBOUNCE_TIME), distinctUntilChanged() - ).subscribe(data => { + ).subscribe((data: string) => { // If the user modify the macro without saving then we update the macro text if (this.isFocused) { this.smartMacroDocService.updateCommand(data); @@ -354,7 +354,7 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA data = data?.trim(); let selection = this.editor.getSelection(); - let cursorPosition; + let cursorPosition: monaco.IPosition; if (selection.isEmpty()) { const macroLines = this.editor.getValue().split(this.editor.getModel().getEOL()); const lineNumber = selection.getPosition().lineNumber; diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/key/macro-key.component.ts b/packages/uhk-web/src/app/components/macro/action-editor/tab/key/macro-key.component.ts index 9c9ad751321..2c9df4d2ac2 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/key/macro-key.component.ts +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/key/macro-key.component.ts @@ -38,7 +38,7 @@ export class MacroKeyTabComponent extends MacroBaseComponent implements OnInit { if (!this.macroAction) { this.macroAction = new KeyMacroAction(); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument this.defaultKeyAction = new KeystrokeAction(this.macroAction); this.selectTab(this.getTabName(this.macroAction)); } @@ -76,7 +76,7 @@ export class MacroKeyTabComponent extends MacroBaseComponent implements OnInit { } getKeyMacroAction(): KeyMacroAction { - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument const keyMacroAction = new KeyMacroAction(this.keypressTab.toKeyAction() as any); keyMacroAction.action = this.getActionType(this.activeTab); return keyMacroAction; diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/text/macro-text.component.ts b/packages/uhk-web/src/app/components/macro/action-editor/tab/text/macro-text.component.ts index 0924e210a35..edfef9bb417 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/text/macro-text.component.ts +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/text/macro-text.component.ts @@ -75,7 +75,7 @@ export class MacroTextTabComponent extends MacroBaseComponent implements OnInit, this.valid.emit(this.isMacroValid()); } - isMacroValid = () => !!this.input.nativeElement.value && !hasNonAsciiCharacters(this.input.nativeElement.value); + isMacroValid = () => !!this.input.nativeElement.value && !hasNonAsciiCharacters(this.input.nativeElement.value as string); private init = () => { if (!this.macroAction) { diff --git a/packages/uhk-web/src/app/components/macro/directives/smart-macro-doc.directive.ts b/packages/uhk-web/src/app/components/macro/directives/smart-macro-doc.directive.ts index 4637d728ded..28cfc4ea4d8 100644 --- a/packages/uhk-web/src/app/components/macro/directives/smart-macro-doc.directive.ts +++ b/packages/uhk-web/src/app/components/macro/directives/smart-macro-doc.directive.ts @@ -9,6 +9,7 @@ import { SmartMacroDocService } from '../../../services/smart-macro-doc-service' export class SmartMacroDocDirective implements OnDestroy { constructor(private elementRef: ElementRef, private smartMacroDocService: SmartMacroDocService) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.smartMacroDocService.setIframe(this.elementRef.nativeElement); } diff --git a/packages/uhk-web/src/app/components/macro/header/macro-header.component.ts b/packages/uhk-web/src/app/components/macro/header/macro-header.component.ts index d200421df63..def5f861f78 100644 --- a/packages/uhk-web/src/app/components/macro/header/macro-header.component.ts +++ b/packages/uhk-web/src/app/components/macro/header/macro-header.component.ts @@ -39,7 +39,7 @@ export class MacroHeaderComponent implements OnChanges { ngOnChanges(changes: SimpleChanges): void { if (changes.macro) { - this.macroName.writeValue(changes.macro.currentValue.name); + this.macroName.writeValue(changes.macro.currentValue.name as string); } } diff --git a/packages/uhk-web/src/app/components/macro/item/macro-item.component.ts b/packages/uhk-web/src/app/components/macro/item/macro-item.component.ts index c9198ba2498..a6cf68dfa7d 100644 --- a/packages/uhk-web/src/app/components/macro/item/macro-item.component.ts +++ b/packages/uhk-web/src/app/components/macro/item/macro-item.component.ts @@ -234,8 +234,7 @@ export class MacroItemComponent implements OnInit, OnChanges { } private setMouseMoveScrollActionContent(action: MacroAction): void { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let typedAction: any; + let typedAction: MoveMouseMacroAction | ScrollMouseMacroAction; if (action instanceof MoveMouseMacroAction) { // Move mouse pointer this.iconName = 'mouse-pointer'; diff --git a/packages/uhk-web/src/app/components/macro/list/macro-list.component.ts b/packages/uhk-web/src/app/components/macro/list/macro-list.component.ts index 800db20a3fa..02621641d44 100644 --- a/packages/uhk-web/src/app/components/macro/list/macro-list.component.ts +++ b/packages/uhk-web/src/app/components/macro/list/macro-list.component.ts @@ -217,7 +217,7 @@ export class MacroListComponent implements AfterViewChecked, OnDestroy { window.scrollTo(document.body.scrollLeft, document.body.scrollHeight); }, ANIMATION_INTERVAL); - this.scrollToBottomSetTimeoutTimer = window.setTimeout(this.clearScrollToBottomInterval.bind(this), ANIMATION_TIMEOUT); + this.scrollToBottomSetTimeoutTimer = window.setTimeout(() => this.clearScrollToBottomInterval(), ANIMATION_TIMEOUT); } private clearScrollToBottomInterval(): void { diff --git a/packages/uhk-web/src/app/components/popover/tab/keypress/keypress-tab.component.ts b/packages/uhk-web/src/app/components/popover/tab/keypress/keypress-tab.component.ts index 2821f600042..b7726e263f3 100644 --- a/packages/uhk-web/src/app/components/popover/tab/keypress/keypress-tab.component.ts +++ b/packages/uhk-web/src/app/components/popover/tab/keypress/keypress-tab.component.ts @@ -83,6 +83,7 @@ export class KeypressTabComponent extends Tab implements OnChanges { group: group.text, additional: { type: 'basic', + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument scancode: Number.parseInt(child.id, 10), ...child.additional } diff --git a/packages/uhk-web/src/app/components/side-menu/second-side-menu-container.component.ts b/packages/uhk-web/src/app/components/side-menu/second-side-menu-container.component.ts index 23c17b298f5..df60846d322 100644 --- a/packages/uhk-web/src/app/components/side-menu/second-side-menu-container.component.ts +++ b/packages/uhk-web/src/app/components/side-menu/second-side-menu-container.component.ts @@ -22,6 +22,7 @@ export class SecondSideMenuContainerComponent { // eslint-disable-next-line @typescript-eslint/no-explicit-any resolveComponent(component: any): void { this.container.clear(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const componentFactory = this.componentFactoryResolver.resolveComponentFactory(component); this.container.createComponent(componentFactory); this.cdRef.detectChanges(); diff --git a/packages/uhk-web/src/app/components/svg/module/svg-module.model.ts b/packages/uhk-web/src/app/components/svg/module/svg-module.model.ts index a11180605b3..ddffa982d29 100644 --- a/packages/uhk-web/src/app/components/svg/module/svg-module.model.ts +++ b/packages/uhk-web/src/app/components/svg/module/svg-module.model.ts @@ -20,13 +20,13 @@ export class SvgModule { const keys = obj.rect.map(rect => rect.$); for (let i = 0; i < keys.length; ++i) { const key = keys[i]; - const idSplit = key.id.split('-'); + const idSplit: string[] = key.id.split('-'); if (idSplit.length === 2) { const index = Number.parseInt(idSplit[1], 10); keys[i].type = 'rec'; keys[i].height = +keys[i].height; keys[i].width = +keys[i].width; - const style = parseStyle(keys[i].style); + const style = parseStyle(keys[i].style as string); keys[i].fill = style.fill; this.keyboardKeys[index] = keys[i]; } @@ -58,11 +58,11 @@ export class SvgModule { } if (path.id) { - const idSplit = path.id.split('-'); // split the 'key-6{-print}' + const idSplit: string[] = path.id.split('-'); // split the 'key-6{-print}' if (idSplit.length === 2) { const index = Number.parseInt(idSplit[1], 10); - const style = parseStyle(path.style); + const style = parseStyle(path.style as string); this.keyboardKeys[index] = { ...this.keyboardKeys[index], @@ -85,7 +85,7 @@ export class SvgModule { if (obj.g) { obj.g.forEach(g => { if (g.$.id) { - const idSplit = g.$.id.split('-'); + const idSplit: string[] = g.$.id.split('-'); const index = Number.parseInt(idSplit[1], 10); const key: SvgKeyboardKey = { @@ -101,7 +101,7 @@ export class SvgModule { if (g.path) { key.elements.paths = g.path.map(path => { path = path.$; - const style = parseStyle(path.style); + const style = parseStyle(path.style as string); return { id: path.id, @@ -114,7 +114,7 @@ export class SvgModule { if (g.circle) { key.elements.circles = g.circle.map(circle => { circle = circle.$; - const style = parseStyle(circle.style); + const style = parseStyle(circle.style as string); return { id: circle.id, @@ -142,7 +142,7 @@ export class SvgModule { } this.attributes = obj.$; - this.id = parseInt(obj.$['data-module-id'], 10); + this.id = parseInt(obj.$['data-module-id'] as string, 10); } } diff --git a/packages/uhk-web/src/app/services/app-update-renderer.service.ts b/packages/uhk-web/src/app/services/app-update-renderer.service.ts index 9e40dbac004..2eef84c5131 100644 --- a/packages/uhk-web/src/app/services/app-update-renderer.service.ts +++ b/packages/uhk-web/src/app/services/app-update-renderer.service.ts @@ -2,6 +2,7 @@ import { Injectable, NgZone } from '@angular/core'; import { Action, Store } from '@ngrx/store'; import { IpcEvents, LogService } from 'uhk-common'; +import { UpdateInfo } from '../models/update-info'; import { AppState } from '../store'; import { UpdateDownloadedAction, UpdateErrorAction } from '../store/actions/app-update.action'; import { CheckForUpdateFailedAction, CheckForUpdateSuccessAction } from '../store/actions/auto-update-settings'; @@ -60,8 +61,7 @@ export class AppUpdateRendererService { this.logService.misc(IpcEvents.autoUpdater.autoUpdateDownloadProgress, arg); }); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - this.ipcRenderer.on(IpcEvents.autoUpdater.autoUpdateDownloaded, (event: string, arg: any) => { + this.ipcRenderer.on(IpcEvents.autoUpdater.autoUpdateDownloaded, (event: string, arg: UpdateInfo) => { this.logService.misc(IpcEvents.autoUpdater.autoUpdateDownloaded, arg); this.dispatchStoreAction(new UpdateDownloadedAction(arg)); }); diff --git a/packages/uhk-web/src/app/services/device-renderer.service.ts b/packages/uhk-web/src/app/services/device-renderer.service.ts index 98880a50878..b299c9d1bc0 100644 --- a/packages/uhk-web/src/app/services/device-renderer.service.ts +++ b/packages/uhk-web/src/app/services/device-renderer.service.ts @@ -4,6 +4,8 @@ import { Action, Store } from '@ngrx/store'; import { AreBleAddressesPairedIpcResponse, ChangeKeyboardLayoutIpcResponse, + ConfigSizesInfo, + ConfigurationReply, CurrentlyUpdatingModuleInfo, DeviceConnectionState, DeviceVersionInformation, @@ -24,7 +26,6 @@ import { UploadFileData, UserConfiguration, UserConfigHistory, - VersionInformation, ZephyrLogEntry, } from 'uhk-common'; @@ -287,7 +288,7 @@ export class DeviceRendererService { }); this.ipcRenderer.on(IpcEvents.device.loadConfigurationReply, (event: string, response: string) => { - this.dispachStoreAction(new LoadConfigFromDeviceReplyAction(JSON.parse(response))); + this.dispachStoreAction(new LoadConfigFromDeviceReplyAction(JSON.parse(response) as ConfigurationReply)); }); this.ipcRenderer.on(IpcEvents.device.updateFirmwareJson, (event: string, data: FirmwareJson) => { @@ -315,7 +316,7 @@ export class DeviceRendererService { }); this.ipcRenderer.on(IpcEvents.device.readConfigSizesReply, (event: string, response: string) => { - this.dispachStoreAction(new ReadConfigSizesReplyAction(JSON.parse(response))); + this.dispachStoreAction(new ReadConfigSizesReplyAction(JSON.parse(response) as ConfigSizesInfo)); }); this.ipcRenderer.on(IpcEvents.device.loadUserConfigHistoryReply, (event: string, response: UserConfigHistory) => { diff --git a/packages/uhk-web/src/app/services/key-action-coloring.service.ts b/packages/uhk-web/src/app/services/key-action-coloring.service.ts index 6067052b836..0f368d39392 100644 --- a/packages/uhk-web/src/app/services/key-action-coloring.service.ts +++ b/packages/uhk-web/src/app/services/key-action-coloring.service.ts @@ -21,6 +21,7 @@ export class KeyActionColoringService implements OnDestroy { @Inject(DOCUMENT) private _document: Document, private _store: Store ) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this._document.addEventListener('mouseup', this.leftButtonUp.bind(this)); this.subscriptions.add(this._store.select(isBacklightingColoring).subscribe(coloring => this.coloring = coloring)); this.subscriptions.add(this._store.select(selectedBacklightingColor).subscribe(color => this._selectedBacklightingColor = color)); diff --git a/packages/uhk-web/src/app/services/key-action-drag-and-drop.service.ts b/packages/uhk-web/src/app/services/key-action-drag-and-drop.service.ts index a53289c1861..ff2b517cef2 100644 --- a/packages/uhk-web/src/app/services/key-action-drag-and-drop.service.ts +++ b/packages/uhk-web/src/app/services/key-action-drag-and-drop.service.ts @@ -58,7 +58,9 @@ export class KeyActionDragAndDropService implements OnDestroy { @Inject(DOCUMENT) private _document: Document, private _store: Store ) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this._document.addEventListener('mouseup', this.leftButtonUp.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this._document.addEventListener('mousemove', this.mouseMove.bind(this)); this.subscriptions.add(this._store.select(getSelectedKeymap).subscribe(keymap => this.keymap = keymap)); this.subscriptions.add(this._store.select(getHalvesInfo).subscribe(info => this.halvesInfo = info)); diff --git a/packages/uhk-web/src/app/services/smart-macro-doc-service.ts b/packages/uhk-web/src/app/services/smart-macro-doc-service.ts index 21dea56585f..194eee478ac 100644 --- a/packages/uhk-web/src/app/services/smart-macro-doc-service.ts +++ b/packages/uhk-web/src/app/services/smart-macro-doc-service.ts @@ -31,7 +31,9 @@ export class SmartMacroDocService implements OnDestroy { constructor(private store: Store, private logService: LogService, private zone: NgZone) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument window.addEventListener('message', this.onMessage.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument window.addEventListener('messageerror', this.onMessageError.bind(this)); this.subscriptions.add( @@ -52,7 +54,9 @@ export class SmartMacroDocService implements OnDestroy { } ngOnDestroy(): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument window.removeEventListener('message', this.onMessage.bind(this)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument window.removeEventListener('messageerror', this.onMessageError.bind(this)); this.subscriptions.unsubscribe(); } @@ -103,7 +107,7 @@ export class SmartMacroDocService implements OnDestroy { return this.dispatchSmartMacroDocCommand(SmartMacroDocCommandAction.set, event.data.command); case 'doc-message-open-link': { - return this.dispatchStoreAction(new OpenUrlInNewWindowAction(event.data.url)); + return this.dispatchStoreAction(new OpenUrlInNewWindowAction(event.data.url as string)); } default: { diff --git a/packages/uhk-web/src/app/services/svg-module-provider.service.ts b/packages/uhk-web/src/app/services/svg-module-provider.service.ts index 165cd1c0f32..2cc8b73918f 100644 --- a/packages/uhk-web/src/app/services/svg-module-provider.service.ts +++ b/packages/uhk-web/src/app/services/svg-module-provider.service.ts @@ -139,6 +139,7 @@ export class SvgModuleProviderService implements OnDestroy { private getKeyClusterLeft(): SvgModule { if (!this.keyClusterLeft) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.keyClusterLeft = new SvgModule(require('!xml-loader!../../modules/keyclusterleft/module.svg').svg); } @@ -152,9 +153,13 @@ export class SvgModuleProviderService implements OnDestroy { private setModules() { switch (this.connectedDeviceId) { case UHK_80_DEVICE.id: { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.separator = convertXmlToSvgSeparator(require('!xml-loader!../../devices/uhk80-right/separator.svg').svg); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.right = new SvgModule(require('!xml-loader!../../devices/uhk80-right/layout.svg').svg); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.isoLeft = new SvgModule(require('!xml-loader!../../modules/uhk80-left/layout-iso.svg').svg); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.ansiLeft = new SvgModule(require('!xml-loader!../../modules/uhk80-left/layout-ansi.svg').svg); break; } @@ -168,6 +173,7 @@ export class SvgModuleProviderService implements OnDestroy { private getTouchPadRight(): SvgModule { if (!this.touchPadRight) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.touchPadRight = new SvgModule(require('!xml-loader!../../modules/touchpadright/module.svg').svg); } @@ -176,6 +182,7 @@ export class SvgModuleProviderService implements OnDestroy { private getTrackBallRight(): SvgModule { if (!this.trackBallRight) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.trackBallRight = new SvgModule(require('!xml-loader!../../modules/trackballright/module.svg').svg); } @@ -184,6 +191,7 @@ export class SvgModuleProviderService implements OnDestroy { private getTrackPointRight(): SvgModule { if (!this.trackPointRight) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.trackPointRight = new SvgModule(require('!xml-loader!../../modules/trackpointright/module.svg').svg); } @@ -191,9 +199,13 @@ export class SvgModuleProviderService implements OnDestroy { } private setUHK60Modules() { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.separator = convertXmlToSvgSeparator(require('!xml-loader!../../devices/uhk60-right/separator.svg').svg); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.right = new SvgModule(require('!xml-loader!../../devices/uhk60-right/layout.svg').svg); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.isoLeft = new SvgModule(require('!xml-loader!../../modules/uhk60-left/layout-iso.svg').svg); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.ansiLeft = new SvgModule(require('!xml-loader!../../modules/uhk60-left/layout-ansi.svg').svg); } } diff --git a/packages/uhk-web/src/app/store/effects/contributors.effect.ts b/packages/uhk-web/src/app/store/effects/contributors.effect.ts index 52dab04e175..40b96e88d81 100644 --- a/packages/uhk-web/src/app/store/effects/contributors.effect.ts +++ b/packages/uhk-web/src/app/store/effects/contributors.effect.ts @@ -59,7 +59,7 @@ export class ContributorsEffect { return new AgentContributorsAvailableAction(contributorsWithAvatars); } ), - catchError(error => of(new AgentContributorsNotAvailableAction(error))) + catchError((error: Error) => of(new AgentContributorsNotAvailableAction(error))) ) ); diff --git a/packages/uhk-web/src/app/store/effects/default-user-configuration.effect.ts b/packages/uhk-web/src/app/store/effects/default-user-configuration.effect.ts index cb4f57136f7..2cd08bf1a82 100644 --- a/packages/uhk-web/src/app/store/effects/default-user-configuration.effect.ts +++ b/packages/uhk-web/src/app/store/effects/default-user-configuration.effect.ts @@ -38,7 +38,7 @@ export class DefaultUserConfigurationEffect { filter(routerState => routerState.url.startsWith('/add-keymap')), map(routerState => routerState.params.newKeymapAbbr), distinctUntilChanged(), - map(abbreviation => new AddKeymapSelectedAction(abbreviation)) + map((abbreviation: string) => new AddKeymapSelectedAction(abbreviation)) ) ); diff --git a/packages/uhk-web/src/app/store/effects/device.ts b/packages/uhk-web/src/app/store/effects/device.ts index 855be30700f..c2cb8cf1b86 100644 --- a/packages/uhk-web/src/app/store/effects/device.ts +++ b/packages/uhk-web/src/app/store/effects/device.ts @@ -144,7 +144,7 @@ export class DeviceEffects { return } - const addresses = []; + const addresses: string[] = []; for (const hostConnection of hostConnections) { if (hostConnection.hasAddress()) { addresses.push(hostConnection.address); diff --git a/packages/uhk-web/src/app/store/effects/macro.ts b/packages/uhk-web/src/app/store/effects/macro.ts index e4650594f35..e6ca97c1d65 100644 --- a/packages/uhk-web/src/app/store/effects/macro.ts +++ b/packages/uhk-web/src/app/store/effects/macro.ts @@ -30,6 +30,7 @@ export class MacroEffects { tap(action => this.store.dispatch(new Keymaps.CheckMacroAction(action.payload))), withLatestFrom(this.store.select(getSelectedMacro)), map(([, newMacro]) => newMacro), + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument tap(this.navigateToNewMacro.bind(this)) ), @@ -42,6 +43,7 @@ export class MacroEffects { Macros.ActionTypes.Add, Macros.ActionTypes.Duplicate), withLatestFrom(this.store.select(getSelectedMacro)), map(([, newMacro]) => newMacro), + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument tap(this.navigateToNewMacro.bind(this)) ), { dispatch: false } diff --git a/packages/uhk-web/src/app/util/escape-html.ts b/packages/uhk-web/src/app/util/escape-html.ts index f051a01ec4c..5b44ba79fc6 100644 --- a/packages/uhk-web/src/app/util/escape-html.ts +++ b/packages/uhk-web/src/app/util/escape-html.ts @@ -1,6 +1,6 @@ const matchHtmlRegExp = /["'&<>]/ -export function escapeHtml(value) { +export function escapeHtml(value: string) { if (!value) { return value; } diff --git a/packages/uhk-web/src/renderer/services/electron-log.service.ts b/packages/uhk-web/src/renderer/services/electron-log.service.ts index 93739ef7182..3ac126fe706 100644 --- a/packages/uhk-web/src/renderer/services/electron-log.service.ts +++ b/packages/uhk-web/src/renderer/services/electron-log.service.ts @@ -16,6 +16,7 @@ export class ElectronLogService extends LogService { } error(...args: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument log.error(...args); } @@ -24,6 +25,7 @@ export class ElectronLogService extends LogService { return; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.log(...args); } @@ -32,6 +34,7 @@ export class ElectronLogService extends LogService { return; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.log(...args); } @@ -40,10 +43,12 @@ export class ElectronLogService extends LogService { return; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.log(...args); } protected log(...args: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument log.log(...args); } }