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 @@ -27,7 +27,6 @@ export const typescriptRules = {
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unbound-method': 'off',
'no-case-declarations': 'off',
'no-prototype-builtins': 'off',
'preserve-caught-error': 'off',
}
Expand Down
40 changes: 29 additions & 11 deletions packages/mcumgr/src/util/cbor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function encode(value: unknown) {
return writeUint8(0xf7);

switch (typeof value) {
case "number":
case "number": {
if (Math.floor(value) === value) {
if (0 <= value && value <= POW_2_53)
return writeTypeAndLength(0, value);
Expand All @@ -105,8 +105,9 @@ export function encode(value: unknown) {
}
writeUint8(0xfb);
return writeFloat64(value);
}

case "string":
case "string": {
const utf8data = [];
for (i = 0; i < value.length; ++i) {
let charCode = value.charCodeAt(i);
Expand All @@ -133,8 +134,9 @@ export function encode(value: unknown) {

writeTypeAndLength(3, utf8data.length);
return writeUint8Array(utf8data);
}

default:
default: {
let length;
if (Array.isArray(value)) {
length = value.length;
Expand All @@ -154,6 +156,7 @@ export function encode(value: unknown) {
encodeItem(value[key]);
}
}
}
}
}

Expand Down Expand Up @@ -308,11 +311,15 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function,
throw "Invalid length";

switch (majorType) {
case 0:
case 0: {
return length;
case 1:
}

case 1: {
return -1 - length;
case 2:
}

case 2: {
if (length < 0) {
const elements = [];
let fullArrayLength = 0;
Expand All @@ -329,15 +336,19 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function,
return fullArray;
}
return readArrayBuffer(length);
case 3:
}

case 3: {
const utf16data = [];
if (length < 0) {
while ((length = readIndefiniteStringLength(majorType)) >= 0)
appendUtf16Data(utf16data, length);
} else
appendUtf16Data(utf16data, length);
return String.fromCharCode.apply(null, utf16data);
case 4:
}

case 4: {
let retArray;
if (length < 0) {
retArray = [];
Expand All @@ -349,16 +360,22 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function,
retArray[i] = decodeItem();
}
return retArray;
case 5:
}

case 5: {
const retObject = {};
for (i = 0; i < length || length < 0 && !readBreak(); ++i) {
const key = decodeItem();
retObject[key] = decodeItem();
}
return retObject;
case 6:
}

case 6: {
return tagger(decodeItem(), length);
case 7:
}

case 7: {
switch (length) {
case 20:
return false;
Expand All @@ -371,6 +388,7 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function,
default:
return simpleValue(length);
}
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions packages/uhk-agent/src/services/sudo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@ export class SudoService {
}

switch (process.platform) {
case 'linux':
case 'linux': {
await this.setPrivilegeOnLinux(event);
break;
default:
}

default: {
const response: IpcResponse = {
success: false,
error: {message: 'Permissions couldn\'t be set. Invalid platform: ' + process.platform}
error: { message: 'Permissions couldn\'t be set. Invalid platform: ' + process.platform }
};

event.sender.send(IpcEvents.device.setPrivilegeOnLinuxReply, response);
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,17 @@ export class MacroMouseTabComponent extends MacroBaseComponent implements OnInit
isMacroValid = () => {
switch (this.macroAction.constructor) {
case MoveMouseMacroAction:
case ScrollMouseMacroAction:
const {x, y} = this.macroAction as MoveMouseMacroAction;
case ScrollMouseMacroAction: {
const { x, y } = this.macroAction as MoveMouseMacroAction;
return x !== undefined && x !== null && y !== undefined && y !== null &&
(x !== 0 || y !== 0) && x < 10000 && x > -10000 && y < 10000 && y > -10000;
case MouseButtonMacroAction:
const {mouseButtonsMask} = this.macroAction as MouseButtonMacroAction;
}

case MouseButtonMacroAction: {
const { mouseButtonsMask } = this.macroAction as MouseButtonMacroAction;
return !!mouseButtonsMask;
}

default:
return true;
}
Expand Down
Loading