From 0fa52c11cbfe70780648b99717f1dd3502befaff Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Tue, 9 Apr 2013 11:45:09 -0400 Subject: [PATCH] Update jshintrc to conform to new style guide. Conform to onevar and unused in tests. Fixes #13755. --- .jshintrc | 13 +- Gruntfile.js | 6 +- src/.jshintrc | 12 +- src/data.js | 12 +- test/.jshintrc | 11 +- test/data/test.js | 2 +- test/data/testinit.js | 131 ++++++++++---------- test/data/testrunner.js | 10 +- test/unit/ajax.js | 37 +++--- test/unit/attributes.js | 133 +++++++++++--------- test/unit/callbacks.js | 4 +- test/unit/core.js | 179 +++++++++++++------------- test/unit/css.js | 91 ++++++++------ test/unit/data.js | 51 ++++---- test/unit/deferred.js | 28 ++--- test/unit/dimensions.js | 63 ++++++---- test/unit/effects.js | 160 +++++++++++++----------- test/unit/event.js | 255 ++++++++++++++++++++------------------ test/unit/manipulation.js | 58 ++++----- test/unit/offset.js | 50 +++++--- test/unit/queue.js | 33 +++-- test/unit/serialize.js | 6 +- test/unit/traversing.js | 51 +++++--- test/unit/wrap.js | 28 ++--- 24 files changed, 768 insertions(+), 656 deletions(-) diff --git a/.jshintrc b/.jshintrc index 4f0431ddc..13a9e01b9 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,14 +1,17 @@ { + "boss": true, "curly": true, "eqeqeq": true, - "latedef": true, + "eqnull": true, + "expr": true, + "immed": true, "noarg": true, - "noempty": true, + "onevar": true, "quotmark": "double", + "smarttabs": true, + "trailing": true, "undef": true, "unused": true, - "strict": true, - "trailing": true, "node": true -} +} \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 5e2917373..9d9f85a20 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -406,7 +406,7 @@ module.exports = function( grunt ) { // Process files for distribution grunt.registerTask( "dist", function() { - var flags, paths, stored; + var stored, flags, paths, fs, nonascii; // Check for stored destination paths // ( set in dist/.destination.json ) @@ -421,8 +421,8 @@ module.exports = function( grunt ) { }); // Ensure the dist files are pure ASCII - var fs = require("fs"), - nonascii = false; + fs = require("fs"); + nonascii = false; distpaths.forEach(function( filename ) { var i, c, map, diff --git a/src/.jshintrc b/src/.jshintrc index ef8723031..71e505e1d 100644 --- a/src/.jshintrc +++ b/src/.jshintrc @@ -1,18 +1,18 @@ { + "boss": true, "curly": true, + "eqeqeq": true, + "eqnull": true, "expr": true, - "newcap": false, + "immed": true, + "noarg": true, "quotmark": "double", + "smarttabs": true, "trailing": true, "undef": true, "unused": true, - "latedef": false, - "eqeqeq": true, - "maxerr": 100, - "eqnull": true, "sub": true, - "boss": true, "browser": true, "es5": true, diff --git a/src/data.js b/src/data.js index acb3fa265..0fd35033a 100644 --- a/src/data.js +++ b/src/data.js @@ -333,12 +333,12 @@ function dataAttr( elem, key, data ) { if ( typeof data === "string" ) { try { data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - // Only convert to a number if it doesn't change the string - +data + "" === data ? +data : - rbrace.test( data ) ? - JSON.parse( data ) : data; + data === "false" ? false : + data === "null" ? null : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? JSON.parse( data ) : + data; } catch( e ) {} // Make sure we set the data so it isn't changed later diff --git a/test/.jshintrc b/test/.jshintrc index 5e4f23fc7..f92ff88cd 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -1,14 +1,19 @@ { + "boss": true, "curly": true, + "eqeqeq": true, + "eqnull": true, "expr": true, + "immed": true, + "noarg": true, + "onevar": true, "quotmark": "double", + "smarttabs": true, "trailing": true, "undef": true, - "maxerr": 100, + "unused": true, - "eqnull": true, "evil": true, - "smarttabs": true, "sub": true, "browser": true, diff --git a/test/data/test.js b/test/data/test.js index 5980bff91..fb3395296 100644 --- a/test/data/test.js +++ b/test/data/test.js @@ -1,3 +1,3 @@ -var testBar = "bar"; +this.testBar = "bar"; jQuery("#ap").html("bar"); ok( true, "test.js executed"); diff --git a/test/data/testinit.js b/test/data/testinit.js index 87edfde29..0351f0264 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -3,11 +3,12 @@ var amdDefined, fireNative, originaljQuery = this.jQuery || "jQuery", original$ = this.$ || "$", - hasPHP = true, - isLocal = window.location.protocol === "file:", // see RFC 2606 externalHost = "example.com"; +this.hasPHP = true; +this.isLocal = window.location.protocol === "file:"; + // For testing .noConflict() this.jQuery = originaljQuery; this.$ = original$; @@ -26,7 +27,7 @@ define.amd = {}; * @example q("main", "foo", "bar") * @result [
, , ] */ -function q() { +this.q = function() { var r = [], i = 0; @@ -34,7 +35,7 @@ function q() { r.push( document.getElementById( arguments[i] ) ); } return r; -} +}; /** * Asserts that a select matches the given IDs @@ -44,7 +45,7 @@ function q() { * @example t("Check for something", "//[a]", ["foo", "baar"]); * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar' */ -function t( a, b, c ) { +this.t = function( a, b, c ) { var f = jQuery(b).get(), s = "", i = 0; @@ -54,9 +55,9 @@ function t( a, b, c ) { } deepEqual(f, q.apply( q, c ), a + " (" + b + ")"); -} +}; -function createDashboardXML() { +this.createDashboardXML = function() { var string = ' \ \ \ @@ -70,9 +71,9 @@ function createDashboardXML() { '; return jQuery.parseXML(string); -} +}; -function createWithFriesXML() { +this.createWithFriesXML = function() { var string = ' \ '; return jQuery.parseXML( string.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost ) ); -} +}; -function createXMLFragment() { +this.createXMLFragment = function() { var xml, frag; if ( window.ActiveXObject ) { xml = new ActiveXObject("msxml2.domdocument"); @@ -115,7 +116,7 @@ function createXMLFragment() { } return frag; -} +}; fireNative = document.createEvent ? function( node, type ) { @@ -142,7 +143,7 @@ function url( value ) { } // Ajax testing helper -function ajaxTest( title, expect, options ) { +this.ajaxTest = function( title, expect, options ) { var requestOptions; if ( jQuery.isFunction( options ) ) { options = options(); @@ -205,63 +206,59 @@ function ajaxTest( title, expect, options ) { } }; }); -} +}; -(function () { - - this.testIframe = function( fileName, name, fn ) { - - test(name, function() { - // pause execution for now - stop(); - - // load fixture in iframe - var iframe = loadFixture(), - win = iframe.contentWindow, - interval = setInterval( function() { - if ( win && win.jQuery && win.jQuery.isReady ) { - clearInterval( interval ); - // continue - start(); - // call actual tests passing the correct jQuery instance to use - fn.call( this, win.jQuery, win, win.document ); - document.body.removeChild( iframe ); - iframe = null; - } - }, 15 ); - }); - - function loadFixture() { - var src = url("./data/" + fileName + ".html"), - iframe = jQuery("