Skip to content

Commit d1fa53c

Browse files
committed
Cleanup lint warnings from recent testing changes
Also, relaxed a rule for dot notation (and unrelaxed it in src).
1 parent b61eacd commit d1fa53c

File tree

9 files changed

+80
-46
lines changed

9 files changed

+80
-46
lines changed

.jshintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"noempty": true,
1414
"nonstandard": true,
1515
"onecase": true,
16+
"sub": true,
1617
"regexdash": true,
1718
"trailing": true,
1819
"undef": true,

Gruntfile.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ module.exports = function(grunt) {
2929
grunt.config.set('compress', require('./grunt/config/compress'));
3030

3131
Object.keys(grunt.file.readJSON('package.json').devDependencies)
32-
.filter(function(npmTaskName){ return npmTaskName.indexOf('grunt-') === 0;})
33-
.filter(function(npmTaskName){ return npmTaskName != 'grunt-cli' })
34-
.forEach(function(npmTaskName){
35-
grunt.loadNpmTasks(npmTaskName);
36-
})
37-
;
32+
.filter(function(npmTaskName) { return npmTaskName.indexOf('grunt-') === 0; })
33+
.filter(function(npmTaskName) { return npmTaskName != 'grunt-cli'; })
34+
.forEach(function(npmTaskName) { grunt.loadNpmTasks(npmTaskName); });
3835

3936
// Alias 'jshint' to 'lint' to better match the workflow we know
4037
grunt.registerTask('lint', ['jshint']);

grunt/config/server.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
module.exports = function(grunt){
1+
'use strict';
2+
3+
module.exports = function(grunt) {
24

35
function testResultLoggerMiddleware(req, res, next) {
4-
if (!(req.method == 'POST' && req._parsedUrl.pathname.indexOf('/reportTestResults') === 0)) return next();
6+
if (!(req.method == 'POST' && req._parsedUrl.pathname.indexOf('/reportTestResults') === 0)) {
7+
return next();
8+
}
59
var logType = 'writeln';
610
var message = req.body;
711

812
if (req.body.type && req.body.message){
9-
if (req.body.type == 'error') logType = 'error';
10-
else if (req.body.message.indexOf('ok') === 0) logType = 'ok';
11-
else if (req.body.message.indexOf('not ok') === 0) logType = 'error';
13+
if (req.body.type == 'error') {
14+
logType = 'error';
15+
} else if (req.body.message.indexOf('ok') === 0) {
16+
logType = 'ok';
17+
} else if (req.body.message.indexOf('not ok') === 0) {
18+
logType = 'error';
19+
}
1220
message = req.body.message;
1321
}
14-
if (typeof message != 'string') message = JSON.stringify(message, null, 2);
22+
if (typeof message != 'string') {
23+
message = JSON.stringify(message, null, 2);
24+
}
1525
grunt.log[logType]('[%s][%s]', req.headers['user-agent'], Date.now(), message);
1626
res.write('<!doctype html><meta charset=utf-8>');
1727
res.end('Got it, thanks!');
@@ -24,20 +34,20 @@ module.exports = function(grunt){
2434
hostname: '*',
2535
port: 9999,
2636
middleware: function(connect, options) {
27-
28-
connect.logger.token('user-agent', function(req, res){ return req.headers['user-agent']; });
29-
connect.logger.token('timestamp', function(req, res){ return Date.now(); });
30-
37+
38+
connect.logger.token('user-agent', function(req, res) { return req.headers['user-agent']; });
39+
connect.logger.token('timestamp', function(req, res) { return Date.now(); });
40+
3141
return [
3242
connect.json(),
3343
testResultLoggerMiddleware,
34-
44+
3545
connect.logger({format:'[:user-agent][:timestamp] :method :url', stream:grunt.verbose}),
3646
connect.static(options.base),
3747
connect.directory(options.base)
3848
];
3949
},
4050
}
4151
}
42-
}
43-
}
52+
};
53+
};

grunt/config/webdriver-jasmine.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var grunt = require('grunt');
24

35

@@ -14,9 +16,11 @@ exports.local = {
1416
onError: function(error){
1517
grunt.fatal(error);
1618
}
17-
}
19+
};
1820

19-
if (grunt.option('debug')) exports.local.url += '?debug=' + grunt.option('debug');
21+
if (grunt.option('debug')) {
22+
exports.local.url += '?debug=' + grunt.option('debug');
23+
}
2024

2125

2226
exports.saucelabs = {
@@ -43,7 +47,7 @@ exports.saucelabs = {
4347
},
4448
onComplete: exports.local.onComplete,
4549
onError: exports.local.onError
46-
}
50+
};
4751

4852
/* https://saucelabs.com/docs/platforms */
4953
exports.saucelabs_ios =
@@ -74,7 +78,7 @@ exports.saucelabs_ie10 = sauceItUp({ browserName: 'internet explorer', version:
7478
exports.saucelabs_ie11 = sauceItUp({ browserName: 'internet explorer', version: 11, platform:'Windows 8.1' });
7579

7680

77-
function sauceItUp(desiredCapabilities){
81+
function sauceItUp(desiredCapabilities) {
7882
desiredCapabilities["build"] = exports.saucelabs.desiredCapabilities["build"];
7983
desiredCapabilities["tunnel-identifier"] = exports.saucelabs.desiredCapabilities["tunnel-identifier"];
8084
return {

grunt/tasks/populist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var grunt = require('grunt');
4-
var fs = require('fs')
4+
var fs = require('fs');
55

66
module.exports = function() {
77
var config = this.data;

grunt/tasks/sauce-tunnel.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1+
'use strict';
2+
13
var grunt = require('grunt');
24
var SauceTunnel = require('sauce-tunnel');
35

4-
module.exports = function(){
6+
module.exports = function() {
57
var task = this;
6-
var config = task.data;
78
var shouldStayAliveForever = task.flags.keepalive;
89

910
var SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY;
10-
if (!SAUCE_ACCESS_KEY) grunt.fatal('Requires the environment variable SAUCE_ACCESS_KEY to be set');
11+
if (!SAUCE_ACCESS_KEY) {
12+
grunt.fatal('Requires the environment variable SAUCE_ACCESS_KEY to be set');
13+
}
1114

1215
var SAUCE_USERNAME = process.env.SAUCE_USERNAME;
13-
if (!SAUCE_USERNAME) grunt.fatal('Requires the environment variable SAUCE_USERNAME to be set');
16+
if (!SAUCE_USERNAME) {
17+
grunt.fatal('Requires the environment variable SAUCE_USERNAME to be set');
18+
}
1419

1520
var IDENTIFIER = process.env.TRAVIS_JOB_NUMBER || 'my awesome tunnel';
1621

@@ -28,7 +33,7 @@ module.exports = function(){
2833
stunnel.on('verbose:writeln', grunt.verbose.writeln.bind(grunt.verbose));
2934

3035
stunnel.openTunnel(function(isOpen){
31-
if (shouldStayAliveForever && isOpen){
36+
if (shouldStayAliveForever && isOpen) {
3237
grunt.verbose.writeln('Keeping the sauce-tunnel open forever because you used the keepalive flag `' + task.nameArgs + '`');
3338
return;
3439
}

grunt/tasks/webdriver-jasmine.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/* jshint evil: true */
2+
3+
'use strict';
4+
15
var grunt = require("grunt");
26
var wd = require('wd');
37

@@ -6,10 +10,14 @@ module.exports = function(){
610
var taskSucceeded = this.async();
711

812
var desiredCapabilities = {};
9-
if (config.desiredCapabilities) Object.keys(config.desiredCapabilities).forEach(function(key){
10-
if (config.desiredCapabilities[key] === undefined) return;
11-
desiredCapabilities[key] = config.desiredCapabilities[key];
12-
});
13+
if (config.desiredCapabilities) {
14+
Object.keys(config.desiredCapabilities).forEach(function(key) {
15+
if (config.desiredCapabilities[key] === undefined) {
16+
return;
17+
}
18+
desiredCapabilities[key] = config.desiredCapabilities[key];
19+
});
20+
}
1321
grunt.verbose.writeln("desiredCapabilities", JSON.stringify(desiredCapabilities));
1422

1523
var browser = wd.promiseChainRemote(config.webdriver.remote);
@@ -37,26 +45,31 @@ module.exports = function(){
3745
return browser
3846
.eval('document.documentElement.innerText || document.documentElement.textContent')
3947
.then(grunt.verbose.writeln.bind(grunt.verbose))
40-
.then(function(){throw error})
48+
.then(function(){ throw error; })
4149
;
4250
})
4351
.finally(function(){
44-
if (grunt.option('webdriver-keep-open')) return;
52+
if (grunt.option('webdriver-keep-open')) {
53+
return;
54+
}
4555
grunt.verbose.writeln('Closing the browser window. To keep it open, pass the --webdriver-keep-open flag to grunt.');
4656
return browser.quit();
4757
})
4858
.done(
49-
function(){
50-
if (config.onComplete) config.onComplete(results);
59+
function() {
60+
if (config.onComplete) {
61+
config.onComplete(results);
62+
}
5163
taskSucceeded(true);
5264
},
53-
function(error){
54-
if (config.onError) config.onError(error);
65+
function(error) {
66+
if (config.onError) {
67+
config.onError(error);
68+
}
5569
taskSucceeded(false);
5670
}
57-
)
58-
;
59-
}
71+
);
72+
};
6073

6174
function getJSReport(browser){
6275
return browser
@@ -66,6 +79,5 @@ function getJSReport(browser){
6679
})
6780
.waitForCondition("typeof window.jasmine.getJSReport != 'undefined'", 10e3)
6881
.waitForCondition("window.postDataToURL.running <= 0", 30e3)
69-
.eval("jasmine.getJSReport().passed")
70-
;
82+
.eval("jasmine.getJSReport().passed");
7183
}

grunt/tasks/webdriver-phantomjs.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var grunt = require('grunt');
24

35
module.exports = function(){
@@ -21,7 +23,9 @@ module.exports = function(){
2123
});
2224
child.on('exit', function(code) {
2325
grunt.verbose.writeln('phantomjs END');
24-
if (code) grunt.fatal('phantomjs FAIL');
26+
if (code) {
27+
grunt.fatal('phantomjs FAIL');
28+
}
2529
});
2630

2731
function verboseWrite(chunk) {
@@ -34,4 +38,4 @@ module.exports = function(){
3438
}
3539
child.stdout.on('data', verboseWrite);
3640
child.stderr.on('data', verboseWrite);
37-
}
41+
};

src/.jshintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"nonstandard": true,
1616
"onecase": true,
1717
"regexdash": true,
18+
"sub": false,
1819
"trailing": true,
1920
"undef": true,
2021
"unused": "vars",

0 commit comments

Comments
 (0)