Skip to content

Commit

Permalink
Build: Update JSCS and JSHint
Browse files Browse the repository at this point in the history
Closes gh-936
Fixes gh-879
  • Loading branch information
Trent Willis authored and leobalter committed Mar 2, 2016
1 parent 65706a1 commit 0f9ae34
Show file tree
Hide file tree
Showing 48 changed files with 618 additions and 559 deletions.
4 changes: 2 additions & 2 deletions Gruntfile.js
Expand Up @@ -19,7 +19,7 @@ function process( code, filepath ) {
.replace( /@DATE/g, ( new Date() ).toISOString().replace( /:\d+\.\d+Z$/, "Z" ) );
}

grunt.initConfig({
grunt.initConfig( {
pkg: grunt.file.readJSON( "package.json" ),
concat: {
"src-js": {
Expand Down Expand Up @@ -173,7 +173,7 @@ grunt.initConfig({
],
tasks: "default"
}
});
} );

grunt.loadTasks( "build/tasks" );
grunt.registerTask( "build", [ "concat" ] );
Expand Down
6 changes: 3 additions & 3 deletions build/release.js
Expand Up @@ -3,7 +3,7 @@ module.exports = function( Release ) {

var shell = require( "shelljs" );

Release.define({
Release.define( {
npmPublish: true,
issueTracker: "github",
changelogShell: function() {
Expand All @@ -17,9 +17,9 @@ Release.define({
shell.mkdir( "-p", "dist/cdn" );
shell.cp( "dist/qunit.js", "dist/cdn/qunit-" + Release.newVersion + ".js" );
shell.cp( "dist/qunit.css", "dist/cdn/qunit-" + Release.newVersion + ".css" );
done([ "qunit/qunit.js", "qunit/qunit.css" ]);
done( [ "qunit/qunit.js", "qunit/qunit.css" ] );
}
});
} );

};

Expand Down
22 changes: 11 additions & 11 deletions build/tasks/test-on-node.js
Expand Up @@ -10,18 +10,18 @@ module.exports = function( grunt ) {
return function( runEnd ) {
runQUnit( file, runEnd );
};
});
} );

var done = this.async();

async.series( runs, function( error, result ) {
var total = result.reduce(function( previous, details ) {
var total = result.reduce( function( previous, details ) {
return previous + details.total;
}, 0 );
var failed = result.reduce(function( previous, details ) {
var failed = result.reduce( function( previous, details ) {
return previous + details.failed;
}, 0 );
var runtime = result.reduce(function( previous, details ) {
var runtime = result.reduce( function( previous, details ) {
return previous + details.runtime;
}, 0 );

Expand All @@ -30,8 +30,8 @@ module.exports = function( grunt ) {
"with " + failed + " failed assertions" );

done( !error );
});
});
} );
} );

function runQUnit( file, runEnd ) {

Expand Down Expand Up @@ -60,21 +60,21 @@ module.exports = function( grunt ) {

QUnit.begin( function() {
grunt.log.ok( "Testing " + file + " ..." );
});
} );
QUnit.testStart( function() {
testActive = true;
});
} );
QUnit.log( function( details ) {
if ( !testActive || details.result ) {
return;
}
var message = "name: " + details.name + " module: " + details.module +
" message: " + details.message;
grunt.log.error( message );
});
} );
QUnit.testDone( function() {
testActive = false;
});
} );
QUnit.done( function( details ) {
if ( runDone ) {
return;
Expand All @@ -90,6 +90,6 @@ module.exports = function( grunt ) {

runDone = true;
runEnd( details.failed, details );
});
} );
}
};
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -35,11 +35,11 @@
"grunt-cli": "0.1.13",
"grunt-concurrent": "2.0.3",
"grunt-contrib-concat": "0.3.0",
"grunt-contrib-jshint": "0.11.2",
"grunt-contrib-jshint": "1.0.0",
"grunt-contrib-watch": "0.5.3",
"grunt-coveralls": "1.0.0",
"grunt-git-authors": "3.0.0",
"grunt-jscs": "0.8.1",
"grunt-jscs": "2.7.0",
"grunt-qunit-istanbul": "0.5.0",
"grunt-search": "0.1.6",
"load-grunt-tasks": "0.3.0",
Expand Down
73 changes: 37 additions & 36 deletions reporter/html.js
@@ -1,4 +1,4 @@
(function() {
( function() {

// Don't load the HTML Reporter on non-Browser environments
if ( typeof window === "undefined" || !window.document ) {
Expand Down Expand Up @@ -67,7 +67,7 @@ var config = QUnit.config,
hasOwn = Object.prototype.hasOwnProperty,
defined = {
document: window.document !== undefined,
sessionStorage: (function() {
sessionStorage: ( function() {
var x = "qunit-test-string";
try {
sessionStorage.setItem( x, x );
Expand All @@ -76,7 +76,7 @@ var config = QUnit.config,
} catch ( e ) {
return false;
}
}())
}() )
},
modulesList = [];

Expand All @@ -103,7 +103,7 @@ function escapeText( s ) {
case "&":
return "&";
}
});
} );
}

/**
Expand All @@ -118,15 +118,15 @@ function addEvent( elem, type, fn ) {
elem.addEventListener( type, fn, false );
} else if ( elem.attachEvent ) {

// support: IE <9
// Support: IE <9
elem.attachEvent( "on" + type, function() {
var event = window.event;
if ( !event.target ) {
event.target = event.srcElement || document;
}

fn.call( elem, event );
});
} );
}
}

Expand Down Expand Up @@ -168,7 +168,7 @@ function removeClass( elem, name ) {
set = set.replace( " " + name + " ", " " );
}

// trim for prettiness
// Trim for prettiness
elem.className = typeof set.trim === "function" ? set.trim() : set.replace( /^\s+|\s+$/g, "" );
}

Expand Down Expand Up @@ -305,13 +305,13 @@ function applyUrlParams() {
decodeURIComponent( modulesList.options[ modulesList.selectedIndex ].value ) :
undefined;

window.location = setUrl({
window.location = setUrl( {
module: ( selectedModule === "" ) ? undefined : selectedModule,
filter: ( filter === "" ) ? undefined : filter,

// Remove testId filter
testId: undefined
});
} );
}

function toolbarUrlConfigContainer() {
Expand Down Expand Up @@ -358,7 +358,7 @@ function toolbarLooseFilter() {
}

return false;
});
} );

return filter;
}
Expand All @@ -371,9 +371,9 @@ function toolbarModuleFilterHtml() {
return false;
}

modulesList.sort(function( a, b ) {
modulesList.sort( function( a, b ) {
return a.localeCompare( b );
});
} );

moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label>" +
"<select id='qunit-modulefilter' name='modulefilter'><option value='' " +
Expand Down Expand Up @@ -466,7 +466,7 @@ function appendFilteredTest() {
return "";
}
return "<div id='qunit-filteredTest'>Rerunning selected tests: " +
escapeText( testId.join(", ") ) +
escapeText( testId.join( ", " ) ) +
" <a id='qunit-clearFilter' href='" +
escapeText( setUrl( { filter: undefined, module: undefined, testId: undefined } ) ) +
"'>" + "Run all tests" + "</a></div>";
Expand Down Expand Up @@ -516,7 +516,7 @@ function appendTest( name, testId, moduleName ) {

rerunTrigger = document.createElement( "a" );
rerunTrigger.innerHTML = "Rerun";
rerunTrigger.href = setUrl({ testId: testId });
rerunTrigger.href = setUrl( { testId: testId } );

testBlock = document.createElement( "li" );
testBlock.appendChild( title );
Expand All @@ -532,7 +532,7 @@ function appendTest( name, testId, moduleName ) {
}

// HTML Reporter initialization and load
QUnit.begin(function( details ) {
QUnit.begin( function( details ) {
var qunit = id( "qunit" );

// Fixture is the only one necessary to run without the #qunit element
Expand All @@ -559,9 +559,9 @@ QUnit.begin(function( details ) {
if ( qunit && config.hidepassed ) {
addClass( qunit.lastChild, "hidepass" );
}
});
} );

QUnit.done(function( details ) {
QUnit.done( function( details ) {
var i, key,
banner = id( "qunit-banner" ),
tests = id( "qunit-tests" ),
Expand All @@ -588,15 +588,15 @@ QUnit.done(function( details ) {

if ( config.altertitle && defined.document && document.title ) {

// show ✖ for good, ✔ for bad suite result in title
// Show ✖ for good, ✔ for bad suite result in title
// use escape sequences in case file gets loaded with non-utf-8-charset
document.title = [
( details.failed ? "\u2716" : "\u2714" ),
document.title.replace( /^[\u2714\u2716] /i, "" )
].join( " " );
}

// clear own sessionStorage items if all tests passed
// Clear own sessionStorage items if all tests passed
if ( config.reorder && defined.sessionStorage && details.failed === 0 ) {
for ( i = 0; i < sessionStorage.length; i++ ) {
key = sessionStorage.key( i++ );
Expand All @@ -606,11 +606,11 @@ QUnit.done(function( details ) {
}
}

// scroll back to top to show results
// Scroll back to top to show results
if ( config.scrolltop && window.scrollTo ) {
window.scrollTo( 0, 0 );
}
});
} );

function getNameHtml( name, module ) {
var nameHtml = "";
Expand All @@ -624,7 +624,7 @@ function getNameHtml( name, module ) {
return nameHtml;
}

QUnit.testStart(function( details ) {
QUnit.testStart( function( details ) {
var running, testBlock, bad;

testBlock = id( "qunit-test-output-" + details.testId );
Expand All @@ -647,14 +647,15 @@ QUnit.testStart(function( details ) {
getNameHtml( details.name, details.module );
}

});
} );

function stripHtml( string ) {
// strip tags, html entity and whitespaces
return string.replace(/<\/?[^>]+(>|$)/g, "").replace(/\&quot;/g, "").replace(/\s+/g, "");

// Strip tags, html entity and whitespaces
return string.replace( /<\/?[^>]+(>|$)/g, "" ).replace( /\&quot;/g, "" ).replace( /\s+/g, "" );
}

QUnit.log(function( details ) {
QUnit.log( function( details ) {
var assertList, assertLi,
message, expected, actual, diff,
showDiff = false,
Expand All @@ -668,7 +669,7 @@ QUnit.log(function( details ) {
message = "<span class='test-message'>" + message + "</span>";
message += "<span class='runtime'>@ " + details.runtime + " ms</span>";

// pushFailure doesn't provide details.expected
// The pushFailure doesn't provide details.expected
// when it calls, it's implicit to also not show expected and diff stuff
// Also, we need to check details.expected existence, as it can exist and be undefined
if ( !details.result && hasOwn.call( details, "expected" ) ) {
Expand Down Expand Up @@ -719,7 +720,7 @@ QUnit.log(function( details ) {

message += "</table>";

// this occurs when pushFailure is set and we have an extracted stack trace
// This occurs when pushFailure is set and we have an extracted stack trace
} else if ( !details.result && details.source ) {
message += "<table>" +
"<tr class='test-source'><th>Source: </th><td><pre>" +
Expand All @@ -733,9 +734,9 @@ QUnit.log(function( details ) {
assertLi.className = details.result ? "pass" : "fail";
assertLi.innerHTML = message;
assertList.appendChild( assertLi );
});
} );

QUnit.testDone(function( details ) {
QUnit.testDone( function( details ) {
var testTitle, time, testItem, assertList,
good, bad, testCounts, skipped, sourceName,
tests = id( "qunit-tests" );
Expand All @@ -751,7 +752,7 @@ QUnit.testDone(function( details ) {
good = details.passed;
bad = details.failed;

// store result when possible
// Store result when possible
if ( config.reorder && defined.sessionStorage ) {
if ( bad ) {
sessionStorage.setItem( "qunit-test-" + details.module + "-" + details.name, bad );
Expand All @@ -774,7 +775,7 @@ QUnit.testDone(function( details ) {
addClass( assertList, "qunit-collapsed" );
}

// testItem.firstChild is the test name
// The testItem.firstChild is the test name
testTitle = testItem.firstChild;

testCounts = bad ?
Expand All @@ -793,7 +794,7 @@ QUnit.testDone(function( details ) {
} else {
addEvent( testTitle, "click", function() {
toggleClass( assertList, "qunit-collapsed" );
});
} );

testItem.className = bad ? "fail" : "pass";

Expand All @@ -813,10 +814,10 @@ QUnit.testDone(function( details ) {
}
addEvent( testTitle, "click", function() {
toggleClass( sourceName, "qunit-collapsed" );
});
} );
testItem.appendChild( sourceName );
}
});
} );

if ( defined.document ) {

Expand All @@ -836,4 +837,4 @@ if ( defined.document ) {
config.autorun = true;
}

})();
}() );

0 comments on commit 0f9ae34

Please sign in to comment.