Skip to content

Commit

Permalink
Feature/eslint support (#347)
Browse files Browse the repository at this point in the history
* Added Eslint support
* Fixed legitimate issues found with linting
* Lint optimisation for all warn issues

Co-authored-by: Angelo Perera <angelo.perera@nintex.com>
Co-authored-by: Cameron <32912464+kiwi-cam@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 22, 2021
1 parent eb3dad0 commit d6f6445
Show file tree
Hide file tree
Showing 38 changed files with 2,235 additions and 696 deletions.
51 changes: 51 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"root": true,
"plugins": [
"no-autofix"
],
"env": {
"browser": true,
"es6": true,
"node": true,
"jest": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly",

"HistoryService":true,
"Characteristic":true,
"Service":true

},
"ignorePatterns": [
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {

"global-require": "off",
"no-unused-vars": "off",
"no-mixed-spaces-and-tabs": "off",
"no-fallthrough": "off",
"no-unreachable": "off",
"no-empty": "off",
"no-console": "off",
"quotes": "off",
"brace-style": "off",
"semi": "off",
"comma-dangle": "off",
"eqeqeq": "off",

"no-extra-semi": "warn",
"dot-notation": "warn",
"no-autofix/prefer-const": "warn",

"indent": ["error", 2, { "SwitchCase": 1 }],
"linebreak-style": ["error", "unix"],
"curly": 1
}
}
8 changes: 4 additions & 4 deletions accessories/accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const catchDelayCancelError = require('../helpers/catchDelayCancelError');
class BroadlinkRMAccessory extends HomebridgeAccessory {

constructor (log, config = {}, serviceManagerType) {
if (!config.name) config.name = "Unknown Accessory"
if (!config.name) {config.name = "Unknown Accessory"}

config.resendDataAfterReload = config.resendHexAfterReload;
if (config.host) {
Expand All @@ -21,7 +21,7 @@ class BroadlinkRMAccessory extends HomebridgeAccessory {
}

super(log, config, serviceManagerType);
if (config.debug) this.debug = true
if (config.debug) {this.debug = true}

this.manufacturer = 'Broadlink';
this.model = 'RM Mini or Pro';
Expand Down Expand Up @@ -52,7 +52,7 @@ class BroadlinkRMAccessory extends HomebridgeAccessory {
break;
default:
//default to 'info':
if(this.config.logLevel !== undefined) log(`\x1b[31m[CONFIG ERROR] \x1b[33mlogLevel\x1b[0m should be one of: trace, debug, info, warning, error, critical, or none.`);
if(this.config.logLevel !== undefined) {log(`\x1b[31m[CONFIG ERROR] \x1b[33mlogLevel\x1b[0m should be one of: trace, debug, info, warning, error, critical, or none.`);}
this.logLevel = 2;
break;
}
Expand Down Expand Up @@ -109,7 +109,7 @@ class BroadlinkRMAccessory extends HomebridgeAccessory {
let { data, interval, sendCount } = parentData;

sendCount = sendCount || 1
if (sendCount > 1) interval = interval || 0.1;
if (sendCount > 1) {interval = interval || 0.1;}

// Itterate through each hex config in the array
for (let index = 0; index < sendCount; index++) {
Expand Down
18 changes: 9 additions & 9 deletions accessories/air-purifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class AirPurifierAccessory extends FanAccessory {

// User requested a the target state be set
async setTargetState (hexData, previousValue) {
const { log, name, state, serviceManager } = this;
const { log, name, state, serviceManager } = this;

// Ignore if no change to the targetPosition
if (state.targetState === previousValue) return;
// Ignore if no change to the targetPosition
if (state.targetState === previousValue) {return;}

// Set the CurrentAirPurifierState to match the switch state
log(`${name} setTargetState: currently ${previousValue === 0 ? 'manual' : 'auto'}, changing to ${state.targetState === 0 ? 'manual' : 'auto'}`);
// Set the CurrentAirPurifierState to match the switch state
log(`${name} setTargetState: currently ${previousValue === 0 ? 'manual' : 'auto'}, changing to ${state.targetState === 0 ? 'manual' : 'auto'}`);

await this.performSend(hexData);
await this.performSend(hexData);
}

updateCurrentState() {
Expand Down Expand Up @@ -49,9 +49,9 @@ class AirPurifierAccessory extends FanAccessory {
} = data || {};

// Defaults
if (config.showLockPhysicalControls !== false) config.showLockPhysicalControls = true
if (config.showSwingMode !== false && config.hideSwingMode !== true) config.showSwingMode = true
if (config.showRotationDirection !== false && config.hideRotationDirection !== true) config.showRotationDirection = true
if (config.showLockPhysicalControls !== false) {config.showLockPhysicalControls = true}
if (config.showSwingMode !== false && config.hideSwingMode !== true) {config.showSwingMode = true}
if (config.showRotationDirection !== false && config.hideRotationDirection !== true) {config.showRotationDirection = true}

this.serviceManager = new ServiceManagerTypes[serviceManagerType](name, Service.AirPurifier, this.log);

Expand Down
Loading

0 comments on commit d6f6445

Please sign in to comment.