From 64d3b11fd929552cfe6841e3df26b1a5dbf516f2 Mon Sep 17 00:00:00 2001 From: dceejay Date: Mon, 11 May 2015 20:04:51 +0100 Subject: [PATCH] slightly nicer jscs style updates to several nodes again not pushed to npm - still just whitespace. --- .jscsrc | 1 + hardware/scanBLE/101-scanBLE.js | 2 +- hardware/sensorTag/79-sensorTag.js | 38 +++++++++++++++--------------- io/emoncms/88-emoncms.js | 6 ++--- social/dweetio/55-dweetio.js | 2 +- social/pushbullet/57-pushbullet.js | 6 ++--- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.jscsrc b/.jscsrc index 6b8a5051..de427c30 100644 --- a/.jscsrc +++ b/.jscsrc @@ -5,6 +5,7 @@ "requireCurlyBraces": true, "disallowMixedSpacesAndTabs": true, "disallowMultipleSpaces": {"allowEOLComments": true}, + "requireSpaceBeforeBlockStatements": 1, //"requireSemicolons": true, //"validateParameterSeparator": ", ", "requireSpaceAfterKeywords": ["do","for","if","else","switch","case","try","while"] diff --git a/hardware/scanBLE/101-scanBLE.js b/hardware/scanBLE/101-scanBLE.js index 7f4282ac..6e280ff3 100644 --- a/hardware/scanBLE/101-scanBLE.js +++ b/hardware/scanBLE/101-scanBLE.js @@ -37,7 +37,7 @@ function BleScan(n) { this.ble_name = n.ble_name; this.ble_uuid = n.ble_uuid; - this.on("input", function(msg){ + this.on("input", function(msg) { noble.startScanning(); }); diff --git a/hardware/sensorTag/79-sensorTag.js b/hardware/sensorTag/79-sensorTag.js index 5e3d4b2d..9c725859 100644 --- a/hardware/sensorTag/79-sensorTag.js +++ b/hardware/sensorTag/79-sensorTag.js @@ -41,27 +41,27 @@ function sensorTagNode(n) { if ( typeof node.stag == "undefined") { //console.log("starting"); - SensorTag.discover(function(sensorTag){ + SensorTag.discover(function(sensorTag) { node.stag = sensorTag; - sensorTag.connect(function(){ + sensorTag.connect(function() { //console.log("connected"); - sensorTag.discoverServicesAndCharacteristics(function(){ - sensorTag.enableIrTemperature(function(){}); + sensorTag.discoverServicesAndCharacteristics(function() { + sensorTag.enableIrTemperature(function() {}); sensorTag.on('irTemperatureChange', - function(objectTemperature, ambientTemperature){ + function(objectTemperature, ambientTemperature) { var msg = {'topic': node.topic + '/temperature'}; msg.payload = {'object': objectTemperature.toFixed(1), 'ambient':ambientTemperature.toFixed(1) }; node.send(msg); }); - sensorTag.enableBarometricPressure(function(){}); - sensorTag.on('barometricPressureChange', function(pressure){ + sensorTag.enableBarometricPressure(function() {}); + sensorTag.on('barometricPressureChange', function(pressure) { var msg = {'topic': node.topic + '/pressure'}; msg.payload = {'pres': pressure.toFixed(1)}; node.send(msg); }); - sensorTag.enableHumidity(function(){}); + sensorTag.enableHumidity(function() {}); sensorTag.on('humidityChange', function(temp, humidity) { var msg = {'topic': node.topic + '/humidity'}; msg.payload = {'temp': temp.toFixed(1), @@ -69,25 +69,25 @@ function sensorTagNode(n) { }; node.send(msg); }); - sensorTag.enableAccelerometer(function(){}); - sensorTag.on('accelerometerChange', function(x,y,z){ + sensorTag.enableAccelerometer(function() {}); + sensorTag.on('accelerometerChange', function(x,y,z) { var msg = {'topic': node.topic + '/accelerometer'}; msg.payload = {'x': x, 'y': y, 'z': z}; node.send(msg); }); sensorTag.enableMagnetometer(function() {}); - sensorTag.on('magnetometerChange', function(x,y,z){ + sensorTag.on('magnetometerChange', function(x,y,z) { var msg = {'topic': node.topic + '/magnetometer'}; msg.payload = {'x': x, 'y': y, 'z': z}; node.send(msg); }); - sensorTag.enableGyroscope(function(){}); - sensorTag.on('gyroscopeChange', function(x,y,z){ + sensorTag.enableGyroscope(function() {}); + sensorTag.on('gyroscopeChange', function(x,y,z) { var msg = {'topic': node.topic + '/gyroscope'}; msg.payload = {'x': x, 'y': y, 'z': z}; node.send(msg); }); - sensorTag.on('simpleKeyChange', function(left, right){ + sensorTag.on('simpleKeyChange', function(left, right) { var msg = {'topic': node.topic + '/keys'}; msg.payload = {'left': left, 'right': right}; node.send(msg); @@ -104,21 +104,21 @@ function sensorTagNode(n) { function enable(node) { if (node.temperature) { - node.stag.notifyIrTemperature(function(){}); + node.stag.notifyIrTemperature(function() {}); } else { - node.stag.unnotifyIrTemperature(function(){}); + node.stag.unnotifyIrTemperature(function() {}); } if (node.pressure) { - node.stag.notifyBarometricPressure(function(){}); + node.stag.notifyBarometricPressure(function() {}); } else { - node.stag.unnotifyBarometricPressure(function(){}); + node.stag.unnotifyBarometricPressure(function() {}); } if (node.humidity) { node.stag.notifyHumidity(function() {}); } else { node.stag.unnotifyHumidity(function() {}); } - if (node.accelerometer){ + if (node.accelerometer) { node.stag.notifyAccelerometer(function() {}); } else { node.stag.unnotifyAccelerometer(function() {}); diff --git a/io/emoncms/88-emoncms.js b/io/emoncms/88-emoncms.js index 03ef4d83..0d1b29b9 100644 --- a/io/emoncms/88-emoncms.js +++ b/io/emoncms/88-emoncms.js @@ -43,17 +43,17 @@ module.exports = function(RED) { else { http = require("http"); } this.on("input", function(msg) { this.url = this.baseurl + '/input/post.json?'; - if (msg.payload.indexOf(':') > -1){ + if (msg.payload.indexOf(':') > -1) { this.url += 'json={' + msg.payload + '}'; } else { this.url += 'csv='+msg.payload; } this.url += '&apikey='+this.apikey; var nodegroup = this.nodegroup || msg.nodegroup; - if (nodegroup !== ""){ + if (nodegroup !== "") { this.url += '&node=' + nodegroup; } - if (typeof msg.time !== 'undefined'){ + if (typeof msg.time !== 'undefined') { this.url += '&time=' + msg.time; } node.log("[emoncms] "+this.url); diff --git a/social/dweetio/55-dweetio.js b/social/dweetio/55-dweetio.js index 29ab48a1..88d26562 100644 --- a/social/dweetio/55-dweetio.js +++ b/social/dweetio/55-dweetio.js @@ -50,7 +50,7 @@ module.exports = function(RED) { if (dweetio == null) { dweetio = new DweetClient(); } var node = this; - dweetio.listen_for(node.thing, function(dweet){ + dweetio.listen_for(node.thing, function(dweet) { // This will be called anytime there is a new dweet for my-thing if (dweet.content.hasOwnProperty("payload")) { dweet.payload=dweet.content.payload; diff --git a/social/pushbullet/57-pushbullet.js b/social/pushbullet/57-pushbullet.js index 86a5b005..cec3a3f7 100644 --- a/social/pushbullet/57-pushbullet.js +++ b/social/pushbullet/57-pushbullet.js @@ -93,7 +93,7 @@ module.exports = function(RED) { try { resolve(res.pushes[0].modified); } - catch(ex){ + catch(ex) { self.warn('Unable to get history.'); resolve(0); } @@ -329,7 +329,7 @@ module.exports = function(RED) { try { this.deviceid = this.credentials.deviceid; } - catch(err){} + catch(err) {} } if (configNode) { @@ -390,7 +390,7 @@ module.exports = function(RED) { PushbulletOut.prototype.pushMsg = function(pushtype, deviceid, title, msg) { var self = this; if (this.pusher) { - var handleErr = function(msg){ + var handleErr = function(msg) { return function(err) { if (err) { self.error(msg);