From 900917b9d7d896a398a98b243ebae9c93ebfa8ba Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 26 Aug 2025 17:34:29 +0100 Subject: [PATCH] more linting --- analysis/mlsentiment/mlsentiment.js | 2 +- hardware/LEDborg/78-ledborg.js | 1 - hardware/PiLcd/pilcd.js | 1 - hardware/scanBLE/101-scanBLE.js | 6 ++---- hardware/unicorn/unicorn.js | 1 - io/mdns/mdns.js | 2 +- io/stomp/18-stomp.js | 23 ++++++++++------------- social/email/61-email.js | 2 +- social/notify/57-notify.js | 1 - time/suncalc/79-suncalc.js | 2 +- utility/annotate-image/annotate.js | 2 +- 11 files changed, 17 insertions(+), 26 deletions(-) diff --git a/analysis/mlsentiment/mlsentiment.js b/analysis/mlsentiment/mlsentiment.js index b35051af..9b0f96a9 100644 --- a/analysis/mlsentiment/mlsentiment.js +++ b/analysis/mlsentiment/mlsentiment.js @@ -1,7 +1,7 @@ module.exports = function (RED) { "use strict"; - var multilangsentiment = require('multilang-sentiment'); + var multilangSentiment = require('multilang-sentiment'); function MultiLangSentimentNode(n) { RED.nodes.createNode(this, n); diff --git a/hardware/LEDborg/78-ledborg.js b/hardware/LEDborg/78-ledborg.js index 8166f3a4..f449e7e6 100644 --- a/hardware/LEDborg/78-ledborg.js +++ b/hardware/LEDborg/78-ledborg.js @@ -1,7 +1,6 @@ module.exports = function(RED) { "use strict"; - var util = require("util"); //var exec = require('child_process').exec; var spawn = require('child_process').spawn; var fs = require('fs'); diff --git a/hardware/PiLcd/pilcd.js b/hardware/PiLcd/pilcd.js index 857e72d9..8027fad3 100644 --- a/hardware/PiLcd/pilcd.js +++ b/hardware/PiLcd/pilcd.js @@ -1,7 +1,6 @@ module.exports = function(RED) { "use strict"; - var util = require("util"); var spawn = require('child_process').spawn; var fs = require('fs'); diff --git a/hardware/scanBLE/101-scanBLE.js b/hardware/scanBLE/101-scanBLE.js index 1b102b39..ab0208ac 100644 --- a/hardware/scanBLE/101-scanBLE.js +++ b/hardware/scanBLE/101-scanBLE.js @@ -10,8 +10,6 @@ module.exports = function(RED) { // Create a RED node RED.nodes.createNode(this,n); - var msg = {}; - var ble_name; var node = this; //get name and uuid from user @@ -23,7 +21,7 @@ module.exports = function(RED) { }); noble.on('scanStart', function(msg) { - msg = {}; + let msg = {}; msg.topic = node.topic; msg.payload = "Scanning initiated..." //debugging //console.log('scanning initiated...'); @@ -31,7 +29,7 @@ module.exports = function(RED) { }); noble.on('discover', function(peripheral) { - var msg = {}; + let msg = {}; msg.topic = node.topic; msg.payload = "not found"; diff --git a/hardware/unicorn/unicorn.js b/hardware/unicorn/unicorn.js index 5161cf65..dfd120ed 100644 --- a/hardware/unicorn/unicorn.js +++ b/hardware/unicorn/unicorn.js @@ -4,7 +4,6 @@ module.exports = function(RED) { var fs = require('fs'); var PNG = require('pngjs').PNG; var spawn = require('child_process').spawn; - var execSync = require('child_process').execSync; var hatCommand = __dirname+'/unihat'; var allOK = true; diff --git a/io/mdns/mdns.js b/io/mdns/mdns.js index c448cb66..7482ebf3 100644 --- a/io/mdns/mdns.js +++ b/io/mdns/mdns.js @@ -58,7 +58,7 @@ module.exports = function(RED) { this.port = n.port; this.name = n.name; this.txt = n.txt; - if (this.txt && (this.txt !== '')) { + if (this?.txt && (this.txt !== '')) { try { this.txt = JSON.parse('{'+this.txt+'}'); } catch (e) { delete this.txt; } } diff --git a/io/stomp/18-stomp.js b/io/stomp/18-stomp.js index d9942ce7..30ec6de1 100644 --- a/io/stomp/18-stomp.js +++ b/io/stomp/18-stomp.js @@ -6,17 +6,15 @@ module.exports = function(RED) { // ---------------------------------------------- // ------------------- State -------------------- // ---------------------------------------------- - function updateStatus(node, allNodes) { - let setStatus = setStatusDisconnected; - - if (node.connecting) { - setStatus = setStatusConnecting; - } else if (node.connected) { - setStatus = setStatusConnected; - } - - setStatus(node, allNodes); - } + // function updateStatus(node, allNodes) { + // let setStatus = setStatusDisconnected; + // if (node.connecting) { + // setStatus = setStatusConnecting; + // } else if (node.connected) { + // setStatus = setStatusConnected; + // } + // setStatus(node, allNodes); + // } function setStatusDisconnected(node, allNodes) { if (allNodes) { @@ -483,9 +481,8 @@ module.exports = function(RED) { const topic = node.topic || msg.topic; if (topic.length > 0) { node.serverConnection.ack(topic, msg.messageId, msg.transaction); - } else if (!(topic.length > 0)) { + } else if (typeof topic !== "string") { node.warn('No valid publish topic'); - } else { node.warn('Payload or topic is undefined/null') } diff --git a/social/email/61-email.js b/social/email/61-email.js index b423d0a8..9d87d7b1 100644 --- a/social/email/61-email.js +++ b/social/email/61-email.js @@ -1,6 +1,6 @@ /* eslint-disable indent */ -const { domainToUnicode } = require("url"); +// const { domainToUnicode } = require("url"); /** * POP3 protocol - RFC1939 - https://www.ietf.org/rfc/rfc1939.txt diff --git a/social/notify/57-notify.js b/social/notify/57-notify.js index f20c4f07..ccb3a71e 100644 --- a/social/notify/57-notify.js +++ b/social/notify/57-notify.js @@ -21,7 +21,6 @@ module.exports = function(RED) { if (fs.existsSync(msg.icon)) { icon = msg.icon; } else { node.error("Bad Icon file: "+msg.icon,msg); } } - var icon = msg.icon || image; if (typeof(title) !== 'undefined') { notifier.notify({ message:msg.payload, title:title, icon:icon }); } diff --git a/time/suncalc/79-suncalc.js b/time/suncalc/79-suncalc.js index cf15fa71..a76091cc 100644 --- a/time/suncalc/79-suncalc.js +++ b/time/suncalc/79-suncalc.js @@ -48,7 +48,7 @@ module.exports = function(RED) { sun.altitude = sun.altitude * 180 / Math.PI; sun.azimuth = sun.azimuth * 180 / Math.PI; var msg = {payload:0, topic:"sun", sun:sun, moon:moon, start:s1, end:s2, now:now}; - if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; } + if ((e1 > 0) && (e2 < 0)) { msg.payload = 1; } if (oldval == null && !node.sendAtStartup) { oldval = msg.payload; } if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"sunrise.dayState"}); } else { node.status({fill:"blue",shape:"dot",text:"sunrise.nightState"}); } diff --git a/utility/annotate-image/annotate.js b/utility/annotate-image/annotate.js index bf12fc72..3032594f 100644 --- a/utility/annotate-image/annotate.js +++ b/utility/annotate-image/annotate.js @@ -102,7 +102,7 @@ module.exports = function(RED) { else { //not enought room above imagebox, put label on the bottom if (y < 0 + (20+((defaultLineWidth*0.5)+(Number(defaultFontSize))))) { - y = y + (10+h+(((defaultLineWidth*0.5)+(Number(defaultFontSize))))); + y = y + (10+h+((defaultLineWidth*0.5)+(Number(defaultFontSize)))); ctx.textBaseline = "bottom"; } //else put the label on the top