From a62972d02293ced7ba202357f3556ad8f8c91ef8 Mon Sep 17 00:00:00 2001 From: Arne Blumentritt Date: Wed, 5 May 2021 10:35:31 +0200 Subject: [PATCH] Removed lint check for beta --- .eslintrc | 3 +- package.json | 3 +- src/api.ts | 78 ++++++++++++++++++---------------- src/homebridgeNeatoPlatform.ts | 12 +++--- 4 files changed, 51 insertions(+), 45 deletions(-) diff --git a/.eslintrc b/.eslintrc index edd1da8..755890b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -10,7 +10,8 @@ "sourceType": "module" }, "ignorePatterns": [ - "dist" + "dist", + "api.ts" ], "rules": { "quotes": ["warn", "double"], diff --git a/package.json b/package.json index 70354bf..4439ac9 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,7 @@ "scripts": { "lint": "eslint src/**.ts --max-warnings=0", "watch": "npm run build && npm link && nodemon", - "build": "rimraf ./dist && tsc", - "prepublishOnly": "npm run lint && npm run build" + "build": "rimraf ./dist && tsc" }, "author": { "name": "Arne Blumentritt", diff --git a/src/api.ts b/src/api.ts index eae19b8..6f78b20 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,45 +1,51 @@ var axios = require('axios'); -function request(url, payload, method, headers, callback) { - if (!url || url === '') { - if (typeof callback === 'function') callback('no url specified'); - return; - } +function request(url, payload, method, headers, callback) +{ + if (!url || url === '') + { + if (typeof callback === 'function') callback('no url specified'); + return; + } - var options = { - data: null, - method: method === 'GET' ? 'GET' : 'POST', - url: url, - headers: { - 'Accept': 'application/vnd.neato.nucleo.v1' - } - }; + var options = { + data: null, + method: method === 'GET' ? 'GET' : 'POST', + url: url, + headers: { + 'Accept': 'application/vnd.neato.nucleo.v1' + } + }; - if (options.method === 'POST') { - options.data = payload; - } + if (options.method === 'POST') + { + options.data = payload; + } - if (typeof headers === 'object') { - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - options.headers[header] = headers[header]; - } - } - } + if (typeof headers === 'object') + { + for (var header in headers) + { + if (headers.hasOwnProperty(header)) + { + options.headers[header] = headers[header]; + } + } + } - let res, err; - - axios(options) - .then(function (response) { - res = response.data; - }) - .catch(function (error) { - err = error; - }) - .finally(function () { - // Callback needs to be called in finally block, see: https://github.com/Pmant/node-botvac/issues/15 - if (typeof callback === 'function') callback(err, res); - }); + let res, err; + + axios(options) + .then(function (response) { + res = response.data; + }) + .catch(function (error) { + err = error; + }) + .finally(function () { + // Callback needs to be called in finally block, see: https://github.com/Pmant/node-botvac/issues/15 + if (typeof callback === 'function') callback(err, res); + }); } exports.request = request; diff --git a/src/homebridgeNeatoPlatform.ts b/src/homebridgeNeatoPlatform.ts index 551a22e..914d274 100644 --- a/src/homebridgeNeatoPlatform.ts +++ b/src/homebridgeNeatoPlatform.ts @@ -41,7 +41,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin discoverRobots() { const client = new NeatoApi.Client(); - + try { @@ -57,20 +57,20 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin // Debug robot request TODO: remove after beta let that = this; - api.request(client._baseUrl + '/users/me/robots', null, 'GET', {Authorization: client._tokenType + client._token}, (function (error, result) { + api.request(client._baseUrl + "/users/me/robots", null, "GET", {Authorization: client._tokenType + client._token}, (function (error, result) { result.forEach(r => { r.serial = "xxx" + r.serial.length; r.secret_key = "xxx" + r.secret_key.length; r.mac_address = "xxx" + r.mac_address.length; that.log.debug("Robot Request Result: " + JSON.stringify(r)); }); - + if (error) { that.log.debug("Robot Request Error: " + JSON.stringify(error)); } })); - + // Get all robots from account client.getRobots((error, robots) => { if (error) @@ -112,7 +112,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin // Check if robot already exists as an accessory const uuid = this.api.hap.uuid.generate(robot._serial); const cachedRobot = this.cachedRobotAccessories.find(accessory => accessory.UUID === uuid); - + if (cachedRobot) { this.log.debug("[" + robot.name + "] Updating meta information for robot in cache."); @@ -147,7 +147,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin else { // TODO get maps - + const newRobot = new this.api.platformAccessory(robot.name, uuid); newRobot.context.robot = robot; new NeatoVacuumRobotAccessory(this, newRobot, this.config);