Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/eslint support #347

Merged
merged 4 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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