]> source.dussan.org Git - jquery.git/commitdiff
Make compatible with jshint, lint test/data. Close gh-1043.
authorTimo Tijhof <krinklemail@gmail.com>
Sun, 25 Nov 2012 19:30:16 +0000 (20:30 +0100)
committerRichard Gibson <richard.gibson@gmail.com>
Thu, 6 Dec 2012 18:46:37 +0000 (13:46 -0500)
.jshintrc
grunt.js
src/.jshintrc
test/.jshintignore [new file with mode: 0644]
test/.jshintrc
test/data/test.js
test/data/testinit.js
test/data/testrunner.js

index 5ff1e697da661013aa64ccfa7375dcb77126b756..4f0431ddc0c674bbd7ef8c192e32b363ae703a20 100644 (file)
--- a/.jshintrc
+++ b/.jshintrc
@@ -1,16 +1,14 @@
 {
-  "options": {
-    "curly": true,
-    "eqeqeq": true,
-    "eqnull": true,
-    "expr": true,
-    "latedef": true,
-    "noarg": true,
-    "node": true,
-    "quotmark": "double",
-    "smarttabs": true,
-    "trailing": true,
-    "undef": true,
-    "unused": true
-  }
+       "curly": true,
+       "eqeqeq": true,
+       "latedef": true,
+       "noarg": true,
+       "noempty": true,
+       "quotmark": "double",
+       "undef": true,
+       "unused": true,
+       "strict": true,
+       "trailing": true,
+
+       "node": true
 }
index dad96b77d045f70524cd1617c150560c4369d92e..90dd7d69a00722cc110edeba988b43e73842522b 100644 (file)
--- a/grunt.js
+++ b/grunt.js
@@ -2,7 +2,6 @@
  * Resources
  *
  * https://gist.github.com/2489540
- *
  */
 
 module.exports = function( grunt ) {
@@ -82,7 +81,8 @@ module.exports = function( grunt ) {
                lint: {
                        dist: "dist/jquery.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() {
@@ -91,9 +91,15 @@ module.exports = function( grunt ) {
                        }
 
                        return {
-                               grunt: jshintrc(),
-                               dist: jshintrc( "src/" ),
-                               tests: jshintrc( "test/" )
+                               grunt: {
+                                       options: jshintrc()
+                               },
+                               dist: {
+                                       options: jshintrc( "src/" )
+                               },
+                               tests: {
+                                       options: jshintrc( "test/" )
+                               }
                        };
                })(),
 
index daffbf5cc76878e884ba3aa9724b7358cc0db9d9..72a58de2ea12eab277afbf5124b4698dc697d907 100644 (file)
@@ -1,32 +1,24 @@
 {
-  "options": {
-    "browser": true,
-    "curly": true,
-    "eqnull": true,
-    "evil": true,
-    "expr": true,
-    "maxerr": 100,
-    "newcap": false,
-    "quotmark": "double",
-    "regexdash": true,
-    "strict": true,
-    "sub": true,
-    "trailing": true,
-    "undef": true,
-    "unused": true,
-    "wsh": true
-  },
-  "globals": {
-    "define": true,
-    "DOMParser": true,
-    "__dirname": true,
-    "jQuery": true,
-    "global": true,
-    "module": true,
-    "exports": true,
-    "require": true,
-    "file": true,
-    "log": true,
-    "console": true
-  }
+       "curly": true,
+       "expr": true,
+       "newcap": false,
+       "quotmark": "double",
+       "regexdash": true,
+       "strict": true,
+       "trailing": true,
+       "undef": true,
+       "unused": true,
+       "maxerr": 100,
+
+       "eqnull": true,
+       "evil": true,
+       "sub": true,
+
+       "browser": true,
+       "wsh": true,
+
+       "predef": [
+               "define",
+               "jQuery"
+       ]
 }
diff --git a/test/.jshintignore b/test/.jshintignore
new file mode 100644 (file)
index 0000000..ba90d81
--- /dev/null
@@ -0,0 +1,3 @@
+qunit/
+data/badjson.js
+data/jquery-1.8.2.ajax_xhr.min.js
index 2dd668c3fc7a294cb7f00966f1f9628e39d91662..76e215f1eed5b12b8f443647625546db9fb8d8a1 100644 (file)
@@ -1,61 +1,55 @@
 {
-  "options": {
-    "browser": true,
-    "curly": true,
-    "devel": true,
-    "eqnull": true,
-    "evil": true,
-    "expr": true,
-    "maxerr": 100,
-    "quotmark": "double",
-    "smarttabs": true,
-    "sub": true,
-    "trailing": true,
-    "undef": true,
-    "wsh": true
-  },
-  "globals": {
-    "define": true,
-    "DOMParser": true,
-    "__dirname": true,
-    "jQuery": true,
-    "global": true,
-    "module": true,
-    "exports": true,
-    "require": true,
-    "file": true,
-    "log": true,
-    "QUnit": true,
-    "ok": true,
-    "equal": true,
-    "test": true,
-    "asyncTest": true,
-    "notEqual": true,
-    "deepEqual": true,
-    "strictEqual": true,
-    "notStrictEqual": true,
-    "start": true,
-    "stop": true,
-    "expect": true,
-    "raises": true,
-    "ajaxTest": true,
-    "testIframe": true,
-    "testIframeWithCallback": true,
-    "createDashboardXML": true,
-    "createXMLFragment": true,
-    "moduleTeardown": true,
-    "testFoo": true,
-    "url": true,
-    "t": true,
-    "q": true,
-    "amdDefined": true,
-    "fireNative": true,
-    "Globals": true,
-    "hasPHP": true,
-    "isLocal": true,
-    "originaljQuery": true,
-    "$": true,
-    "original$": true,
-    "externalHost": true
-  }
+       "curly": true,
+       "expr": true,
+       "quotmark": "double",
+       "trailing": true,
+       "undef": true,
+       "maxerr": 100,
+
+       "eqnull": true,
+       "evil": true,
+       "smarttabs": true,
+       "sub": true,
+
+       "browser": true,
+       "devel": true,
+       "wsh": true,
+
+       "predef": [
+               "DOMParser",
+               "jQuery",
+               "QUnit",
+               "module",
+               "ok",
+               "equal",
+               "test",
+               "asyncTest",
+               "notEqual",
+               "deepEqual",
+               "strictEqual",
+               "notStrictEqual",
+               "start",
+               "stop",
+               "expect",
+               "raises",
+               "ajaxTest",
+               "testIframe",
+               "testIframeWithCallback",
+               "createDashboardXML",
+               "createXMLFragment",
+               "moduleTeardown",
+               "testFoo",
+               "url",
+               "t",
+               "q",
+               "amdDefined",
+               "fireNative",
+               "Globals",
+               "hasPHP",
+               "isLocal",
+               "originaljQuery",
+               "$",
+               "original$",
+               "externalHost"
+  ]
 }
index a188153150ddd01162ceb5987e3aea01c8857d60..5980bff913ef49219037b84bb47f1d7765643b82 100644 (file)
@@ -1,3 +1,3 @@
 var testBar = "bar";
-jQuery('#ap').html('bar');
+jQuery("#ap").html("bar");
 ok( true, "test.js executed");
index bff6b8dffdf983707024efc5b8ef72771ae0686e..ea940cb6371b43dd0baf7495190175314b5618b4 100644 (file)
@@ -1,4 +1,4 @@
-/*jshint multistr:true */
+/*jshint multistr:true, quotmark:false */
 
 var amdDefined, fireNative,
        originaljQuery = this.jQuery || "jQuery",
@@ -207,7 +207,7 @@ function ajaxTest( title, expect, options ) {
                        }
                };
        });
-};
+}
 
 (function () {
 
index ba6b892e37799d821e9335e7a12fbdb2a002b748..c9888c3837b0caef374f8379af27d8642d4798b8 100644 (file)
@@ -232,7 +232,7 @@ var Globals = (function() {
                                // Since this method was called it means some data was
                                // expected to be found, but since there is nothing, fail early
                                // (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 {
                                if ( expectedDataKeys[expando] ) {
                                        expectedDataKeys[expando].push( key );
@@ -243,9 +243,9 @@ var Globals = (function() {
                }
        };
        QUnit.config.urlConfig.push( {
-               id: 'jqdata',
-               label: 'Always check jQuery.data',
-               tooltip: 'Trigger "QUnit.expectJqData" detection for all tests instead of just the ones that call it'
+               id: "jqdata",
+               label: "Always check jQuery.data",
+               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];
                                actualKeys = jQuery.cache[i] ? keys( jQuery.cache[i] ) : jQuery.cache[i];
                                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 expectedDataKeys[i];
                        }
                        // In case it was removed from cache before (or never there in the first place)
                        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];
                        }
                }
@@ -359,5 +359,5 @@ QUnit.config.requireExpects = true;
                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>");
 })();