Fix up linting errors

This commit is contained in:
Tom Sightler
2024-08-06 23:03:40 -04:00
parent c762930458
commit d1abc0a7d1
16 changed files with 501 additions and 701 deletions

View File

@@ -66,7 +66,7 @@ export default class BeamOutdoorPlug extends RingSocketDevice {
case 'on':
case 'off': {
const duration = 32767
const data = Boolean(command === 'on') ? { lightMode: 'on', duration } : { lightMode: 'default' }
const data = command === 'on' ? { lightMode: 'on', duration } : { lightMode: 'default' }
this[outletId].sendCommand('light-mode.set', data)
break;
}

View File

@@ -126,7 +126,7 @@ export default class Beam extends RingSocketDevice {
if (this.isLightGroup && this.groupId) {
this.device.location.setLightGroup(this.groupId, Boolean(command === 'on'), duration)
} else {
const data = Boolean(command === 'on') ? { lightMode: 'on', duration } : { lightMode: 'default' }
const data = command === 'on' ? { lightMode: 'on', duration } : { lightMode: 'default' }
this.device.sendCommand('light-mode.set', data)
}
break;

View File

@@ -101,7 +101,7 @@ export default class Chime extends RingPolledDevice {
this.data.volume = volumeState
}
const snoozeState = Boolean(this.device.data.do_not_disturb.seconds_left) ? 'ON' : 'OFF'
const snoozeState = this.device.data.do_not_disturb.seconds_left ? 'ON' : 'OFF'
if (snoozeState !== this.data.snooze || isPublish) {
this.mqttPublish(this.entity.snooze.state_topic, snoozeState)
this.data.snooze = snoozeState

View File

@@ -112,7 +112,7 @@ export default class Lock extends RingPolledDevice {
}
this.mqttPublish(this.entity.info.state_topic, JSON.stringify(attributes), 'attr')
this.publishAttributeEntities(attributes)
} catch(error) {
} catch {
this.debug('Could not publish attributes due to no health data')
}
}

View File

@@ -164,6 +164,7 @@ export default class Thermostat extends RingSocketDevice {
switch(mode) {
case 'off':
this.mqttPublish(this.entity.thermostat.action_topic, mode)
// Fall through
case 'cool':
case 'heat':
case 'auto':
@@ -262,11 +263,12 @@ export default class Thermostat extends RingSocketDevice {
const presetMode = value.toLowerCase()
switch(presetMode) {
case 'auxillary':
case 'none':
case 'none': {
const mode = presetMode === 'auxillary' ? 'aux' : 'heat'
this.device.setInfo({ device: { v1: { mode } } })
this.mqttPublish(this.entity.thermostat.preset_mode_state_topic, presetMode.replace(/^./, str => str.toUpperCase()))
break;
}
default:
this.debug('Received invalid preset mode command')
}

17
eslint.config.js Normal file
View File

@@ -0,0 +1,17 @@
import globals from "globals";
import pluginJs from "@eslint/js";
export default [
{
languageOptions: {
globals: globals.node
}
},
pluginJs.configs.recommended,
{
rules: {
"no-prototype-builtins": "off"
}
}
];

View File

@@ -33,7 +33,7 @@ async function getRefreshToken(systemId) {
try {
generatedToken = await restClient.getAuth(code)
return generatedToken.refresh_token
} catch(err) {
} catch {
throw('Failed to validate the entered 2FA code. (error: invalid_code)')
}
}
@@ -109,7 +109,7 @@ const main = async() => {
console.log('New config file written to '+configFile)
} catch (err) {
console.log('Failed to create new config file at '+stateFile)
conslog.log(err)
console.log(err)
}
}
}

View File

@@ -31,10 +31,11 @@ export default new class Config {
await this.loadConfigFile()
this.doMqttDiscovery()
break;
default:
default: {
const configPath = dirname(fileURLToPath(new URL('.', import.meta.url)))+'/'
this.file = (process.env.RINGMQTT_CONFIG) ? configPath+process.env.RINGMQTT_CONFIG : configPath+'config.json'
await this.loadConfigFile()
}
}
// If there's still no configured settings, force some defaults.

View File

@@ -1,5 +1,5 @@
import exithandler from './exithandler.js'
import mqtt from './mqtt.js'
export * from './exithandler.js'
export * from './mqtt.js'
import state from './state.js'
import ring from './ring.js'
import utils from './utils.js'

View File

@@ -241,6 +241,7 @@ export default new class RingMqtt {
case 'not-supported':
// Save unsupported device type for log output later
unsupportedDevices.push(device.deviceType)
// fall through
case 'ignore':
ringDevice=false
break

View File

@@ -87,9 +87,7 @@ export class WeriftPeerConnection extends Subscribed {
this.addSubscriptions(merge(this.onRequestKeyFrame, interval(4000)).subscribe(() => {
videoTransceiver.receiver
.sendRtcpPLI(track.ssrc)
.catch((e) => {
// debug(e)
})
.catch()
}))
this.requestKeyFrame()
})
@@ -131,9 +129,7 @@ export class WeriftPeerConnection extends Subscribed {
}
close() {
this.pc.close().catch((e) => {
//debug
})
this.pc.close().catch()
this.unsubscribe()
}
}

View File

@@ -150,7 +150,7 @@ export class WebrtcConnection extends Subscribed {
return
case 'pong':
return
case 'notification':
case 'notification': {
const { text } = message.body
if (text === 'camera_connected') {
this.onCameraConnected.next()
@@ -162,6 +162,7 @@ export class WebrtcConnection extends Subscribed {
return
}
break
}
case 'close':
this.callEnded()
return
@@ -219,7 +220,7 @@ export class WebrtcConnection extends Subscribed {
})
this.ws.close()
}
catch (_) {
catch {
// ignore any errors since we are stopping the call
}
this.hasEnded = true

View File

@@ -100,7 +100,7 @@ export default new class TokenApp {
const code = req.body.code
try {
generatedToken = await restClient.getAuth(code)
} catch(err) {
} catch {
generatedToken = false
const errormsg = 'The 2FA code was not accepted, please verify the code and try again.'
debug(errormsg)

1136
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,16 +15,18 @@
"js-yaml": "^4.1.0",
"minimist": "^1.2.8",
"mqtt": "^5.8.1",
"ring-client-api": "13.0.0-beta.5",
"ring-client-api": "^13.0.0",
"rxjs": "^7.8.1",
"werift": "^0.19.4",
"write-file-atomic": "^5.0.1"
},
"devDependencies": {
"eslint": "^7.32.0"
"@eslint/js": "^9.8.0",
"eslint": "^9.8.0",
"globals": "^15.9.0"
},
"overrides": {
"@eneris/push-receiver": "4.1.3"
"@eneris/push-receiver": "4.1.4"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env node
import Main from './lib/main.js'
export * from './lib/main.js'