Make compatible with jshint, lint test/data. Close gh-1043.

This commit is contained in:
Timo Tijhof 2012-11-25 20:30:16 +01:00 committed by Richard Gibson
parent 26bf8dd56b
commit 5dd8a90f73
8 changed files with 111 additions and 118 deletions

View File

@ -1,16 +1,14 @@
{ {
"options": {
"curly": true, "curly": true,
"eqeqeq": true, "eqeqeq": true,
"eqnull": true,
"expr": true,
"latedef": true, "latedef": true,
"noarg": true, "noarg": true,
"node": true, "noempty": true,
"quotmark": "double", "quotmark": "double",
"smarttabs": true,
"trailing": true,
"undef": true, "undef": true,
"unused": true "unused": true,
} "strict": true,
"trailing": true,
"node": true
} }

View File

@ -2,7 +2,6 @@
* Resources * Resources
* *
* https://gist.github.com/2489540 * https://gist.github.com/2489540
*
*/ */
module.exports = function( grunt ) { module.exports = function( grunt ) {
@ -82,7 +81,8 @@ module.exports = function( grunt ) {
lint: { lint: {
dist: "dist/jquery.js", dist: "dist/jquery.js",
grunt: "grunt.js", grunt: "grunt.js",
tests: "test/unit/**/*.js" // TODO: Once .jshintignore is supported, use that instead.
tests: ["test/data/{test,testinit,testrunner}.js", "test/unit/**/*.js"]
}, },
jshint: (function() { jshint: (function() {
@ -91,9 +91,15 @@ module.exports = function( grunt ) {
} }
return { return {
grunt: jshintrc(), grunt: {
dist: jshintrc( "src/" ), options: jshintrc()
tests: jshintrc( "test/" ) },
dist: {
options: jshintrc( "src/" )
},
tests: {
options: jshintrc( "test/" )
}
}; };
})(), })(),

View File

@ -1,32 +1,24 @@
{ {
"options": {
"browser": true,
"curly": true, "curly": true,
"eqnull": true,
"evil": true,
"expr": true, "expr": true,
"maxerr": 100,
"newcap": false, "newcap": false,
"quotmark": "double", "quotmark": "double",
"regexdash": true, "regexdash": true,
"strict": true, "strict": true,
"sub": true,
"trailing": true, "trailing": true,
"undef": true, "undef": true,
"unused": true, "unused": true,
"wsh": true "maxerr": 100,
},
"globals": { "eqnull": true,
"define": true, "evil": true,
"DOMParser": true, "sub": true,
"__dirname": true,
"jQuery": true, "browser": true,
"global": true, "wsh": true,
"module": true,
"exports": true, "predef": [
"require": true, "define",
"file": true, "jQuery"
"log": true, ]
"console": true
}
} }

3
test/.jshintignore Normal file
View File

@ -0,0 +1,3 @@
qunit/
data/badjson.js
data/jquery-1.8.2.ajax_xhr.min.js

View File

@ -1,61 +1,55 @@
{ {
"options": {
"browser": true,
"curly": true, "curly": true,
"devel": true,
"eqnull": true,
"evil": true,
"expr": true, "expr": true,
"maxerr": 100,
"quotmark": "double", "quotmark": "double",
"smarttabs": true,
"sub": true,
"trailing": true, "trailing": true,
"undef": true, "undef": true,
"wsh": true "maxerr": 100,
},
"globals": { "eqnull": true,
"define": true, "evil": true,
"DOMParser": true, "smarttabs": true,
"__dirname": true, "sub": true,
"jQuery": true,
"global": true, "browser": true,
"module": true, "devel": true,
"exports": true, "wsh": true,
"require": true,
"file": true, "predef": [
"log": true, "DOMParser",
"QUnit": true, "jQuery",
"ok": true, "QUnit",
"equal": true, "module",
"test": true, "ok",
"asyncTest": true, "equal",
"notEqual": true, "test",
"deepEqual": true, "asyncTest",
"strictEqual": true, "notEqual",
"notStrictEqual": true, "deepEqual",
"start": true, "strictEqual",
"stop": true, "notStrictEqual",
"expect": true, "start",
"raises": true, "stop",
"ajaxTest": true, "expect",
"testIframe": true, "raises",
"testIframeWithCallback": true, "ajaxTest",
"createDashboardXML": true, "testIframe",
"createXMLFragment": true, "testIframeWithCallback",
"moduleTeardown": true, "createDashboardXML",
"testFoo": true, "createXMLFragment",
"url": true, "moduleTeardown",
"t": true, "testFoo",
"q": true, "url",
"amdDefined": true, "t",
"fireNative": true, "q",
"Globals": true, "amdDefined",
"hasPHP": true, "fireNative",
"isLocal": true, "Globals",
"originaljQuery": true, "hasPHP",
"$": true, "isLocal",
"original$": true, "originaljQuery",
"externalHost": true "$",
} "original$",
"externalHost"
]
} }

View File

@ -1,3 +1,3 @@
var testBar = "bar"; var testBar = "bar";
jQuery('#ap').html('bar'); jQuery("#ap").html("bar");
ok( true, "test.js executed"); ok( true, "test.js executed");

View File

@ -1,4 +1,4 @@
/*jshint multistr:true */ /*jshint multistr:true, quotmark:false */
var amdDefined, fireNative, var amdDefined, fireNative,
originaljQuery = this.jQuery || "jQuery", originaljQuery = this.jQuery || "jQuery",
@ -207,7 +207,7 @@ function ajaxTest( title, expect, options ) {
} }
}; };
}); });
}; }
(function () { (function () {

View File

@ -232,7 +232,7 @@ var Globals = (function() {
// Since this method was called it means some data was // Since this method was called it means some data was
// expected to be found, but since there is nothing, fail early // expected to be found, but since there is nothing, fail early
// (instead of in teardown). // (instead of in teardown).
notStrictEqual( expando, undefined, 'Target for expectJqData must have an expando, for else there can be no data to expect.' ); notStrictEqual( expando, undefined, "Target for expectJqData must have an expando, for else there can be no data to expect." );
} else { } else {
if ( expectedDataKeys[expando] ) { if ( expectedDataKeys[expando] ) {
expectedDataKeys[expando].push( key ); expectedDataKeys[expando].push( key );
@ -243,9 +243,9 @@ var Globals = (function() {
} }
}; };
QUnit.config.urlConfig.push( { QUnit.config.urlConfig.push( {
id: 'jqdata', id: "jqdata",
label: 'Always check jQuery.data', label: "Always check jQuery.data",
tooltip: 'Trigger "QUnit.expectJqData" detection for all tests instead of just the ones that call it' tooltip: "Trigger QUnit.expectJqData detection for all tests instead of just the ones that call it"
} ); } );
/** /**
@ -265,14 +265,14 @@ var Globals = (function() {
expectedKeys = expectedDataKeys[i]; expectedKeys = expectedDataKeys[i];
actualKeys = jQuery.cache[i] ? keys( jQuery.cache[i] ) : jQuery.cache[i]; actualKeys = jQuery.cache[i] ? keys( jQuery.cache[i] ) : jQuery.cache[i];
if ( !QUnit.equiv( expectedKeys, actualKeys ) ) { if ( !QUnit.equiv( expectedKeys, actualKeys ) ) {
deepEqual( actualKeys, expectedKeys, 'Expected keys exist in jQuery.cache' ); deepEqual( actualKeys, expectedKeys, "Expected keys exist in jQuery.cache" );
} }
delete jQuery.cache[i]; delete jQuery.cache[i];
delete expectedDataKeys[i]; delete expectedDataKeys[i];
} }
// In case it was removed from cache before (or never there in the first place) // In case it was removed from cache before (or never there in the first place)
for ( i in expectedDataKeys ) { for ( i in expectedDataKeys ) {
deepEqual( expectedDataKeys[i], undefined, 'No unexpected keys were left in jQuery.cache (#' + i + ')' ); deepEqual( expectedDataKeys[i], undefined, "No unexpected keys were left in jQuery.cache (#" + i + ")" );
delete expectedDataKeys[i]; delete expectedDataKeys[i];
} }
} }
@ -359,5 +359,5 @@ QUnit.config.requireExpects = true;
return; return;
} }
document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>"); document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() + "'></scr" + "ipt>");
})(); })();