Skip to content

Commit

Permalink
bring grunt lint into parity with jshintrc, and fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps committed May 1, 2014
1 parent b2250b0 commit 8a5b698
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 47 deletions.
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ module.exports = function (grunt) {
, strict: true
, white: true
, indent: 2
, undef: true
, unused: true
, eqeqeq: true
},
files: {
src: ['*.js', './**/*.js'],
Expand Down
4 changes: 2 additions & 2 deletions grunt-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports.runMochaTests = function (grunt, appName, testType, deviceType, c
var file = mochaFiles.shift();
if (typeof file !== "undefined") {
var mochaProc = spawn('mocha', args.concat(file), {cwd: __dirname});
mochaProc.on("error", function (err) {
mochaProc.on("error", function () {
grunt.fatal("Unable to spawn mocha process: mocha not installed?");
});
mochaProc.stdout.setEncoding('utf8');
Expand Down Expand Up @@ -376,7 +376,7 @@ var buildAndroidProj = function (grunt, projPath, target, cb) {
var cmd = stdout.split('\r\n')[0].trim();
grunt.log.write("Using " + cmdName + " found at " + cmd + "\n");
var proc = spawn(cmd, [target], {cwd: projPath});
proc.on("error", function (err) {
proc.on("error", function () {
grunt.fatal("Unable to spawn \"" + cmdName + "\"");
});
proc.stdout.setEncoding('utf8');
Expand Down
1 change: 0 additions & 1 deletion lib/devices/android/adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var spawn = require('win-spawn')
, fs = require('fs')
, net = require('net')
, mkdirp = require('mkdirp')
, status = require('../../server/status.js')
, logger = require('../../server/logger.js').get('appium')
, async = require('async')
, ncp = require('ncp')
Expand Down
3 changes: 1 addition & 2 deletions lib/devices/android/android-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ androidController.getContexts = function (cb) {
this.listWebviews(function (err, webviews) {
if (err) return cb(err);
this.contexts = [NATIVE_WIN];
var idx = 0;
_.each(webviews, function (view, idx) {
this.contexts.push(WEBVIEW_BASE + (idx + 1).toString());
}.bind(this));
Expand Down Expand Up @@ -1043,7 +1042,7 @@ androidController.parseTouch = function (gestures, cb) {
// and the position (which may be an offset)
var prevPos = null,
time = 0;
_.each(touchStateObjects, function (state, index) {
_.each(touchStateObjects, function (state) {
if (state.touch === false) {
// if we have no position (this happens with `wait`) we need the previous one
state.touch = prevPos;
Expand Down
4 changes: 2 additions & 2 deletions lib/devices/android/selendroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ Selendroid.prototype.unpackApp = androidController.unpackApp;

Selendroid.prototype.translatePath = function (req) {
var path = req.originalUrl;
if (path.indexOf("contexts") != -1) {
if (path.indexOf("contexts") !== -1) {
logger.info("Temporarily translating 'contexts' to 'window_handles");
path = path.replace("contexts", "window_handles");
} else if (path.indexOf("context") != -1) {
} else if (path.indexOf("context") !== -1) {
logger.info("Temporarily translating 'context' to 'window'");
path = path.replace("context", "window");
}
Expand Down
4 changes: 1 addition & 3 deletions lib/devices/ios/ios-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ var uuid = require('uuid-js')
, escapeSpecialChars = helpers.escapeSpecialChars
, parseWebCookies = helpers.parseWebCookies
, rotateImage = helpers.rotateImage
, warnDeprecated = helpers.logDeprecationWarning
, warnDeprecatedCustom = helpers.logCustomDeprecationWarning
, request = require('request')
, mkdirp = require('mkdirp')
, deviceCommon = require('../common.js')
Expand Down Expand Up @@ -1825,7 +1823,7 @@ iOSController.parseTouch = function (gestures, cb) {
// we need to change the time (which is now an offset)
// and the position (which may be an offset)
var time = 0;
_.each(touchStateObjects, function (state, index) {
_.each(touchStateObjects, function (state) {
if (state.touch[0] === false) {
// if we have no position (this happens with `wait`) we need the previous one
state.touch[0] = prevPos;
Expand Down
1 change: 0 additions & 1 deletion lib/server/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var status = require('./status.js')
, checkMissingParams = responses.checkMissingParams
, notYetImplemented = responses.notYetImplemented
, helpers = require('../helpers.js')
, logDeprecationWarning = helpers.logDeprecationWarning
, logCustomDeprecationWarning = helpers.logCustomDeprecationWarning
, _ = require('underscore');

Expand Down
1 change: 0 additions & 1 deletion lib/server/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var helpers = require('../helpers.js')
, status = require('./status.js')
, async = require('async')
, through = require('through')
, fs = require('fs')
, io = require('socket.io')
, bytes = require('bytes');

Expand Down
1 change: 0 additions & 1 deletion test/functional/common/prelaunch-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var env = require('../../helpers/env')
, androidApp = path.resolve(__dirname, "..", "..", "..", "sample-code",
"apps", "ApiDemos", "bin", "ApiDemos-debug.apk")
, spawn = require('child_process').spawn
, exec = require('child_process').exec
, crazyPort = 4799
, _ = require('underscore');

Expand Down
5 changes: 2 additions & 3 deletions test/functional/ios/testapp/clear-specs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"use strict";

var env = require('../../../helpers/env'),
setup = require("../../common/setup-base"),
desired = require('./desired');
var setup = require("../../common/setup-base")
, desired = require('./desired');

describe('testapp - clear -', function () {
var driver;
Expand Down
3 changes: 1 addition & 2 deletions test/functional/ios/testapp/context-specs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"use strict";

var setup = require("../../common/setup-base"),
desired = require('./desired'),
unorm = require('unorm');
desired = require('./desired');

describe('testapp - context methods', function () {
var driver;
Expand Down
17 changes: 2 additions & 15 deletions test/unit/common-device-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

var common = require('../../lib/devices/common.js')
, checkValidLocStrat = common.checkValidLocStrat
, clearWarnings = require('../../lib/helpers.js').clearWarnings
, loggerjs = require('../../lib/server/logger')
, logger = loggerjs.get('appium');
, _ = require('underscore');


var _ = require('underscore')
, sinon = require('sinon');

describe('devices/common.js', function () {
var nullCb = function () {};
Expand All @@ -29,16 +26,6 @@ describe('devices/common.js', function () {
assertLocatorValidity(name, loc, webIncluded, false);
};

var warningTemplate = _.template(
"[DEPRECATED] The <%= deprecated %> locator strategy has been " +
"deprecated and will be removed. Please use the " +
"<%= replacement %> locator strategy instead."
);

var expectedWarning = function (selector, replacement) {
return warningTemplate({deprecated: selector, replacement: replacement});
};

describe('#checkValidLocStrat', function () {
var validStrategies = [
'xpath',
Expand Down
5 changes: 3 additions & 2 deletions test/unit/device-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
var Device = require('../../lib/devices/device.js')
, capConversion = require('../../lib/server/capabilities.js').capabilityConversions
, chai = require('chai')
, should = chai.should()
, _ = require('underscore');

chai.should();

var Test = function () {
this.init();
};
Expand All @@ -25,4 +26,4 @@ describe("device.js", function () {
});
});
});
});
});
5 changes: 3 additions & 2 deletions test/unit/helper-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
var helpers = require('../../lib/helpers.js')
, logger = require('../../lib/server/logger.js').get('appium')
, chai = require('chai')
, should = chai.should()
, sinon = require('sinon');

chai.should();

describe("Helpers", function () {
describe("#formatDeprecationWarning", function () {
describe("with a function", function () {
Expand Down Expand Up @@ -88,4 +89,4 @@ describe("Helpers", function () {
logger.warn.called.should.equal(false);
});
});
});
});
13 changes: 3 additions & 10 deletions test/unit/ios-controller-specs.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
"use strict";

var chai = require('chai')
, should = chai.should()
, sinon = require('sinon')
, SandboxedModule = require('sandboxed-module')
, fs = require('fs')
, path = require('path')
, controller_path = '../../lib/devices/ios/ios-controller.js'
, controller = require(controller_path)
, child_process = require('child_process')
, createGetElementCommand = controller.createGetElementCommand
, getSelectorForStrategy = controller.getSelectorForStrategy
, errors = require('../../lib/server/errors.js')
, NotYetImplementedError = errors.NotYetImplementedError
, status = require('../../lib/server/status.js');
, getSelectorForStrategy = controller.getSelectorForStrategy;

chai.should();

describe('ios-controller', function () {

Expand Down

0 comments on commit 8a5b698

Please sign in to comment.