mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-12-26 23:16:47 +01:00
more linting
This commit is contained in:
@@ -3,7 +3,7 @@ module.exports = function(RED) {
|
|||||||
"use strict";
|
"use strict";
|
||||||
var blinkstick = require("blinkstick");
|
var blinkstick = require("blinkstick");
|
||||||
|
|
||||||
var availableModes = ["normal", "inverted", "neopixel"];
|
//var availableModes = ["normal", "inverted", "neopixel"];
|
||||||
var availableTasks = ["set_color", "blink", "pulse", "morph"];
|
var availableTasks = ["set_color", "blink", "pulse", "morph"];
|
||||||
|
|
||||||
Object.size = function(obj) {
|
Object.size = function(obj) {
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ module.exports = function(RED) {
|
|||||||
// setup the node group for URI. Must have a node group or exit
|
// setup the node group for URI. Must have a node group or exit
|
||||||
var nodegroup = this.nodegroup || msg.nodegroup;
|
var nodegroup = this.nodegroup || msg.nodegroup;
|
||||||
if (typeof nodegroup === "undefined") {
|
if (typeof nodegroup === "undefined") {
|
||||||
node.error("ERROR: A Node group must be specified - " + nodegroup);
|
node.error("ERROR: the nodegroup is undefined");
|
||||||
node.status({fill:"red",shape:"ring",text:"No Nodegroup"});
|
node.status({fill:"red",shape:"ring",text:"No nodegroup"});
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
this.url += '&node=' + nodegroup;
|
this.url += '&node=' + nodegroup;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ module.exports = function(RED) {
|
|||||||
this.port = n.port;
|
this.port = n.port;
|
||||||
this.name = n.name;
|
this.name = n.name;
|
||||||
this.txt = n.txt;
|
this.txt = n.txt;
|
||||||
if (this?.txt && (this.txt !== '')) {
|
if (typeof this.txt === "string" && this.txt !== '') {
|
||||||
try { this.txt = JSON.parse('{'+this.txt+'}'); }
|
try { this.txt = JSON.parse('{'+this.txt+'}'); }
|
||||||
catch (e) { delete this.txt; }
|
catch (e) { delete this.txt; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -430,16 +430,15 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
node.on("input", function(msg, send, done) {
|
node.on("input", function(msg, send, done) {
|
||||||
const topic = node.topic || msg.topic;
|
const topic = node.topic || msg.topic;
|
||||||
if (topic.length > 0 && msg.payload) {
|
if (typeof topic === "string" && topic.length > 0 && msg.payload) {
|
||||||
try {
|
try {
|
||||||
msg.payload = JSON.stringify(msg.payload);
|
msg.payload = JSON.stringify(msg.payload);
|
||||||
} catch {
|
} catch {
|
||||||
msg.payload = `${msg.payload}`;
|
msg.payload = `${msg.payload}`;
|
||||||
}
|
}
|
||||||
node.serverConnection.publish(topic, msg.payload, msg.headers || {});
|
node.serverConnection.publish(topic, msg.payload, msg.headers || {});
|
||||||
} else if (!topic.length > 0) {
|
} else if (typeof topic === "string" && topic.length == 0) {
|
||||||
node.warn('No valid publish topic');
|
node.warn('No valid publish topic');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
node.warn('Payload or topic is undefined/null')
|
node.warn('Payload or topic is undefined/null')
|
||||||
}
|
}
|
||||||
@@ -479,9 +478,9 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
node.on("input", function(msg, send, done) {
|
node.on("input", function(msg, send, done) {
|
||||||
const topic = node.topic || msg.topic;
|
const topic = node.topic || msg.topic;
|
||||||
if (topic.length > 0) {
|
if (typeof topic === "string" && topic.length > 0) {
|
||||||
node.serverConnection.ack(topic, msg.messageId, msg.transaction);
|
node.serverConnection.ack(topic, msg.messageId, msg.transaction);
|
||||||
} else if (typeof topic !== "string") {
|
} else if (typeof topic === "string" && topic.length == 0) {
|
||||||
node.warn('No valid publish topic');
|
node.warn('No valid publish topic');
|
||||||
} else {
|
} else {
|
||||||
node.warn('Payload or topic is undefined/null')
|
node.warn('Payload or topic is undefined/null')
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
else if (node.action === "b64") {
|
else if (node.action === "b64") {
|
||||||
if ( typeof value === "string") {
|
if ( typeof value === "string") {
|
||||||
var load = value.replace(/\s+/g,'');
|
let load = value.replace(/\s+/g,'');
|
||||||
if (regexp.test(load) && (load.length % 4 === 0) ) {
|
if (regexp.test(load) && (load.length % 4 === 0) ) {
|
||||||
value = Buffer.from(load,'base64').toString();
|
value = Buffer.from(load,'base64').toString();
|
||||||
RED.util.setMessageProperty(msg,node.property,value);
|
RED.util.setMessageProperty(msg,node.property,value);
|
||||||
@@ -37,7 +37,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
else if (typeof value === "string") {
|
else if (typeof value === "string") {
|
||||||
// Take base64 string and make into binary buffer
|
// Take base64 string and make into binary buffer
|
||||||
var load = value.replace(/\s+/g,''); // remove any whitespace
|
let load = value.replace(/\s+/g,''); // remove any whitespace
|
||||||
//var load = value.replace(/[\t\r\n\f]+/g,'');
|
//var load = value.replace(/[\t\r\n\f]+/g,'');
|
||||||
//var load = value;
|
//var load = value;
|
||||||
if ( regexp.test(load) && (load.length % 4 === 0) ) {
|
if ( regexp.test(load) && (load.length % 4 === 0) ) {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (annotation.labelLocation === "bottom") {
|
else if (annotation.labelLocation === "bottom") {
|
||||||
y = y + (10+h+(((defaultLineWidth*0.5)+(Number(defaultFontSize)))));
|
y = y + (10+h+((defaultLineWidth*0.5)+(Number(defaultFontSize))));
|
||||||
ctx.textBaseline = "bottom";
|
ctx.textBaseline = "bottom";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function convertDegreesMinutesSecondsToDecimals(degrees, minutes, seconds) {
|
// function convertDegreesMinutesSecondsToDecimals(degrees, minutes, seconds) {
|
||||||
var result;
|
// var result;
|
||||||
result = degrees + (minutes / 60) + (seconds / 3600);
|
// result = degrees + (minutes / 60) + (seconds / 3600);
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function ExifNode(n) {
|
function ExifNode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
|
|||||||
Reference in New Issue
Block a user