From c0c4ce6958f335895e889fd6ddcc3bc1df39fdec Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Fri, 7 Mar 2014 23:33:59 -0800 Subject: [PATCH] Small changes to appease JSHint --- .jshintrc | 5 ++++- lib/basestar.js | 4 ++-- lib/cli/bluetooth.js | 2 +- lib/cli/scan.js | 2 +- lib/cylon.js | 4 ++-- lib/generators/adaptor.js | 2 +- lib/generators/adaptor/test/support/runner.js | 2 +- lib/logger.js | 6 +++--- lib/robot.js | 4 ++-- lib/utils.js | 10 ++++------ 10 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.jshintrc b/.jshintrc index 6977997..ff78d4d 100644 --- a/.jshintrc +++ b/.jshintrc @@ -28,6 +28,9 @@ "sinon", "subclass", "proxyTestStubs", - "proxyFunctionsToObject" + "proxyFunctionsToObject", + "every", + "hasProp", + "bind" ] } diff --git a/lib/basestar.js b/lib/basestar.js index 6a9f5fd..a32be66 100644 --- a/lib/basestar.js +++ b/lib/basestar.js @@ -77,7 +77,7 @@ namespace("Cylon", function() { // // Returns this.connector Basestar.prototype.defineAdaptorEvent = function(opts) { - if (typeof opts === 'string') { opts = { eventName: opts } } + if (typeof opts === 'string') { opts = { eventName: opts }; } opts['source'] = this.connector; opts['target'] = this.connection; @@ -93,7 +93,7 @@ namespace("Cylon", function() { // // Returns this.connection Basestar.prototype.defineDriverEvent = function(opts) { - if (typeof opts === 'string') { opts = { eventName: opts } } + if (typeof opts === 'string') { opts = { eventName: opts }; } opts['source'] = this.connection; opts['target'] = this.device; diff --git a/lib/cli/bluetooth.js b/lib/cli/bluetooth.js index 3c8914c..07eb738 100644 --- a/lib/cli/bluetooth.js +++ b/lib/cli/bluetooth.js @@ -4,7 +4,7 @@ var os = require('os'), namespace("Cylon.CLI", function() { this.Bluetooth = (function() { function Bluetooth() { - this.process = new Cylon.Process; + this.process = new Cylon.Process(); this.platform = os.platform(); } diff --git a/lib/cli/scan.js b/lib/cli/scan.js index b53af78..208b7f8 100644 --- a/lib/cli/scan.js +++ b/lib/cli/scan.js @@ -4,7 +4,7 @@ var os = require('os'), namespace('Cylon.CLI', function() { this.Scan = (function() { function Scan() { - this.process = new Cylon.Process; + this.process = new Cylon.Process(); this.platform = os.platform(); } diff --git a/lib/cylon.js b/lib/cylon.js index ca35d1e..832d29a 100644 --- a/lib/cylon.js +++ b/lib/cylon.js @@ -48,7 +48,7 @@ var Cylon = (function() { if (process.platform === "win32") { var readline = require("readline"), - io = { input: process.stdin, output: process.stdout } + io = { input: process.stdin, output: process.stdout }; readline.createInterface(io).on("SIGINT", function() { process.emit("SIGINT"); @@ -91,7 +91,7 @@ var Cylon = (function() { // // Returns the API configuration Master.prototype.api = function(opts) { - if (opts == null) { opts = {} }; + if (opts == null) { opts = {}; } var host = opts.host || this.api_config.host, port = opts.port || this.api_config.port; diff --git a/lib/generators/adaptor.js b/lib/generators/adaptor.js index acfbd0e..edd59a3 100644 --- a/lib/generators/adaptor.js +++ b/lib/generators/adaptor.js @@ -53,7 +53,7 @@ var generateTemplateData = function() { basename: String(adaptorName).toLowerCase(), cylonVersion: pkg.version }; -} +}; var generator = function(name) { adaptorName = name; diff --git a/lib/generators/adaptor/test/support/runner.js b/lib/generators/adaptor/test/support/runner.js index 050dcd4..0c256c3 100644 --- a/lib/generators/adaptor/test/support/runner.js +++ b/lib/generators/adaptor/test/support/runner.js @@ -9,7 +9,7 @@ var mocha = new Mocha({ reporter: 'spec', ui: 'bdd'}); function run(cb) { var files = grunt.file.expand(__dirname + '/../specs/**/*.spec.js'); - console.log(files) + console.log(files); files.forEach(function (file) { mocha.addFile(file); }); diff --git a/lib/logger.js b/lib/logger.js index 483e8a7..3dd4f54 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -10,7 +10,7 @@ var getArgs = function(args) { return args.length >= 1 ? [].slice.call(args, 0) : []; -} +}; // The Logger is a global object to facilitate logging stuff to the console (or // other output) easily and consistently. It's available anywhere in Cylon, as @@ -24,7 +24,7 @@ global.Logger = { // // Returns the new logger instance setup: function(logger) { - if (logger == null) { logger = new BasicLogger; } + if (logger == null) { logger = new BasicLogger(); } if (logger === false) { this.logger = new NullLogger(); @@ -32,7 +32,7 @@ global.Logger = { this.logger = logger; } - return this.logger + return this.logger; }, toString: function() { return this.logger.toString(); }, diff --git a/lib/robot.js b/lib/robot.js index c553fce..2ece611 100644 --- a/lib/robot.js +++ b/lib/robot.js @@ -203,7 +203,7 @@ namespace("Cylon", function() { // // Returns nothing Robot.prototype.startConnections = function(callback) { - var starters = {} + var starters = {}; Logger.info("Starting connections..."); @@ -222,7 +222,7 @@ namespace("Cylon", function() { // // Returns nothing Robot.prototype.startDevices = function(callback) { - var starters = {} + var starters = {}; Logger.info("Starting devices..."); diff --git a/lib/utils.js b/lib/utils.js index 7990ff2..b83afc7 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -132,12 +132,10 @@ global.proxyFunctionsToObject = function(methods, target, base, force) { global.proxyTestStubs = function(methods, base) { if (base == null) { base = this; } - for (var i = 0; i < methods.length; i++) { - var method = methods[i]; - + methods.forEach(function(method) { base[method] = function() { return true; }; base.commandList.push(method); - } + }); return base; }; @@ -157,8 +155,8 @@ global.proxyTestStubs = function(methods, base) { // // Returns a function wrapper global.bind = function(fn, me) { - return function() { return fn.apply(me, arguments); } -} + return function() { return fn.apply(me, arguments); }; +}; // Public: Monkey-patches Number to have Rails-like //seconds() function. Warning, // due to the way the Javascript parser works, applying functions on numbers is