diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..3d74e96a8 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +**/renderer/modal/* +**/renderer/lang/* +*.bundle.js* +*.build.js* diff --git a/app/src/main/datahandler/handler.js b/app/src/main/datahandler/handler.js index cde8d0b2d..0fbe6483e 100644 --- a/app/src/main/datahandler/handler.js +++ b/app/src/main/datahandler/handler.js @@ -1,78 +1,82 @@ 'use strict'; + function Handler(config) { - this.config = config; - switch (config.entry.protocol) { - case 'bytearray': { - this.sendHandler = require('./bytearray.js').create(config.id, config.entry.bufferSize || config.entry.buffersize); - break; - } - case 'json': { - this.sendHandler = require('./json.js').create(config.id); - break; - } + this.config = config; + switch (config.entry.protocol) { + case 'bytearray': { + this.sendHandler = require('./bytearray.js').create( + config.id, + config.entry.bufferSize || config.entry.buffersize, + ); + break; + } + case 'json': { + this.sendHandler = require('./json.js').create(config.id); + break; + } // case 'dmp': { // this.sendHandler = require('./dmp.js').create(config.id); // break; // } - } + } } Handler.prototype.encode = function() { - if (this.sendHandler) { - return this.sendHandler.encode(); - } + if (this.sendHandler) { + return this.sendHandler.encode(); + } }; Handler.prototype.decode = function(data, type) { - if (type == 'binary') { - if (data[1] != 0x00) { - if (!this.receiveHandler) { - switch (data[5]) { - case 0x01: { - this.receiveHandler = require('./bytearray.js').create(this.config.id); - break; - } + if (type == 'binary') { + if (data[1] != 0x00) { + if (!this.receiveHandler) { + switch (data[5]) { + case 0x01: { + this.receiveHandler = require('./bytearray.js').create(this.config.id); + break; + } // case 0x03: { // this.receiveHandler = require('./dmp.js').create(this.config.id); // break; // } - } - } - if (this.receiveHandler) { - this.receiveHandler.decode(data); - } - } - } else if (type == 'utf8') { - if (!this.receiveHandler) { - this.receiveHandler = require('./json.js').create(this.config.id); - } - if (this.receiveHandler) { - this.receiveHandler.decode(data); - } - } + } + } + if (this.receiveHandler) { + this.receiveHandler.decode(data); + } + } + } else if (type == 'utf8') { + if (!this.receiveHandler) { + this.receiveHandler = require('./json.js').create(this.config.id); + } + if (this.receiveHandler) { + this.receiveHandler.decode(data); + } + } }; Handler.prototype.e = function(arg) { - if (this.receiveHandler) { - return this.receiveHandler.e(arg); - } - return false; + if (this.receiveHandler) { + return this.receiveHandler.e(arg); + } + return false; }; Handler.prototype.read = function(arg) { - if (this.receiveHandler) { - return this.receiveHandler.read(arg); - } - return 0; + if (this.receiveHandler) { + return this.receiveHandler.read(arg); + } + return 0; }; Handler.prototype.write = function(arg1, arg2) { - if (this.sendHandler) { - return this.sendHandler.write(arg1, arg2); - } - return false; + if (this.sendHandler) { + return this.sendHandler.write(arg1, arg2); + } + return false; }; module.exports.create = function(config) { - return new Handler(config); + return new Handler(config); }; diff --git a/app/src/main/serial/connector.js b/app/src/main/serial/connector.js index 67a846222..ce9f8c6d7 100644 --- a/app/src/main/serial/connector.js +++ b/app/src/main/serial/connector.js @@ -355,11 +355,11 @@ class SerialConnector extends BaseConnector { !this.isSending ) { this.isSending = true; - + let resultData = data; if (this.options.stream === 'string') { - data = Buffer.from(data, 'utf8'); + resultData = Buffer.from(data, 'utf8'); } - this.serialPort.write(data, () => { + this.serialPort.write(resultData, () => { if (this.serialPort) { this.serialPort.drain(() => { this.received = true; diff --git a/app/src/renderer/js/rendererRouter.js b/app/src/renderer/js/rendererRouter.js index 74cbcb070..7276df974 100644 --- a/app/src/renderer/js/rendererRouter.js +++ b/app/src/renderer/js/rendererRouter.js @@ -122,6 +122,8 @@ class RendererRouter { const { appName } = this.sharedObject; const { translator, Modal } = window; const translate = (str) => translator.translate(str); + + // eslint-disable-next-line new-cap const modal = new Modal.default(); if (appName === 'hardware' && navigator.onLine) {