From 552e360f6f52e2b98b87bc7ec04e6b0e54ad6f2e Mon Sep 17 00:00:00 2001 From: Arne Blumentritt Date: Tue, 4 May 2021 14:08:54 +0200 Subject: [PATCH] Linting --- .eslintrc | 8 ++++---- src/homebridgeNeatoPlatform.ts | 24 ++++++++++++++---------- src/index.ts | 11 ++++++----- src/settings.ts | 4 ++-- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.eslintrc b/.eslintrc index ba9b8ef..4ef49bb 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,16 +13,16 @@ "dist" ], "rules": { - "quotes": ["warn", "single"], - "indent": ["warn", 2, { "SwitchCase": 1 }], + "quotes": ["warn", "double"], + "indent": ["warn", "tab"], "semi": ["off"], "comma-dangle": ["warn", "always-multiline"], "dot-notation": "off", "eqeqeq": "warn", "curly": ["warn", "all"], - "brace-style": ["warn"], + "brace-style": ["warn", "allman"], "prefer-arrow-callback": ["warn"], - "max-len": ["warn", 140], + "max-len": ["warn", 200], "no-console": ["warn"], // use the provided Homebridge log method instead "no-non-null-assertion": ["off"], "comma-spacing": ["error"], diff --git a/src/homebridgeNeatoPlatform.ts b/src/homebridgeNeatoPlatform.ts index 823a4c0..370e4f7 100644 --- a/src/homebridgeNeatoPlatform.ts +++ b/src/homebridgeNeatoPlatform.ts @@ -1,7 +1,7 @@ -import {API, Characteristic, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service} from 'homebridge'; +import {API, Characteristic, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service} from "homebridge"; import NeatoApi from "node-botvac"; -import {PLATFORM_NAME, PLUGIN_NAME} from './settings'; -import {NeatoVacuumRobotAccessory} from './accessories/NeatoVacuumRobot'; +import {PLATFORM_NAME, PLUGIN_NAME} from "./settings"; +import {NeatoVacuumRobotAccessory} from "./accessories/NeatoVacuumRobot"; /** * HomebridgePlatform @@ -21,7 +21,8 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin public readonly config: PlatformConfig, public readonly api: API) { - this.api.on('didFinishLaunching', () => { + this.api.on("didFinishLaunching", () => + { this.discoverRobots(); }); } @@ -38,12 +39,13 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin discoverRobots() { - let client = new NeatoApi.Client(); + const client = new NeatoApi.Client(); try { // Login - client.authorize((this.config)['email'], (this.config)['password'], false, (error) => { + client.authorize((this.config)["email"], (this.config)["password"], false, (error) => + { if (error) { this.log.warn("Cannot connect to neato server. No new robots will be found and existing robots will be unresponsive."); @@ -53,7 +55,8 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin } // Get all robots from account - client.getRobots((error, robots) => { + client.getRobots((error, robots) => + { if (error) { this.log.error("Successful login but can't connect to your neato robot: " + error); @@ -67,12 +70,13 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin return; } - this.log.info("Neato account has " + robots.length + " robot " + (robots.length == 1 ? "" : "s")); + this.log.info("Neato account has " + robots.length + " robot " + (robots.length === 1 ? "" : "s")); - for (let robot of robots) + for (const robot of robots) { // Get additional information for the robot - robot.getState((error, state) => { + robot.getState((error, state) => + { if (error) { this.log.error("Error getting robot meta information: " + error + ": " + state); diff --git a/src/index.ts b/src/index.ts index 24802d0..6ab96b8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,12 @@ -import { API } from 'homebridge'; +import {API} from "homebridge"; -import { PLATFORM_NAME } from './settings'; -import { HomebridgeNeatoPlatform } from './homebridgeNeatoPlatform'; +import {PLATFORM_NAME} from "./settings"; +import {HomebridgeNeatoPlatform} from "./homebridgeNeatoPlatform"; /** * This method registers the platform with Homebridge */ -export = (api: API) => { - api.registerPlatform(PLATFORM_NAME, HomebridgeNeatoPlatform); +export = (api: API) => +{ + api.registerPlatform(PLATFORM_NAME, HomebridgeNeatoPlatform); }; diff --git a/src/settings.ts b/src/settings.ts index be8b746..662a701 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,9 +1,9 @@ /** * This is the name of the platform that users will use to register the plugin in the Homebridge config.json */ -export const PLATFORM_NAME = 'NeatoVacuumRobot'; +export const PLATFORM_NAME = "NeatoVacuumRobot"; /** * This must match the name of your plugin as defined the package.json */ -export const PLUGIN_NAME = 'homebridge-neato'; \ No newline at end of file +export const PLUGIN_NAME = "homebridge-neato"; \ No newline at end of file