Cleanup lint warnings from recent testing changes

Also, relaxed a rule for dot notation (and unrelaxed it in src).
This commit is contained in:
Paul O’Shannessy 2013-11-14 11:24:06 -08:00
parent b61eacd3c5
commit d1fa53ca03
9 changed files with 80 additions and 46 deletions

View File

@ -13,6 +13,7 @@
"noempty": true,
"nonstandard": true,
"onecase": true,
"sub": true,
"regexdash": true,
"trailing": true,
"undef": true,

View File

@ -29,12 +29,9 @@ module.exports = function(grunt) {
grunt.config.set('compress', require('./grunt/config/compress'));
Object.keys(grunt.file.readJSON('package.json').devDependencies)
.filter(function(npmTaskName){ return npmTaskName.indexOf('grunt-') === 0;})
.filter(function(npmTaskName){ return npmTaskName != 'grunt-cli' })
.forEach(function(npmTaskName){
grunt.loadNpmTasks(npmTaskName);
})
;
.filter(function(npmTaskName) { return npmTaskName.indexOf('grunt-') === 0; })
.filter(function(npmTaskName) { return npmTaskName != 'grunt-cli'; })
.forEach(function(npmTaskName) { grunt.loadNpmTasks(npmTaskName); });
// Alias 'jshint' to 'lint' to better match the workflow we know
grunt.registerTask('lint', ['jshint']);

View File

@ -1,17 +1,27 @@
module.exports = function(grunt){
'use strict';
module.exports = function(grunt) {
function testResultLoggerMiddleware(req, res, next) {
if (!(req.method == 'POST' && req._parsedUrl.pathname.indexOf('/reportTestResults') === 0)) return next();
if (!(req.method == 'POST' && req._parsedUrl.pathname.indexOf('/reportTestResults') === 0)) {
return next();
}
var logType = 'writeln';
var message = req.body;
if (req.body.type && req.body.message){
if (req.body.type == 'error') logType = 'error';
else if (req.body.message.indexOf('ok') === 0) logType = 'ok';
else if (req.body.message.indexOf('not ok') === 0) logType = 'error';
if (req.body.type == 'error') {
logType = 'error';
} else if (req.body.message.indexOf('ok') === 0) {
logType = 'ok';
} else if (req.body.message.indexOf('not ok') === 0) {
logType = 'error';
}
message = req.body.message;
}
if (typeof message != 'string') message = JSON.stringify(message, null, 2);
if (typeof message != 'string') {
message = JSON.stringify(message, null, 2);
}
grunt.log[logType]('[%s][%s]', req.headers['user-agent'], Date.now(), message);
res.write('<!doctype html><meta charset=utf-8>');
res.end('Got it, thanks!');
@ -25,8 +35,8 @@ module.exports = function(grunt){
port: 9999,
middleware: function(connect, options) {
connect.logger.token('user-agent', function(req, res){ return req.headers['user-agent']; });
connect.logger.token('timestamp', function(req, res){ return Date.now(); });
connect.logger.token('user-agent', function(req, res) { return req.headers['user-agent']; });
connect.logger.token('timestamp', function(req, res) { return Date.now(); });
return [
connect.json(),
@ -39,5 +49,5 @@ module.exports = function(grunt){
},
}
}
}
}
};
};

View File

@ -1,3 +1,5 @@
'use strict';
var grunt = require('grunt');
@ -14,9 +16,11 @@ exports.local = {
onError: function(error){
grunt.fatal(error);
}
}
};
if (grunt.option('debug')) exports.local.url += '?debug=' + grunt.option('debug');
if (grunt.option('debug')) {
exports.local.url += '?debug=' + grunt.option('debug');
}
exports.saucelabs = {
@ -43,7 +47,7 @@ exports.saucelabs = {
},
onComplete: exports.local.onComplete,
onError: exports.local.onError
}
};
/* https://saucelabs.com/docs/platforms */
exports.saucelabs_ios =
@ -74,7 +78,7 @@ exports.saucelabs_ie10 = sauceItUp({ browserName: 'internet explorer', version:
exports.saucelabs_ie11 = sauceItUp({ browserName: 'internet explorer', version: 11, platform:'Windows 8.1' });
function sauceItUp(desiredCapabilities){
function sauceItUp(desiredCapabilities) {
desiredCapabilities["build"] = exports.saucelabs.desiredCapabilities["build"];
desiredCapabilities["tunnel-identifier"] = exports.saucelabs.desiredCapabilities["tunnel-identifier"];
return {

View File

@ -1,7 +1,7 @@
'use strict';
var grunt = require('grunt');
var fs = require('fs')
var fs = require('fs');
module.exports = function() {
var config = this.data;

View File

@ -1,16 +1,21 @@
'use strict';
var grunt = require('grunt');
var SauceTunnel = require('sauce-tunnel');
module.exports = function(){
module.exports = function() {
var task = this;
var config = task.data;
var shouldStayAliveForever = task.flags.keepalive;
var SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY;
if (!SAUCE_ACCESS_KEY) grunt.fatal('Requires the environment variable SAUCE_ACCESS_KEY to be set');
if (!SAUCE_ACCESS_KEY) {
grunt.fatal('Requires the environment variable SAUCE_ACCESS_KEY to be set');
}
var SAUCE_USERNAME = process.env.SAUCE_USERNAME;
if (!SAUCE_USERNAME) grunt.fatal('Requires the environment variable SAUCE_USERNAME to be set');
if (!SAUCE_USERNAME) {
grunt.fatal('Requires the environment variable SAUCE_USERNAME to be set');
}
var IDENTIFIER = process.env.TRAVIS_JOB_NUMBER || 'my awesome tunnel';
@ -28,7 +33,7 @@ module.exports = function(){
stunnel.on('verbose:writeln', grunt.verbose.writeln.bind(grunt.verbose));
stunnel.openTunnel(function(isOpen){
if (shouldStayAliveForever && isOpen){
if (shouldStayAliveForever && isOpen) {
grunt.verbose.writeln('Keeping the sauce-tunnel open forever because you used the keepalive flag `' + task.nameArgs + '`');
return;
}

View File

@ -1,3 +1,7 @@
/* jshint evil: true */
'use strict';
var grunt = require("grunt");
var wd = require('wd');
@ -6,10 +10,14 @@ module.exports = function(){
var taskSucceeded = this.async();
var desiredCapabilities = {};
if (config.desiredCapabilities) Object.keys(config.desiredCapabilities).forEach(function(key){
if (config.desiredCapabilities[key] === undefined) return;
desiredCapabilities[key] = config.desiredCapabilities[key];
});
if (config.desiredCapabilities) {
Object.keys(config.desiredCapabilities).forEach(function(key) {
if (config.desiredCapabilities[key] === undefined) {
return;
}
desiredCapabilities[key] = config.desiredCapabilities[key];
});
}
grunt.verbose.writeln("desiredCapabilities", JSON.stringify(desiredCapabilities));
var browser = wd.promiseChainRemote(config.webdriver.remote);
@ -37,26 +45,31 @@ module.exports = function(){
return browser
.eval('document.documentElement.innerText || document.documentElement.textContent')
.then(grunt.verbose.writeln.bind(grunt.verbose))
.then(function(){throw error})
.then(function(){ throw error; })
;
})
.finally(function(){
if (grunt.option('webdriver-keep-open')) return;
if (grunt.option('webdriver-keep-open')) {
return;
}
grunt.verbose.writeln('Closing the browser window. To keep it open, pass the --webdriver-keep-open flag to grunt.');
return browser.quit();
})
.done(
function(){
if (config.onComplete) config.onComplete(results);
function() {
if (config.onComplete) {
config.onComplete(results);
}
taskSucceeded(true);
},
function(error){
if (config.onError) config.onError(error);
function(error) {
if (config.onError) {
config.onError(error);
}
taskSucceeded(false);
}
)
;
}
);
};
function getJSReport(browser){
return browser
@ -66,6 +79,5 @@ function getJSReport(browser){
})
.waitForCondition("typeof window.jasmine.getJSReport != 'undefined'", 10e3)
.waitForCondition("window.postDataToURL.running <= 0", 30e3)
.eval("jasmine.getJSReport().passed")
;
.eval("jasmine.getJSReport().passed");
}

View File

@ -1,3 +1,5 @@
'use strict';
var grunt = require('grunt');
module.exports = function(){
@ -21,7 +23,9 @@ module.exports = function(){
});
child.on('exit', function(code) {
grunt.verbose.writeln('phantomjs END');
if (code) grunt.fatal('phantomjs FAIL');
if (code) {
grunt.fatal('phantomjs FAIL');
}
});
function verboseWrite(chunk) {
@ -34,4 +38,4 @@ module.exports = function(){
}
child.stdout.on('data', verboseWrite);
child.stderr.on('data', verboseWrite);
}
};

View File

@ -15,6 +15,7 @@
"nonstandard": true,
"onecase": true,
"regexdash": true,
"sub": false,
"trailing": true,
"undef": true,
"unused": "vars",