mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-12-27 07:21:08 +01:00
more linting
This commit is contained in:
@@ -65,8 +65,8 @@ module.exports = function(RED) {
|
||||
// setup the node group for URI. Must have a node group or exit
|
||||
var nodegroup = this.nodegroup || msg.nodegroup;
|
||||
if (typeof nodegroup === "undefined") {
|
||||
node.error("ERROR: A Node group must be specified - " + nodegroup);
|
||||
node.status({fill:"red",shape:"ring",text:"No Nodegroup"});
|
||||
node.error("ERROR: the nodegroup is undefined");
|
||||
node.status({fill:"red",shape:"ring",text:"No nodegroup"});
|
||||
return;
|
||||
} else {
|
||||
this.url += '&node=' + nodegroup;
|
||||
|
||||
@@ -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 (typeof this.txt === "string" && this.txt !== '') {
|
||||
try { this.txt = JSON.parse('{'+this.txt+'}'); }
|
||||
catch (e) { delete this.txt; }
|
||||
}
|
||||
|
||||
@@ -430,16 +430,15 @@ module.exports = function(RED) {
|
||||
|
||||
node.on("input", function(msg, send, done) {
|
||||
const topic = node.topic || msg.topic;
|
||||
if (topic.length > 0 && msg.payload) {
|
||||
if (typeof topic === "string" && topic.length > 0 && msg.payload) {
|
||||
try {
|
||||
msg.payload = JSON.stringify(msg.payload);
|
||||
} catch {
|
||||
msg.payload = `${msg.payload}`;
|
||||
}
|
||||
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');
|
||||
|
||||
} else {
|
||||
node.warn('Payload or topic is undefined/null')
|
||||
}
|
||||
@@ -479,9 +478,9 @@ module.exports = function(RED) {
|
||||
|
||||
node.on("input", function(msg, send, done) {
|
||||
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);
|
||||
} else if (typeof topic !== "string") {
|
||||
} else if (typeof topic === "string" && topic.length == 0) {
|
||||
node.warn('No valid publish topic');
|
||||
} else {
|
||||
node.warn('Payload or topic is undefined/null')
|
||||
|
||||
Reference in New Issue
Block a user