Skip to content
Draft
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 @@ -35,7 +35,6 @@ export const typescriptRules = {
'no-async-promise-executor': 'off',
'no-case-declarations': 'off',
'no-prototype-builtins': 'off',
'prefer-const': 'off',
}

export default [
Expand Down
58 changes: 29 additions & 29 deletions packages/mcumgr/src/util/cbor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export function encode(value: any) {

function prepareWrite(length: number) {
let newByteLength = data.byteLength;
let requiredLength = offset + length;
const requiredLength = offset + length;
while (newByteLength < requiredLength)
newByteLength <<= 1;
if (newByteLength !== data.byteLength) {
let oldDataView = dataView;
const oldDataView = dataView;
data = new ArrayBuffer(newByteLength);
dataView = new DataView(data);
let uint32count = (offset + 3) >> 2;
const uint32count = (offset + 3) >> 2;
for (let i = 0; i < uint32count; ++i)
dataView.setUint32(i << 2, oldDataView.getUint32(i << 2));
}
Expand All @@ -46,7 +46,7 @@ export function encode(value: any) {
commitWrite(prepareWrite(1).setUint8(offset, value));
}
function writeUint8Array(value) {
let dataView = prepareWrite(value.length);
const dataView = prepareWrite(value.length);
for (let i = 0; i < value.length; ++i)
dataView.setUint8(offset + i, value[i]);
commitWrite();
Expand All @@ -58,9 +58,9 @@ export function encode(value: any) {
commitWrite(prepareWrite(4).setUint32(offset, value));
}
function writeUint64(value) {
let low = value % POW_2_32;
let high = (value - low) / POW_2_32;
let dataView = prepareWrite(8);
const low = value % POW_2_32;
const high = (value - low) / POW_2_32;
const dataView = prepareWrite(8);
dataView.setUint32(offset, high);
dataView.setUint32(offset + 4, low);
commitWrite();
Expand Down Expand Up @@ -107,7 +107,7 @@ export function encode(value: any) {
return writeFloat64(value);

case "string":
let utf8data = [];
const utf8data = [];
for (i = 0; i < value.length; ++i) {
let charCode = value.charCodeAt(i);
if (charCode < 0x80) {
Expand Down Expand Up @@ -145,11 +145,11 @@ export function encode(value: any) {
writeTypeAndLength(2, value.length);
writeUint8Array(value);
} else {
let keys = Object.keys(value);
const keys = Object.keys(value);
length = keys.length;
writeTypeAndLength(5, length);
for (i = 0; i < length; ++i) {
let key = keys[i];
const key = keys[i];
encodeItem(key);
encodeItem(value[key]);
}
Expand All @@ -162,15 +162,15 @@ export function encode(value: any) {
if ("slice" in data)
return data.slice(0, offset);

let ret = new ArrayBuffer(offset);
let retView = new DataView(ret);
const ret = new ArrayBuffer(offset);
const retView = new DataView(ret);
for (let i = 0; i < offset; ++i)
retView.setUint8(i, dataView.getUint8(i));
return ret;
}

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

if (typeof tagger !== "function")
Expand All @@ -186,13 +186,13 @@ export function decode(data: any, tagger?: Function, simpleValue?: Function) {
return commitRead(length, new Uint8Array(data, offset, length));
}
function readFloat16() {
let tempArrayBuffer = new ArrayBuffer(4);
let tempDataView = new DataView(tempArrayBuffer);
let value = readUint16();
const tempArrayBuffer = new ArrayBuffer(4);
const tempDataView = new DataView(tempArrayBuffer);
const value = readUint16();

let sign = value & 0x8000;
const sign = value & 0x8000;
let exponent = value & 0x7c00;
let fraction = value & 0x03ff;
const fraction = value & 0x03ff;

if (exponent === 0x7c00)
exponent = 0xff << 10;
Expand Down Expand Up @@ -244,10 +244,10 @@ export function decode(data: any, tagger?: Function, simpleValue?: Function) {
throw "Invalid length encoding";
}
function readIndefiniteStringLength(majorType) {
let initialByte = readUint8();
const initialByte = readUint8();
if (initialByte === 0xff)
return -1;
let length = readLength(initialByte & 0x1f);
const length = readLength(initialByte & 0x1f);
if (length < 0 || (initialByte >> 5) !== majorType)
throw "Invalid indefinite length element";
return length;
Expand Down Expand Up @@ -286,9 +286,9 @@ export function decode(data: any, tagger?: Function, simpleValue?: Function) {
}

function decodeItem() {
let initialByte = readUint8();
let majorType = initialByte >> 5;
let additionalInformation = initialByte & 0x1f;
const initialByte = readUint8();
const majorType = initialByte >> 5;
const additionalInformation = initialByte & 0x1f;
let i;
let length;

Expand All @@ -314,13 +314,13 @@ export function decode(data: any, tagger?: Function, simpleValue?: Function) {
return -1 - length;
case 2:
if (length < 0) {
let elements = [];
const elements = [];
let fullArrayLength = 0;
while ((length = readIndefiniteStringLength(majorType)) >= 0) {
fullArrayLength += length;
elements.push(readArrayBuffer(length));
}
let fullArray = new Uint8Array(fullArrayLength);
const fullArray = new Uint8Array(fullArrayLength);
let fullArrayOffset = 0;
for (i = 0; i < elements.length; ++i) {
fullArray.set(elements[i], fullArrayOffset);
Expand All @@ -330,7 +330,7 @@ export function decode(data: any, tagger?: Function, simpleValue?: Function) {
}
return readArrayBuffer(length);
case 3:
let utf16data = [];
const utf16data = [];
if (length < 0) {
while ((length = readIndefiniteStringLength(majorType)) >= 0)
appendUtf16Data(utf16data, length);
Expand All @@ -350,9 +350,9 @@ export function decode(data: any, tagger?: Function, simpleValue?: Function) {
}
return retArray;
case 5:
let retObject = {};
const retObject = {};
for (i = 0; i < length || length < 0 && !readBreak(); ++i) {
let key = decodeItem();
const key = decodeItem();
retObject[key] = decodeItem();
}
return retObject;
Expand All @@ -374,7 +374,7 @@ export function decode(data: any, tagger?: Function, simpleValue?: Function) {
}
}

let ret = decodeItem();
const ret = decodeItem();
if (offset !== data.byteLength)
throw "Remaining bytes";
return ret;
Expand Down
2 changes: 1 addition & 1 deletion packages/uhk-agent/src/util/backup-user-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function getBackupUserConfigurationContent(logService: LogService,
}

export async function getCompatibleUserConfigFromHistory(logService: LogService, uniqueId: number): Promise<BackupUserConfiguration> {
let history = await loadUserConfigHistoryAsync();
const history = await loadUserConfigHistoryAsync();

const deviceHistory = history.devices.find(device => device.uniqueId === uniqueId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export enum KeyActionId {
MacroArgumentAction = 40,
}

export let keyActionType = {
export const keyActionType = {
NoneAction : 'none',
KeystrokeAction : 'keystroke',
SwitchLayerAction : 'switchLayer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export enum MacroMouseSubAction {
release = 2
}

export let macroActionType = {
export const macroActionType = {
KeyMacroAction : 'key',
MouseButtonMacroAction : 'mouseButton',
MoveMouseMacroAction : 'moveMouse',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class ModuleConfiguration {
this.navigationModeFn4Layer = buffer.readUInt8();
this.navigationModeFn5Layer = buffer.readUInt8();

let numberOfProperties = buffer.readUInt8();
const numberOfProperties = buffer.readUInt8();

for(let index = 0; index < numberOfProperties; index++){
const property = buffer.readUInt8();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class Module {
getKeyActionsCount(): number {
let count = 0

for (let keyAction of this.keyActions) {
for (const keyAction of this.keyActions) {
count++;

if (keyAction instanceof PlayMacroAction) {
Expand Down
2 changes: 1 addition & 1 deletion packages/uhk-usb/src/uhk-hid-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export class UhkHidDevice {

while (new Date().getTime() - startTime.getTime() < waitTimeout) {
iteration++;
let allDevice = [];
const allDevice = [];
for (const vidPid of vidPidPairs) {

if (enumerationMode === EnumerationModes.Bootloader && device.firmwareUpgradeMethod === FIRMWARE_UPGRADE_METHODS.MCUBOOT) {
Expand Down
4 changes: 2 additions & 2 deletions packages/uhk-usb/src/utils/convert-ms-to-duration.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Duration } from '../models/duration.js';

export function convertMsToDuration(milliseconds: number): Duration {
let days, hours, minutes, seconds;
let hours, minutes, seconds;
seconds = Math.floor(milliseconds / 1000);
minutes = Math.floor(seconds / 60);
seconds = seconds % 60;
hours = Math.floor(minutes / 60);
minutes = minutes % 60;
days = Math.floor(hours / 24);
const days = Math.floor(hours / 24);
hours = hours % 24;

return { days, hours, minutes, seconds };
Expand Down
4 changes: 2 additions & 2 deletions packages/uhk-usb/src/utils/list-available-devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function listAvailableDevices(options: ListAvailableDevicesOptions)
prevDevice.state = UsbDeviceConnectionStates.Unknown;
}

let hidDevices = options.hidDevices ?? await getUhkHidDevices();
const hidDevices = options.hidDevices ?? await getUhkHidDevices();
for (const hidDevice of hidDevices) {
const id = `h-${hidDevice.vendorId}-${hidDevice.productId}-${hidDevice.interface}`
const existingPrevDevice = prevDevices.get(id);
Expand All @@ -53,7 +53,7 @@ export async function listAvailableDevices(options: ListAvailableDevicesOptions)
}
}

let serialDevices = options.serialDevices ?? await SerialPort.list();
const serialDevices = options.serialDevices ?? await SerialPort.list();
for (const serialDevice of serialDevices) {
const id = `s-${serialDevice.vendorId}-${serialDevice.productId}-${serialDevice.path}`
const existingPrevDevice = prevDevices.get(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ export class SvgKeystrokeKeyComponent implements OnChanges {
if (this.labelSource) {
this.labelType = 'icon';
} else {
let newLabelSource: string[];
newLabelSource = this.mapper.scanCodeToText(scancode, this.keystrokeAction.type);
const newLabelSource = this.mapper.scanCodeToText(scancode, this.keystrokeAction.type);
if (newLabelSource) {
if (this.secondaryText && newLabelSource.length === 2) {
if (isRectangleAsSecondaryRole || bottomSideMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class MonacoEditorCompletionItemProvider implements monaco.languages.Comp
}

const monacoSuggestions: monaco.languages.CompletionItem[] = nelaSuggestions.map(it => {
let kind = this.guessKind(it.suggestion, it.originRule);
const kind = this.guessKind(it.suggestion, it.originRule);

return {
insertText: it.text(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Uhk80MigratorService implements OnDestroy {
return userConfig;
}

let hasConfiguredExcessKey = this.hasUhk80ConfiguredExcessKey(userConfig);
const hasConfiguredExcessKey = this.hasUhk80ConfiguredExcessKey(userConfig);

if (hasConfiguredExcessKey) {
return userConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ function generateName(items: { name: string }[], name: string) {

function generateMacroId(macros: Macro[]) {
let newId = 0;
let usedMacroIds = new Set();
const usedMacroIds = new Set();

macros.forEach((macro: Macro) => {
if (macro.id > newId) {
Expand Down