Skip to content

Commit 0fa52c1

Browse files
committed
Update jshintrc to conform to new style guide. Conform to onevar and unused in tests. Fixes #13755.
1 parent 0afc92b commit 0fa52c1

24 files changed

+768
-656
lines changed

.jshintrc

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
2+
"boss": true,
23
"curly": true,
34
"eqeqeq": true,
4-
"latedef": true,
5+
"eqnull": true,
6+
"expr": true,
7+
"immed": true,
58
"noarg": true,
6-
"noempty": true,
9+
"onevar": true,
710
"quotmark": "double",
11+
"smarttabs": true,
12+
"trailing": true,
813
"undef": true,
914
"unused": true,
10-
"strict": true,
11-
"trailing": true,
1215

1316
"node": true
14-
}
17+
}

Gruntfile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ module.exports = function( grunt ) {
406406

407407
// Process files for distribution
408408
grunt.registerTask( "dist", function() {
409-
var flags, paths, stored;
409+
var stored, flags, paths, fs, nonascii;
410410

411411
// Check for stored destination paths
412412
// ( set in dist/.destination.json )
@@ -421,8 +421,8 @@ module.exports = function( grunt ) {
421421
});
422422

423423
// Ensure the dist files are pure ASCII
424-
var fs = require("fs"),
425-
nonascii = false;
424+
fs = require("fs");
425+
nonascii = false;
426426

427427
distpaths.forEach(function( filename ) {
428428
var i, c, map,

src/.jshintrc

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
2+
"boss": true,
23
"curly": true,
4+
"eqeqeq": true,
5+
"eqnull": true,
36
"expr": true,
4-
"newcap": false,
7+
"immed": true,
8+
"noarg": true,
59
"quotmark": "double",
10+
"smarttabs": true,
611
"trailing": true,
712
"undef": true,
813
"unused": true,
9-
"latedef": false,
10-
"eqeqeq": true,
11-
"maxerr": 100,
1214

13-
"eqnull": true,
1415
"sub": true,
15-
"boss": true,
1616

1717
"browser": true,
1818
"es5": true,

src/data.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,12 @@ function dataAttr( elem, key, data ) {
333333
if ( typeof data === "string" ) {
334334
try {
335335
data = data === "true" ? true :
336-
data === "false" ? false :
337-
data === "null" ? null :
338-
// Only convert to a number if it doesn't change the string
339-
+data + "" === data ? +data :
340-
rbrace.test( data ) ?
341-
JSON.parse( data ) : data;
336+
data === "false" ? false :
337+
data === "null" ? null :
338+
// Only convert to a number if it doesn't change the string
339+
+data + "" === data ? +data :
340+
rbrace.test( data ) ? JSON.parse( data ) :
341+
data;
342342
} catch( e ) {}
343343

344344
// Make sure we set the data so it isn't changed later

test/.jshintrc

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
{
2+
"boss": true,
23
"curly": true,
4+
"eqeqeq": true,
5+
"eqnull": true,
36
"expr": true,
7+
"immed": true,
8+
"noarg": true,
9+
"onevar": true,
410
"quotmark": "double",
11+
"smarttabs": true,
512
"trailing": true,
613
"undef": true,
7-
"maxerr": 100,
14+
"unused": true,
815

9-
"eqnull": true,
1016
"evil": true,
11-
"smarttabs": true,
1217
"sub": true,
1318

1419
"browser": true,

test/data/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
var testBar = "bar";
1+
this.testBar = "bar";
22
jQuery("#ap").html("bar");
33
ok( true, "test.js executed");

test/data/testinit.js

+64-67
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
var amdDefined, fireNative,
44
originaljQuery = this.jQuery || "jQuery",
55
original$ = this.$ || "$",
6-
hasPHP = true,
7-
isLocal = window.location.protocol === "file:",
86
// see RFC 2606
97
externalHost = "example.com";
108

9+
this.hasPHP = true;
10+
this.isLocal = window.location.protocol === "file:";
11+
1112
// For testing .noConflict()
1213
this.jQuery = originaljQuery;
1314
this.$ = original$;
@@ -26,15 +27,15 @@ define.amd = {};
2627
* @example q("main", "foo", "bar")
2728
* @result [<div id="main">, <span id="foo">, <input id="bar">]
2829
*/
29-
function q() {
30+
this.q = function() {
3031
var r = [],
3132
i = 0;
3233

3334
for ( ; i < arguments.length; i++ ) {
3435
r.push( document.getElementById( arguments[i] ) );
3536
}
3637
return r;
37-
}
38+
};
3839

3940
/**
4041
* Asserts that a select matches the given IDs
@@ -44,7 +45,7 @@ function q() {
4445
* @example t("Check for something", "//[a]", ["foo", "baar"]);
4546
* @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
4647
*/
47-
function t( a, b, c ) {
48+
this.t = function( a, b, c ) {
4849
var f = jQuery(b).get(),
4950
s = "",
5051
i = 0;
@@ -54,9 +55,9 @@ function t( a, b, c ) {
5455
}
5556

5657
deepEqual(f, q.apply( q, c ), a + " (" + b + ")");
57-
}
58+
};
5859

59-
function createDashboardXML() {
60+
this.createDashboardXML = function() {
6061
var string = '<?xml version="1.0" encoding="UTF-8"?> \
6162
<dashboard> \
6263
<locations class="foo"> \
@@ -70,9 +71,9 @@ function createDashboardXML() {
7071
</dashboard>';
7172

7273
return jQuery.parseXML(string);
73-
}
74+
};
7475

75-
function createWithFriesXML() {
76+
this.createWithFriesXML = function() {
7677
var string = '<?xml version="1.0" encoding="UTF-8"?> \
7778
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" \
7879
xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
@@ -100,9 +101,9 @@ function createWithFriesXML() {
100101
</soap:Envelope>';
101102

102103
return jQuery.parseXML( string.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost ) );
103-
}
104+
};
104105

105-
function createXMLFragment() {
106+
this.createXMLFragment = function() {
106107
var xml, frag;
107108
if ( window.ActiveXObject ) {
108109
xml = new ActiveXObject("msxml2.domdocument");
@@ -115,7 +116,7 @@ function createXMLFragment() {
115116
}
116117

117118
return frag;
118-
}
119+
};
119120

120121
fireNative = document.createEvent ?
121122
function( node, type ) {
@@ -142,7 +143,7 @@ function url( value ) {
142143
}
143144

144145
// Ajax testing helper
145-
function ajaxTest( title, expect, options ) {
146+
this.ajaxTest = function( title, expect, options ) {
146147
var requestOptions;
147148
if ( jQuery.isFunction( options ) ) {
148149
options = options();
@@ -205,63 +206,59 @@ function ajaxTest( title, expect, options ) {
205206
}
206207
};
207208
});
208-
}
209+
};
209210

210-
(function () {
211-
212-
this.testIframe = function( fileName, name, fn ) {
213-
214-
test(name, function() {
215-
// pause execution for now
216-
stop();
217-
218-
// load fixture in iframe
219-
var iframe = loadFixture(),
220-
win = iframe.contentWindow,
221-
interval = setInterval( function() {
222-
if ( win && win.jQuery && win.jQuery.isReady ) {
223-
clearInterval( interval );
224-
// continue
225-
start();
226-
// call actual tests passing the correct jQuery instance to use
227-
fn.call( this, win.jQuery, win, win.document );
228-
document.body.removeChild( iframe );
229-
iframe = null;
230-
}
231-
}, 15 );
232-
});
233-
234-
function loadFixture() {
235-
var src = url("./data/" + fileName + ".html"),
236-
iframe = jQuery("<iframe />").appendTo("body")[0];
237-
iframe.style.cssText = "width: 500px; height: 500px; position: absolute; top: -600px; left: -600px; visibility: hidden;";
238-
iframe.contentWindow.location = src;
239-
return iframe;
240-
}
241-
};
242211

243-
this.testIframeWithCallback = function( title, fileName, func ) {
212+
this.testIframe = function( fileName, name, fn ) {
244213

245-
test( title, function() {
246-
var iframe;
214+
test(name, function() {
215+
// pause execution for now
216+
stop();
247217

248-
stop();
249-
window.iframeCallback = function() {
250-
var self = this,
251-
args = arguments;
252-
setTimeout(function() {
253-
window.iframeCallback = undefined;
254-
iframe.remove();
255-
func.apply( self, args );
256-
func = function() {};
218+
// load fixture in iframe
219+
var iframe = loadFixture(),
220+
win = iframe.contentWindow,
221+
interval = setInterval( function() {
222+
if ( win && win.jQuery && win.jQuery.isReady ) {
223+
clearInterval( interval );
224+
// continue
257225
start();
258-
}, 0 );
259-
};
260-
iframe = jQuery( "<div/>" ).append(
261-
jQuery( "<iframe/>" ).attr( "src", url( "./data/" + fileName ) )
262-
).appendTo( "body" );
263-
});
264-
};
226+
// call actual tests passing the correct jQuery instance to use
227+
fn.call( this, win.jQuery, win, win.document );
228+
document.body.removeChild( iframe );
229+
iframe = null;
230+
}
231+
}, 15 );
232+
});
265233

266-
window.iframeCallback = undefined;
267-
}());
234+
function loadFixture() {
235+
var src = url("./data/" + fileName + ".html"),
236+
iframe = jQuery("<iframe />").appendTo("body")[0];
237+
iframe.style.cssText = "width: 500px; height: 500px; position: absolute; top: -600px; left: -600px; visibility: hidden;";
238+
iframe.contentWindow.location = src;
239+
return iframe;
240+
}
241+
};
242+
243+
this.testIframeWithCallback = function( title, fileName, func ) {
244+
245+
test( title, function() {
246+
var iframe;
247+
248+
stop();
249+
window.iframeCallback = function() {
250+
var self = this,
251+
args = arguments;
252+
setTimeout(function() {
253+
window.iframeCallback = undefined;
254+
iframe.remove();
255+
func.apply( self, args );
256+
func = function() {};
257+
start();
258+
}, 0 );
259+
};
260+
iframe = jQuery( "<div/>" ).append(
261+
jQuery( "<iframe/>" ).attr( "src", url( "./data/" + fileName ) )
262+
).appendTo( "body" );
263+
});
264+
};

test/data/testrunner.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ jQuery.each( [ jQuery.expando, "getInterface", "Packages", "java", "netscape" ],
1010

1111
// Expose Sizzle for Sizzle's selector tests
1212
// We remove Sizzle's globalization in jQuery
13-
var Sizzle = Sizzle || jQuery.find;
13+
var Sizzle = Sizzle || jQuery.find,
1414

1515
// Allow subprojects to test against their own fixtures
16-
var qunitModule = QUnit.module,
16+
qunitModule = QUnit.module,
1717
qunitTest = QUnit.test;
1818

19-
function testSubproject( label, url, risTests ) {
19+
this.testSubproject = function( label, url, risTests ) {
2020
var sub, fixture, fixtureHTML,
2121
fixtureReplaced = false;
2222

@@ -132,11 +132,11 @@ function testSubproject( label, url, risTests ) {
132132
fn.apply( this, arguments );
133133
};
134134
}
135-
}
135+
};
136136

137137
// Register globals for cleanup and the cleanup code itself
138138
// Explanation at http://perfectionkills.com/understanding-delete/#ie_bugs
139-
var Globals = (function() {
139+
this.Globals = (function() {
140140
var globals = {};
141141
return {
142142
register: function( name ) {

0 commit comments

Comments
 (0)