@samitouri / QOS-React-2 / commits / d1fa53ca03

Cleanup lint warnings from recent testing changes

Also, relaxed a rule for dot notation (and unrelaxed it in src).

Paul O’Shannessy committed Nov 14, 2013 at 11:24 UTC d1fa53ca03fae2e3c6ce8f211de8117a0c04f440
9 files changed +80 -46
.jshintrc
+1
@@ -13,6 +13,7 @@
13 "noempty": true,
14 "nonstandard": true,
15 "onecase": true,
16 + "sub": true,
17 "regexdash": true,
18 "trailing": true,
19 "undef": true,
Gruntfile.js
+3 -6
@@ -29,12 +29,9 @@ module.exports = function(grunt) {
29 grunt.config.set('compress', require('./grunt/config/compress'));
30
31 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); });
35
36 // Alias 'jshint' to 'lint' to better match the workflow we know
37 grunt.registerTask('lint', ['jshint']);
grunt/config/server.js
+23 -13
@@ -1,17 +1,27 @@
1 -module.exports = function(grunt){
1 +'use strict';
2 +
3 +module.exports = function(grunt) {
4
5 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 + }
9 var logType = 'writeln';
10 var message = req.body;
11
12 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 + }
20 message = req.body.message;
21 }
14 - if (typeof message != 'string') message = JSON.stringify(message, null, 2);
22 + if (typeof message != 'string') {
23 + message = JSON.stringify(message, null, 2);
24 + }
25 grunt.log[logType]('[%s][%s]', req.headers['user-agent'], Date.now(), message);
26 res.write('<!doctype html><meta charset=utf-8>');
27 res.end('Got it, thanks!');
@@ -24,14 +34,14 @@ module.exports = function(grunt){
34 hostname: '*',
35 port: 9999,
36 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 +
41 return [
42 connect.json(),
43 testResultLoggerMiddleware,
34 -
44 +
45 connect.logger({format:'[:user-agent][:timestamp] :method :url', stream:grunt.verbose}),
46 connect.static(options.base),
47 connect.directory(options.base)
@@ -39,5 +49,5 @@ module.exports = function(grunt){
49 },
50 }
51 }
42 - }
43 -}
52 + };
53 +};
grunt/config/webdriver-jasmine.js
+8 -4
@@ -1,3 +1,5 @@
1 +'use strict';
2 +
3 var grunt = require('grunt');
4
5
@@ -14,9 +16,11 @@ exports.local = {
16 onError: function(error){
17 grunt.fatal(error);
18 }
17 -}
19 +};
20
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 +}
24
25
26 exports.saucelabs = {
@@ -43,7 +47,7 @@ exports.saucelabs = {
47 },
48 onComplete: exports.local.onComplete,
49 onError: exports.local.onError
46 -}
50 +};
51
52 /* https://saucelabs.com/docs/platforms */
53 exports.saucelabs_ios =
@@ -74,7 +78,7 @@ exports.saucelabs_ie10 = sauceItUp({ browserName: 'internet explorer', version:
78 exports.saucelabs_ie11 = sauceItUp({ browserName: 'internet explorer', version: 11, platform:'Windows 8.1' });
79
80
77 -function sauceItUp(desiredCapabilities){
81 +function sauceItUp(desiredCapabilities) {
82 desiredCapabilities["build"] = exports.saucelabs.desiredCapabilities["build"];
83 desiredCapabilities["tunnel-identifier"] = exports.saucelabs.desiredCapabilities["tunnel-identifier"];
84 return {
grunt/tasks/populist.js
+1 -1
@@ -1,7 +1,7 @@
1 'use strict';
2
3 var grunt = require('grunt');
4 -var fs = require('fs')
4 +var fs = require('fs');
5
6 module.exports = function() {
7 var config = this.data;
grunt/tasks/sauce-tunnel.js
+10 -5
@@ -1,16 +1,21 @@
1 +'use strict';
2 +
3 var grunt = require('grunt');
4 var SauceTunnel = require('sauce-tunnel');
5
4 -module.exports = function(){
6 +module.exports = function() {
7 var task = this;
6 - var config = task.data;
8 var shouldStayAliveForever = task.flags.keepalive;
9
10 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 + }
14
15 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 + }
19
20 var IDENTIFIER = process.env.TRAVIS_JOB_NUMBER || 'my awesome tunnel';
21
@@ -28,7 +33,7 @@ module.exports = function(){
33 stunnel.on('verbose:writeln', grunt.verbose.writeln.bind(grunt.verbose));
34
35 stunnel.openTunnel(function(isOpen){
31 - if (shouldStayAliveForever && isOpen){
36 + if (shouldStayAliveForever && isOpen) {
37 grunt.verbose.writeln('Keeping the sauce-tunnel open forever because you used the keepalive flag `' + task.nameArgs + '`');
38 return;
39 }
grunt/tasks/webdriver-jasmine.js
+27 -15
@@ -1,3 +1,7 @@
1 +/* jshint evil: true */
2 +
3 +'use strict';
4 +
5 var grunt = require("grunt");
6 var wd = require('wd');
7
@@ -6,10 +10,14 @@ module.exports = function(){
10 var taskSucceeded = this.async();
11
12 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 + }
21 grunt.verbose.writeln("desiredCapabilities", JSON.stringify(desiredCapabilities));
22
23 var browser = wd.promiseChainRemote(config.webdriver.remote);
@@ -37,26 +45,31 @@ module.exports = function(){
45 return browser
46 .eval('document.documentElement.innerText || document.documentElement.textContent')
47 .then(grunt.verbose.writeln.bind(grunt.verbose))
40 - .then(function(){throw error})
48 + .then(function(){ throw error; })
49 ;
50 })
51 .finally(function(){
44 - if (grunt.option('webdriver-keep-open')) return;
52 + if (grunt.option('webdriver-keep-open')) {
53 + return;
54 + }
55 grunt.verbose.writeln('Closing the browser window. To keep it open, pass the --webdriver-keep-open flag to grunt.');
56 return browser.quit();
57 })
58 .done(
49 - function(){
50 - if (config.onComplete) config.onComplete(results);
59 + function() {
60 + if (config.onComplete) {
61 + config.onComplete(results);
62 + }
63 taskSucceeded(true);
64 },
53 - function(error){
54 - if (config.onError) config.onError(error);
65 + function(error) {
66 + if (config.onError) {
67 + config.onError(error);
68 + }
69 taskSucceeded(false);
70 }
57 - )
58 - ;
59 -}
71 + );
72 +};
73
74 function getJSReport(browser){
75 return browser
@@ -66,6 +79,5 @@ function getJSReport(browser){
79 })
80 .waitForCondition("typeof window.jasmine.getJSReport != 'undefined'", 10e3)
81 .waitForCondition("window.postDataToURL.running <= 0", 30e3)
69 - .eval("jasmine.getJSReport().passed")
70 - ;
82 + .eval("jasmine.getJSReport().passed");
83 }
grunt/tasks/webdriver-phantomjs.js
+6 -2
@@ -1,3 +1,5 @@
1 +'use strict';
2 +
3 var grunt = require('grunt');
4
5 module.exports = function(){
@@ -21,7 +23,9 @@ module.exports = function(){
23 });
24 child.on('exit', function(code) {
25 grunt.verbose.writeln('phantomjs END');
24 - if (code) grunt.fatal('phantomjs FAIL');
26 + if (code) {
27 + grunt.fatal('phantomjs FAIL');
28 + }
29 });
30
31 function verboseWrite(chunk) {
@@ -34,4 +38,4 @@ module.exports = function(){
38 }
39 child.stdout.on('data', verboseWrite);
40 child.stderr.on('data', verboseWrite);
37 -}
41 +};
src/.jshintrc
+1
@@ -15,6 +15,7 @@
15 "nonstandard": true,
16 "onecase": true,
17 "regexdash": true,
18 + "sub": false,
19 "trailing": true,
20 "undef": true,
21 "unused": "vars",