Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const globalIgnores = [

export const typescriptRules = {
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/kboot/src/models/data-option.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface DataOption {
startAddress: number;
data: Buffer;
data: Buffer | Uint8Array;
timeout?: number;
}
2 changes: 1 addition & 1 deletion packages/kboot/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export * from './response-parser.js';
export * from './usb/index.js';
export * from './snooze.js';

export const convertToHexString = (arr: number[] | Buffer): string => {
export const convertToHexString = (arr: number[] | Buffer | Uint8Array): string => {
let str = '';

for (const n of arr) {
Expand Down
2 changes: 1 addition & 1 deletion packages/kboot/src/util/is-null-or-undefined.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function isNullOrUndefined(value: any) : boolean {
export function isNullOrUndefined(value: unknown) : boolean {
return value === undefined || value === null;
}
2 changes: 1 addition & 1 deletion packages/kboot/src/util/usb/encode-command-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const encodeCommandOption = (option: CommandOption): number[] => {
return [...header, ...payload, ...placeholders];
};

export const validateCommandParams = (params: any[]): void => {
export const validateCommandParams = (params: number[]): void => {
if (isNullOrUndefined(params)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kboot/test/uhk-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const reenumerate = (mode: UhkReenumerationModes): void => {
);
};

export const readBootloaderFirmwareFromHexFile = (): Map<any, any> => {
export const readBootloaderFirmwareFromHexFile = (): MemoryMap => {
const hexFilePath = join(import.meta.dirname, '../../../../tmp/packages/firmware/devices/uhk60-right/firmware.hex');
const fileContent = readFileSync(hexFilePath, { encoding: 'utf8' });
const memoryMap = MemoryMap.fromHex(fileContent);
Expand Down
9 changes: 5 additions & 4 deletions packages/mcumgr/src/mcumgr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export class McuManager {
/**
* Query images from the device
* TODO: Implement response structure
* @returns {Promise<*>}
* @returns {Promise<NmpResponse<unknown>>}
*/
async imageReadState():Promise<any> {
async imageReadState():Promise<NmpResponse<unknown>> {
logger('Start send image read state command');
return this.sendCommand(MGMT_OP.READ, MGMT_GROUP.IMAGE, IMAGE_OPERATION.STATE);
}
Expand Down Expand Up @@ -118,7 +118,7 @@ export class McuManager {
/**
* Send command to the microcontroller
*/
async sendCommand<T>(op: MGMT_OP_TYPE, group: MGMT_GROUP_TYPE, id: MGMT_OPERATION_TYPE, data?: any): Promise<NmpResponse<T>> {
async sendCommand<T>(op: MGMT_OP_TYPE, group: MGMT_GROUP_TYPE, id: MGMT_OPERATION_TYPE, data?: unknown): Promise<NmpResponse<T>> {
logger('Start send command: %o', {op, group, id, data});

let encodedData = [];
Expand Down Expand Up @@ -156,7 +156,7 @@ export class McuManager {
#parseNmpMessage<T>(buffer: Buffer): NmpResponse<T> {
const [op, flags, length_hi, length_lo, group_hi, group_lo, seq, id] = buffer;

let data: any;
let data: unknown;

// the buffer contains data
// TODO: Maybe worth validate the length of the data section = header.length
Expand All @@ -173,6 +173,7 @@ export class McuManager {
seq,
id,
data,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/mcumgr/src/serial-peripheral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class SerialPeripheral implements Peripheral {
});
}

async #_write(data: any): Promise<void> {
async #_write(data: unknown): Promise<void> {
await this.open();

logger('Write packet %o', data);
Expand Down
6 changes: 3 additions & 3 deletions packages/mcumgr/src/util/cbor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const POW_2_24 = 5.960464477539063e-8,
POW_2_32 = 4294967296,
POW_2_53 = 9007199254740992;

export function encode(value: any) {
export function encode(value: unknown) {
let data = new ArrayBuffer(256);
let dataView = new DataView(data);
let lastLength: number;
Expand All @@ -36,7 +36,7 @@ export function encode(value: any) {
lastLength = length;
return dataView;
}
function commitWrite(x?: any) {
function commitWrite(_?: unknown) {
offset += lastLength;
}
function writeFloat64(value) {
Expand Down Expand Up @@ -169,7 +169,7 @@ export function encode(value: any) {
return ret;
}

export function decode(data: any, tagger?: Function, simpleValue?: Function) {
export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function, simpleValue?: Function) {
const dataView = new DataView(data);
let offset = 0;

Expand Down
2 changes: 1 addition & 1 deletion packages/mcumgr/src/util/convert-to-hex.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Convert the byte array to hexadecimal string
*/
export default function convertToHex(arr: Array<any>): String {
export default function convertToHex(arr: Array<number>): String {
return arr.map(x => x.toString(16).padStart(2, '0')).join(' ');
}
2 changes: 1 addition & 1 deletion packages/mcumgr/src/util/crc16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CRC16TABLE = new Uint16Array([
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
]);

export default function crc16(data: ArrayLike<any>): number {
export default function crc16(data: ArrayLike<number>): number {
let crc = 0;
const l = data.length;
for (let i = 0; i < l; i++) {
Expand Down
2 changes: 1 addition & 1 deletion packages/mcumgr/src/util/from-uint16.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Create a number from the first 2 bytes of the Array. It uses big edian encoding
*/
export default function fromUint16(arr: ArrayLike<any> | Buffer): number {
export default function fromUint16(arr: ArrayLike<number> | Buffer): number {
return (arr[0] * 256) + arr[1];
}
2 changes: 1 addition & 1 deletion packages/uhk-agent/src/electron-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async function createWindow() {
slashes: true
}));

win.on('page-title-updated', (event: any) => {
win.on('page-title-updated', (event) => {
event.preventDefault();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/uhk-agent/src/electron-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export const setMenu = (win: BrowserWindow, allowDevTools): void => {

if (process.platform === 'darwin') {
// hide "Start Dictation" submenu item in Edit menu
systemPreferences.setUserDefault('NSDisabledDictationMenuItem', 'boolean', true as any);
systemPreferences.setUserDefault('NSDisabledDictationMenuItem', 'boolean', true);
// hide "Emoji & Symbols" submenu item in Edit menu
systemPreferences.setUserDefault('NSDisabledCharacterPaletteMenuItem', 'boolean', false as any);
systemPreferences.setUserDefault('NSDisabledCharacterPaletteMenuItem', 'boolean', false);
}

const menu = Menu.buildFromTemplate(template);
Expand Down
1 change: 1 addition & 0 deletions packages/uhk-agent/src/models/queue-entry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
export interface QueueEntry {
method: Function;
bind: any;
Expand Down
2 changes: 1 addition & 1 deletion packages/uhk-agent/src/services/app-update.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class AppUpdateService extends MainServiceBase {
}
});

ipcMain.on(IpcEvents.autoUpdater.checkForUpdate, (event: Electron.Event, args: any[]) => {
ipcMain.on(IpcEvents.autoUpdater.checkForUpdate, (event: Electron.Event, args) => {
const allowPrerelease: boolean = args[0];
const logMsg = `[AppUpdateService] checkForUpdate request from renderer process. Allow prerelease: ${allowPrerelease}`;
this.logService.misc(logMsg);
Expand Down
40 changes: 20 additions & 20 deletions packages/uhk-agent/src/services/device.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class DeviceService {
this.logService.misc('[DeviceService] Cannot query udev info:', error);
});

ipcMain.on(IpcEvents.device.areBleAddressesPaired, (...args: any[]) => {
ipcMain.on(IpcEvents.device.areBleAddressesPaired, (...args) => {
this.queueManager.add({
method: this.areBleAddressesPaired,
bind: this,
Expand All @@ -168,7 +168,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.changeKeyboardLayout, (...args: any[]) => {
ipcMain.on(IpcEvents.device.changeKeyboardLayout, (...args) => {
this.queueManager.add({
method: this.changeKeyboardLayout,
bind: this,
Expand All @@ -177,7 +177,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.deleteHostConnection, (...args: any[]) => {
ipcMain.on(IpcEvents.device.deleteHostConnection, (...args) => {
this.queueManager.add({
method: this.deleteHostConnection,
bind: this,
Expand All @@ -186,7 +186,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.eraseBleSettings, (...args: any[]) => {
ipcMain.on(IpcEvents.device.eraseBleSettings, (...args) => {
this.queueManager.add({
method: this.eraseBleSettings,
bind: this,
Expand All @@ -197,7 +197,7 @@ export class DeviceService {

ipcMain.on(IpcEvents.device.toggleI2cDebugging, this.toggleI2cDebugging.bind(this));

ipcMain.on(IpcEvents.device.isRightHalfZephyrLoggingEnabled, (...args: any[]) => {
ipcMain.on(IpcEvents.device.isRightHalfZephyrLoggingEnabled, (...args) => {
this.queueManager.add({
method: this.isRightHalfZephyrLoggingEnabled,
bind: this,
Expand All @@ -206,7 +206,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.toggleRightHalfZephyrLogging, (...args: any[]) => {
ipcMain.on(IpcEvents.device.toggleRightHalfZephyrLogging, (...args) => {
this.queueManager.add({
method: this.toggleRightHalfZephyrLogging,
bind: this,
Expand All @@ -215,7 +215,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.saveUserConfiguration, (...args: any[]) => {
ipcMain.on(IpcEvents.device.saveUserConfiguration, (...args) => {
this.queueManager.add({
method: this.saveUserConfiguration,
bind: this,
Expand All @@ -224,7 +224,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.loadConfigurations, (...args: any[]) => {
ipcMain.on(IpcEvents.device.loadConfigurations, (...args) => {
this.queueManager.add({
method: this.loadConfigurations,
bind: this,
Expand All @@ -233,7 +233,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.updateFirmware, (...args: any[]) => {
ipcMain.on(IpcEvents.device.updateFirmware, (...args) => {
this.queueManager.add({
method: this.updateFirmware,
bind: this,
Expand All @@ -244,7 +244,7 @@ export class DeviceService {

ipcMain.on(IpcEvents.device.startConnectionPoller, this.startPollUhkDevice.bind(this));

ipcMain.on(IpcEvents.device.startDonglePairing, (...args: any[]) => {
ipcMain.on(IpcEvents.device.startDonglePairing, (...args) => {
this.queueManager.add({
method: this.startDonglePairing,
bind: this,
Expand All @@ -253,7 +253,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.startLeftHalfPairing, (...args: any[]) => {
ipcMain.on(IpcEvents.device.startLeftHalfPairing, (...args) => {
this.queueManager.add({
method: this.startLeftHalfPairing,
bind: this,
Expand All @@ -263,7 +263,7 @@ export class DeviceService {
});


ipcMain.on(IpcEvents.device.recoveryDevice, (...args: any[]) => {
ipcMain.on(IpcEvents.device.recoveryDevice, (...args) => {
this.queueManager.add({
method: this.recoveryDevice,
bind: this,
Expand All @@ -272,7 +272,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.recoveryModule, (...args: any[]) => {
ipcMain.on(IpcEvents.device.recoveryModule, (...args) => {
this.queueManager.add({
method: this.recoveryModule,
bind: this,
Expand All @@ -281,7 +281,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.enableUsbStackTest, (...args: any[]) => {
ipcMain.on(IpcEvents.device.enableUsbStackTest, (...args) => {
this.queueManager.add({
method: this.enableUsbStackTest,
bind: this,
Expand All @@ -290,7 +290,7 @@ export class DeviceService {
});
});

ipcMain.on(IpcEvents.device.readConfigSizes, (...args: any[]) => {
ipcMain.on(IpcEvents.device.readConfigSizes, (...args) => {
this.queueManager.add({
method: this.readConfigSizes,
bind: this,
Expand All @@ -306,7 +306,7 @@ export class DeviceService {
logService.misc('[DeviceService] init success');
}

public async areBleAddressesPaired(event: Electron.IpcMainEvent, args: Array<any>): Promise<void> {
public async areBleAddressesPaired(event: Electron.IpcMainEvent, args): Promise<void> {
this.logService.misc('[DeviceService] Check BLE Addresses are paired');

const response: AreBleAddressesPairedIpcResponse = {
Expand Down Expand Up @@ -341,7 +341,7 @@ export class DeviceService {
* Return with the actual UserConfiguration from UHK Device
* @returns {Promise<Buffer>}
*/
public async loadConfigurations(event: Electron.IpcMainEvent, args: Array<any>): Promise<void> {
public async loadConfigurations(event: Electron.IpcMainEvent, args): Promise<void> {
this.logService.misc('[DeviceService] load user configuration');

let response: ConfigurationReply;
Expand Down Expand Up @@ -789,7 +789,7 @@ export class DeviceService {
event.sender.send(IpcEvents.device.updateFirmwareReply, response);
}

public async recoveryDevice(event: Electron.IpcMainEvent, args: Array<any>): Promise<void> {
public async recoveryDevice(event: Electron.IpcMainEvent, args): Promise<void> {
const response: FirmwareUpgradeIpcResponse = {
success: false,
};
Expand Down Expand Up @@ -845,7 +845,7 @@ export class DeviceService {
this.startPollUhkDevice();
}

public async recoveryModule(event: Electron.IpcMainEvent, args: Array<any>): Promise<void> {
public async recoveryModule(event: Electron.IpcMainEvent, args): Promise<void> {
const response: FirmwareUpgradeIpcResponse = {
success: false,
};
Expand Down Expand Up @@ -907,7 +907,7 @@ export class DeviceService {
}
}

public async deleteHostConnection(event: Electron.IpcMainEvent, args: Array<any>): Promise<void> {
public async deleteHostConnection(event: Electron.IpcMainEvent, args): Promise<void> {
const {isConnectedDongleAddress, index, address} = args[0];
this.logService.misc('[DeviceService] delete host connection', { isConnectedDongleAddress, index, address });

Expand Down
4 changes: 4 additions & 0 deletions packages/uhk-agent/src/services/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ export class ElectronLogService extends LogService {
logUserConfigHelper(this.log, message, config);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
error(...args: any[]): void {
log.error(...args);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
misc(...args: any[]): void {
if (!this._options.misc) {
return;
Expand All @@ -41,6 +43,7 @@ export class ElectronLogService extends LogService {
this.log(...args);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
usb(...args: any[]): void {
if (!this._options.usb) {
return;
Expand Down Expand Up @@ -75,6 +78,7 @@ export class ElectronLogService extends LogService {
this.log('%c' + args.join(' '), 'color:orange');
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected log(...args: any[]): void {
log.log(...args);
}
Expand Down
1 change: 1 addition & 0 deletions packages/uhk-agent/src/services/main-service-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class MainServiceBase {
constructor(protected logService: LogService,
protected win: Electron.BrowserWindow) {}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected sendIpcToWindow(message: string, arg?: any) {
this.logService.misc('sendIpcToWindow:', message, arg);
if (!this.win || this.win.isDestroyed()) {
Expand Down
Loading
Loading