Add tslint.json and fix coding style accordingly for the most part.
This commit is contained in:
+6
-6
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
class UhkBuffer {
|
class UhkBuffer {
|
||||||
buffer: Buffer;
|
|
||||||
offset: number;
|
|
||||||
|
|
||||||
private static maxStringByteLength = 0xFFFF;
|
private static maxStringByteLength = 0xFFFF;
|
||||||
private static longStringPrefix = 0xFF;
|
private static longStringPrefix = 0xFF;
|
||||||
private static stringEncoding = "utf8";
|
private static stringEncoding = 'utf8';
|
||||||
|
|
||||||
|
buffer: Buffer;
|
||||||
|
offset: number;
|
||||||
|
|
||||||
constructor(buffer: Buffer) {
|
constructor(buffer: Buffer) {
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
@@ -94,8 +94,8 @@ class UhkBuffer {
|
|||||||
let stringByteLength = Buffer.byteLength(str, UhkBuffer.stringEncoding);
|
let stringByteLength = Buffer.byteLength(str, UhkBuffer.stringEncoding);
|
||||||
|
|
||||||
if (stringByteLength > UhkBuffer.maxStringByteLength) {
|
if (stringByteLength > UhkBuffer.maxStringByteLength) {
|
||||||
throw "Cannot serialize string: ${stringByteLength} bytes is larger " +
|
throw 'Cannot serialize string: ${stringByteLength} bytes is larger ' +
|
||||||
"than the maximum allowed length of ${UhkBuffer.maxStringByteLength} bytes";
|
'than the maximum allowed length of ${UhkBuffer.maxStringByteLength} bytes';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stringByteLength >= UhkBuffer.longStringPrefix) {
|
if (stringByteLength >= UhkBuffer.longStringPrefix) {
|
||||||
|
|||||||
+13
-13
@@ -1,12 +1,12 @@
|
|||||||
/// <reference path="UhkBuffer.ts" />
|
/// <reference path="UhkBuffer.ts" />
|
||||||
/// <reference path="KeystrokeAction.ts" />
|
/// <reference path="KeystrokeAction.ts" />
|
||||||
|
|
||||||
let fs = require("fs");
|
let fs = require('fs');
|
||||||
let buffer: Buffer = new Buffer(1000);
|
let buffer: Buffer = new Buffer(1000);
|
||||||
buffer.fill(0);
|
buffer.fill(0);
|
||||||
let writer = new UhkBuffer(buffer);
|
let writer = new UhkBuffer(buffer);
|
||||||
|
|
||||||
let uhkConfig = JSON.parse(fs.readFileSync("uhk-config.json"));
|
let uhkConfig = JSON.parse(fs.readFileSync('uhk-config.json'));
|
||||||
let keyActions = uhkConfig.keymaps[0].layers[0].modules[0].keyActions;
|
let keyActions = uhkConfig.keymaps[0].layers[0].modules[0].keyActions;
|
||||||
|
|
||||||
let ARRAY_LAST_ELEMENT_ID = 0;
|
let ARRAY_LAST_ELEMENT_ID = 0;
|
||||||
@@ -51,8 +51,8 @@ let MOUSE_ACTION_ID_SCROLL_RIGHT = 10;
|
|||||||
let MOUSE_ACTION_ID_ACCELERATE = 11;
|
let MOUSE_ACTION_ID_ACCELERATE = 11;
|
||||||
let MOUSE_ACTION_ID_DECELERATE = 12;
|
let MOUSE_ACTION_ID_DECELERATE = 12;
|
||||||
|
|
||||||
function serializeKeyActions(keyActions) {
|
function serializeKeyActions(keyActionsParam) {
|
||||||
keyActions.forEach(function(keyAction) {
|
keyActionsParam.forEach(function(keyAction) {
|
||||||
serializeKeyAction(keyAction);
|
serializeKeyAction(keyAction);
|
||||||
});
|
});
|
||||||
writer.writeUInt8(ARRAY_LAST_ELEMENT_ID);
|
writer.writeUInt8(ARRAY_LAST_ELEMENT_ID);
|
||||||
@@ -60,29 +60,29 @@ function serializeKeyActions(keyActions) {
|
|||||||
|
|
||||||
function serializeKeyAction(keyAction) {
|
function serializeKeyAction(keyAction) {
|
||||||
switch (keyAction.actionType) {
|
switch (keyAction.actionType) {
|
||||||
case "none":
|
case 'none':
|
||||||
serializeNoneAction();
|
serializeNoneAction();
|
||||||
break;
|
break;
|
||||||
case "keystroke":
|
case 'keystroke':
|
||||||
serializeKeystrokeAction(keyAction);
|
serializeKeystrokeAction(keyAction);
|
||||||
break;
|
break;
|
||||||
case "dualRoleKeystroke":
|
case 'dualRoleKeystroke':
|
||||||
serializeDualRoleKeyAction(keyAction);
|
serializeDualRoleKeyAction(keyAction);
|
||||||
break;
|
break;
|
||||||
case "mouse":
|
case 'mouse':
|
||||||
serializeMouseAction(keyAction);
|
serializeMouseAction(keyAction);
|
||||||
break;
|
break;
|
||||||
case "playMacro":
|
case 'playMacro':
|
||||||
serializeMacroAction(keyAction);
|
serializeMacroAction(keyAction);
|
||||||
break;
|
break;
|
||||||
case "switchKeymap":
|
case 'switchKeymap':
|
||||||
serializeSwitchKeymapAction(keyAction);
|
serializeSwitchKeymapAction(keyAction);
|
||||||
break;
|
break;
|
||||||
case "switchLayer":
|
case 'switchLayer':
|
||||||
serializeSwitchLayerAction(keyAction);
|
serializeSwitchLayerAction(keyAction);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw "KeyAction doesn't have a valid actionType property: " + keyAction.actionType;
|
throw 'KeyAction doesn\'t have a valid actionType property: ' + keyAction.actionType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,4 +153,4 @@ function serializeSwitchLayerAction(switchLayerAction) {
|
|||||||
|
|
||||||
new KeystrokeAction();
|
new KeystrokeAction();
|
||||||
serializeKeyActions(keyActions);
|
serializeKeyActions(keyActions);
|
||||||
fs.writeFileSync("uhk-config.bin", buffer);
|
fs.writeFileSync('uhk-config.bin', buffer);
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"member-ordering": [
|
||||||
|
true,
|
||||||
|
"public-before-private",
|
||||||
|
"static-before-instance",
|
||||||
|
"variables-before-functions"
|
||||||
|
],
|
||||||
|
"no-inferrable-types": true,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"curly": true,
|
||||||
|
"no-construct": true,
|
||||||
|
"no-duplicate-key": true,
|
||||||
|
"no-duplicate-variable": true,
|
||||||
|
"no-eval": true,
|
||||||
|
"no-null-keyword": true,
|
||||||
|
"no-shadowed-variable": true,
|
||||||
|
"no-string-literal": true,
|
||||||
|
"no-switch-case-fall-through": true,
|
||||||
|
"no-unreachable": true,
|
||||||
|
"no-unused-expression": true,
|
||||||
|
"no-unused-variable": [
|
||||||
|
true,
|
||||||
|
"check-parameters"
|
||||||
|
],
|
||||||
|
"no-use-before-declare": true,
|
||||||
|
"no-var-keyword": true,
|
||||||
|
"radix": true,
|
||||||
|
"switch-default": true,
|
||||||
|
"triple-equals": true,
|
||||||
|
"eofline": true,
|
||||||
|
"indent": [
|
||||||
|
true,
|
||||||
|
"spaces"
|
||||||
|
],
|
||||||
|
"max-line-length": [true, 100],
|
||||||
|
"no-trailing-whitespace": true,
|
||||||
|
"trailing-comma": [
|
||||||
|
true, {
|
||||||
|
"multiline": "never",
|
||||||
|
"singleline": "never"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"align": [
|
||||||
|
true,
|
||||||
|
"parameters",
|
||||||
|
"arguments",
|
||||||
|
"statements"
|
||||||
|
],
|
||||||
|
"comment-format": [
|
||||||
|
true,
|
||||||
|
"check-space",
|
||||||
|
"check-uppercase"
|
||||||
|
],
|
||||||
|
"no-consecutive-blank-lines": true,
|
||||||
|
"one-line": [
|
||||||
|
true,
|
||||||
|
"check-open-brace",
|
||||||
|
"check-whitespace"
|
||||||
|
],
|
||||||
|
|
||||||
|
"quotemark": [
|
||||||
|
true,
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"semicolon": [
|
||||||
|
true,
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"typedef-whitespace": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"call-signature": "nospace",
|
||||||
|
"index-signature": "nospace",
|
||||||
|
"parameter": "nospace",
|
||||||
|
"property-declaration": "nospace",
|
||||||
|
"variable-declaration": "nospace"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"variable-name": [
|
||||||
|
true,
|
||||||
|
"ban-keywords",
|
||||||
|
"check-format"
|
||||||
|
],
|
||||||
|
"whitespace": [
|
||||||
|
true,
|
||||||
|
"check-branch",
|
||||||
|
"check-decl",
|
||||||
|
"check-operator",
|
||||||
|
"check-module",
|
||||||
|
"check-separator",
|
||||||
|
"check-type",
|
||||||
|
"check-typecast"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user