Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 35dcea0

Browse files
committed
style(jshint): update all style to work with new jshint config
1 parent 47d7636 commit 35dcea0

21 files changed

+71
-73
lines changed

Diff for: lib/cli.js

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ process.argv.slice(2).forEach(function(arg) {
3030

3131
var util = require('util');
3232
var path = require('path');
33-
var child = require('child_process');
3433
var fs = require('fs');
3534
var optimist = require('optimist').
3635
usage('Usage: protractor [options] [configFile]\n' +

Diff for: lib/clientsidescripts.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* inside scripts.
1010
*/
1111

12-
/* jshint browser: true */
12+
// jshint browser: true
13+
// jshint shadow: true
1314
/* global angular */
14-
/* jshint shadow: true */
1515
var clientSideScripts = exports;
1616

1717
/**
@@ -139,7 +139,6 @@ clientSideScripts.findBindings = function(binding, using) {
139139
for (var i = 0; i < repeatElems.length; ++i) {
140140
if (repeatElems[i].getAttribute(attr).indexOf(repeater) != -1) {
141141
var elem = repeatElems[i];
142-
var row = [];
143142
while (elem.nodeType != 8 ||
144143
elem.nodeValue.indexOf(repeater) == -1) {
145144
rows.push(elem);
@@ -213,7 +212,7 @@ clientSideScripts.findRepeaterElement = function(repeater, index, binding, using
213212
}
214213
if (multiRow) {
215214
for (var i = 0; i < multiRow.length; ++i) {
216-
rowElem = multiRow[i];
215+
var rowElem = multiRow[i];
217216
if (rowElem.className.indexOf('ng-binding') != -1) {
218217
bindings.push(rowElem);
219218
}
@@ -372,7 +371,7 @@ clientSideScripts.findByButtonText = function(searchText, using) {
372371
for (var i = 0; i < elements.length; ++i) {
373372
var element = elements[i];
374373
var elementText;
375-
if (element.tagName.toLowerCase() == "button") {
374+
if (element.tagName.toLowerCase() == 'button') {
376375
elementText = element.innerText || element.textContent;
377376
} else {
378377
elementText = element.value;
@@ -400,7 +399,7 @@ clientSideScripts.findByPartialButtonText = function(searchText, using) {
400399
for (var i = 0; i < elements.length; ++i) {
401400
var element = elements[i];
402401
var elementText;
403-
if (element.tagName.toLowerCase() == "button") {
402+
if (element.tagName.toLowerCase() == 'button') {
404403
elementText = element.innerText || element.textContent;
405404
} else {
406405
elementText = element.value;
@@ -524,7 +523,7 @@ clientSideScripts.testForAngular = function(attempts, asyncCallback) {
524523
callback([false, 'retries looking for angular exceeded']);
525524
}
526525
} else {
527-
window.setTimeout(function() {check(n - 1)}, 1000);
526+
window.setTimeout(function() {check(n - 1);}, 1000);
528527
}
529528
} catch (e) {
530529
callback([false, e]);

Diff for: lib/configParser.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ try {
1818
// Intentionally blank - ignore if LiveScript is not available.
1919
}
2020

21-
module.exports = ConfigParser = function() {
21+
var ConfigParser = function() {
2222
// Default configuration.
2323
this.config_= {
2424
specs: [],
@@ -123,7 +123,7 @@ ConfigParser.getSpecs = function(config) {
123123
});
124124

125125
return specs;
126-
}
126+
};
127127

128128
/**
129129
* Add the options in the parameter config to this runner instance.
@@ -190,3 +190,5 @@ ConfigParser.prototype.addConfig = function(argv) {
190190
ConfigParser.prototype.getConfig = function() {
191191
return this.config_;
192192
};
193+
194+
module.exports = ConfigParser;

Diff for: lib/driverProviders/chrome.dp.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ ChromeDriverProvider.prototype.getDriver = function() {
7171
};
7272

7373
// new instance w/ each include
74-
module.exports = (function(config) {
74+
module.exports = function(config) {
7575
return new ChromeDriverProvider(config);
76-
});
76+
};

Diff for: lib/driverProviders/hosted.dp.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ HostedDriverProvider.prototype.setupEnv = function() {
3333
* @return {q.promise} A promise which will resolve when the environment
3434
* is down.
3535
*/
36-
HostedDriverProvider.prototype.teardownEnv = function(runner) {
36+
HostedDriverProvider.prototype.teardownEnv = function() {
3737
var deferred = q.defer();
3838
this.driver_.quit().then(function() {
3939
deferred.resolve();
@@ -57,6 +57,6 @@ HostedDriverProvider.prototype.getDriver = function() {
5757
};
5858

5959
// new instance w/ each include
60-
module.exports = (function(config) {
60+
module.exports = function(config) {
6161
return new HostedDriverProvider(config);
62-
});
62+
};

Diff for: lib/driverProviders/local.dp.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,6 @@ LocalDriverProvider.prototype.getDriver = function() {
124124
};
125125

126126
// new instance w/ each include
127-
module.exports = (function(config) {
127+
module.exports = function(config) {
128128
return new LocalDriverProvider(config);
129-
});
129+
};

Diff for: lib/driverProviders/sauce.dp.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ SauceDriverProvider.prototype.getDriver = function() {
9393
};
9494

9595
// new instance w/ each include
96-
module.exports = (function(config) {
96+
module.exports = function(config) {
9797
return new SauceDriverProvider(config);
98-
});
98+
};

Diff for: lib/launcher.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44
*/
55
'use strict';
66

7-
var util = require('util'),
8-
path = require('path'),
9-
child = require('child_process'),
7+
var child = require('child_process'),
108
ConfigParser = require('./configParser');
119

12-
var launcherPrefix = '[launcher] '
10+
var launcherPrefix = '[launcher] ';
1311

1412
var log_ = function(stuff) {
1513
console.log(launcherPrefix + stuff);
16-
}
14+
};
1715

1816
var noLineLog_ = function(stuff) {
1917
process.stdout.write(launcherPrefix + stuff);
20-
}
18+
};
2119

2220
var reportHeader_ = function(driverInstance) {
2321
var capability = driverInstance.capability;
@@ -36,7 +34,6 @@ var reportHeader_ = function(driverInstance) {
3634
outputHeader += ')' + eol;
3735
outputHeader += '------------------------------------' + eol;
3836

39-
4037
console.log(outputHeader);
4138
};
4239

@@ -146,7 +143,7 @@ var init = function(configFile, additionalConfig) {
146143
driverInstances.forEach(function(driverInstance) {
147144

148145
driverInstance.process = child.fork(
149-
__dirname + "/runFromLauncher.js",
146+
__dirname + '/runFromLauncher.js',
150147
process.argv.slice(2),
151148
{silent: true, cwd: process.cwd()});
152149

@@ -182,7 +179,7 @@ var init = function(configFile, additionalConfig) {
182179
});
183180

184181
// exit handlers
185-
driverInstance.process.on('exit', function(code, signal) {
182+
driverInstance.process.on('exit', function(code) {
186183
if (code) {
187184
log_('Runner Process Exited With Error Code: ' + code);
188185
launcherExitCode = 1;

Diff for: lib/protractor.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
var url = require('url');
2-
var util = require('util');
3-
var path = require('path');
42
var webdriver = require('selenium-webdriver');
53

64
var clientSideScripts = require('./clientsidescripts.js');
@@ -607,6 +605,8 @@ Protractor.prototype.waitForAngular = function() {
607605
* @return {webdriver.WebElement} the wrapped web element.
608606
*/
609607
Protractor.prototype.wrapWebElement = function(element) {
608+
// We want to be able to used varArgs in function signatures for clarity.
609+
// jshint unused: false
610610
var thisPtor = this;
611611
// Before any of the WebElement functions, Protractor will wait to make sure
612612
// Angular is synced up.
@@ -642,7 +642,7 @@ Protractor.prototype.wrapWebElement = function(element) {
642642
* @return {!webdriver.WebElement}
643643
*/
644644
element.$ = function(selector) {
645-
var locator = protractor.By.css(selector);
645+
var locator = thisPtor.By.css(selector);
646646
return this.findElement(locator);
647647
};
648648

@@ -689,7 +689,7 @@ Protractor.prototype.wrapWebElement = function(element) {
689689
* array of the located {@link webdriver.WebElement}s.
690690
*/
691691
element.$$ = function(selector) {
692-
var locator = protractor.By.css(selector);
692+
var locator = thisPtor.By.css(selector);
693693
return this.findElements(locator);
694694
};
695695

@@ -882,7 +882,7 @@ Protractor.prototype.get = function(destination, opt_timeout) {
882882
if (!hasAngular) {
883883
var message = arr[1];
884884
throw new Error('Angular could not be found on the page ' +
885-
destination + " : " + message);
885+
destination + ' : ' + message);
886886
}
887887
};
888888

@@ -896,17 +896,17 @@ Protractor.prototype.get = function(destination, opt_timeout) {
896896
// At this point, Angular will pause for us, until angular.resumeBootstrap
897897
// is called.
898898
for (var i = 0; i < this.moduleScripts_.length; ++i) {
899-
name = this.moduleNames_[i];
899+
var name = this.moduleNames_[i];
900900
this.driver.executeScript(this.moduleScripts_[i]).
901901
then(null, function(err) {
902902
throw 'Error wile running module script ' + name +
903903
': ' + err.message;
904904
});
905905
}
906906

907-
return this.driver.executeScript(function() {
908-
angular.resumeBootstrap(arguments[0]);
909-
}, this.moduleNames_);
907+
return this.driver.executeScript(
908+
'angular.resumeBootstrap(arguments[0]);',
909+
this.moduleNames_);
910910
};
911911

912912
/**
@@ -928,7 +928,7 @@ Protractor.prototype.refresh = function(opt_timeout) {
928928
}
929929

930930
return self.driver.executeScript('return window.location.href').then(function(href) {
931-
return self.get(href, opt_timeout);
931+
return self.get(href, timeout);
932932
});
933933
};
934934

@@ -940,7 +940,7 @@ Protractor.prototype.navigate = function() {
940940
var nav = this.driver.navigate();
941941
mixin(nav, this, 'refresh');
942942
return nav;
943-
}
943+
};
944944

945945
/**
946946
* Browse to another page using in-page navigation.
@@ -987,6 +987,7 @@ Protractor.prototype.getLocationAbsUrl = function() {
987987
* debugger.
988988
*/
989989
Protractor.prototype.debugger = function() {
990+
// jshint debug: true
990991
var clientSideScriptsList = [];
991992
for (var script in clientSideScripts) {
992993
clientSideScriptsList.push(
@@ -1051,7 +1052,7 @@ Protractor.prototype.pause = function() {
10511052
if (descriptions[i].stack.length) {
10521053
asString += '\n |---' + descriptions[i].stack.join('\n |---');
10531054
}
1054-
if (!(i == descriptions.length - 1)) {
1055+
if (i != (descriptions.length - 1)) {
10551056
asString += '\n';
10561057
}
10571058
}
@@ -1069,7 +1070,7 @@ Protractor.prototype.pause = function() {
10691070
fork(__dirname + '/wddebugger.js', ['localhost:5858']);
10701071
process.on('exit', function() {
10711072
nodedebug.kill('SIGTERM');
1072-
})
1073+
});
10731074
});
10741075
flow.timeout(1000, 'waiting for debugger to attach');
10751076
};

Diff for: lib/runFromLauncher.js

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
var ConfigParser = require('./configParser');
77
var Runner = require('./runner');
88

9-
var config, argv;
10-
119
process.on('message', function(m) {
1210
switch (m.command) {
1311
case 'run':

Diff for: lib/runner.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ var protractor = require('./protractor'),
33
ConfigParser = require('./configParser'),
44
path = require('path'),
55
util = require('util'),
6-
fs = require('fs'),
76
q = require('q'),
87
EventEmitter = require('events').EventEmitter;
98

@@ -63,6 +62,7 @@ Runner.prototype.runJasmine_ = function(specs, done) {
6362
self = this;
6463

6564
require('../jasminewd');
65+
/* global jasmine */
6666

6767
var RunnerReporter = function(emitter) {
6868
this.emitter = emitter;
@@ -215,13 +215,13 @@ Runner.prototype.runCucumber_ = function(specs, done) {
215215
execOptions.push(self.config_.cucumberOpts.format);
216216
}
217217
}
218-
cucumber = Cucumber.Cli(execOptions);
218+
global.cucumber = Cucumber.Cli(execOptions);
219219

220220
webdriver.promise.controlFlow().execute(function() {
221221
self.runTestPreparers_();
222222
}, 'run test preparers').then(function() {
223223

224-
cucumber.run(function(succeeded) {
224+
global.cucumber.run(function(succeeded) {
225225
if (self.config_.onComplete) {
226226
self.config_.onComplete();
227227
}

Diff for: lib/wddebugger.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ var repl = require('repl');
88
* at a time.
99
*/
1010

11+
// Leave in err, res function parameters.
12+
// jshint unused: false
1113
var baseDebugger = require('_debugger');
1214

1315
var client = new baseDebugger.Client();
@@ -23,7 +25,7 @@ var resume = function() {
2325
resumeReplCallback();
2426
}
2527
resumeReplCallback = null;
26-
}
28+
};
2729

2830

2931
var debugStepperEval = function(cmd, context, filename, callback) {
@@ -33,7 +35,7 @@ var debugStepperEval = function(cmd, context, filename, callback) {
3335
// named 'c', 's', etc to the REPL context. They have getters which
3436
// perform the desired function, and the callback is stored for later use.
3537
// Think about whether this is a better pattern.
36-
var cmd = cmd.slice(1, cmd.length - 2);
38+
cmd = cmd.slice(1, cmd.length - 2);
3739
switch (cmd) {
3840
case 'c':
3941
resumeReplCallback = callback;
@@ -80,7 +82,7 @@ var debugStepperEval = function(cmd, context, filename, callback) {
8082
callback(null, undefined);
8183
break;
8284
}
83-
}
85+
};
8486

8587
var replOpts = {
8688
prompt: 'wd-debug> ',

0 commit comments

Comments
 (0)