Skip to content

Commit dfed21e

Browse files
committed
Correct code indentations
1. Correct code indentations based on Core Style Guide (https://contribute.jquery.org/style-guide/js/#spacing) 2. Add rules to `src/.eslintrc.json` to enable 'enforcing consistent indentation', with minimal changes to the current code.
1 parent 7fb90a6 commit dfed21e

File tree

16 files changed

+80
-69
lines changed

16 files changed

+80
-69
lines changed

src/.eslintrc.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212

1313
"rules": {
1414
"import/extensions": [ "error", "always" ],
15-
"import/no-cycle": "error"
15+
"import/no-cycle": "error",
16+
"indent": [ "error", "tab", {
17+
"MemberExpression": 1,
18+
"outerIIFEBody": 0
19+
} ]
1620
},
1721

1822
"overrides": [
@@ -23,7 +27,10 @@
2327
"sourceType": "script"
2428
},
2529
"rules": {
26-
"no-unused-vars": "off"
30+
"no-unused-vars": "off",
31+
"indent": [ "error", "tab", {
32+
"ignoredNodes": [ "Program > ExpressionStatement > CallExpression > FunctionExpression > *" ]
33+
} ]
2734
},
2835
"globals": {
2936
"jQuery": false,

src/ajax.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ var
4545

4646
// Anchor tag for parsing the document origin
4747
originAnchor = document.createElement( "a" );
48-
originAnchor.href = location.href;
48+
49+
originAnchor.href = location.href;
4950

5051
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
5152
function addToPrefiltersOrTransports( structure ) {
@@ -426,8 +427,8 @@ jQuery.extend( {
426427
// Context for global events is callbackContext if it is a DOM node or jQuery collection
427428
globalEventContext = s.context &&
428429
( callbackContext.nodeType || callbackContext.jquery ) ?
429-
jQuery( callbackContext ) :
430-
jQuery.event,
430+
jQuery( callbackContext ) :
431+
jQuery.event,
431432

432433
// Deferreds
433434
deferred = jQuery.Deferred(),

src/ajax/xhr.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jQuery.ajaxSettings.xhr = function() {
88

99
var xhrSuccessStatus = {
1010

11-
// File protocol always yields status code 0, assume 200
12-
0: 200
13-
};
11+
// File protocol always yields status code 0, assume 200
12+
0: 200
13+
};
1414

1515
jQuery.ajaxTransport( function( options ) {
1616
var callback;

src/attributes/classes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ jQuery.fn.extend( {
155155
if ( this.setAttribute ) {
156156
this.setAttribute( "class",
157157
className || value === false ?
158-
"" :
159-
dataPriv.get( this, "__className__" ) || ""
158+
"" :
159+
dataPriv.get( this, "__className__" ) || ""
160160
);
161161
}
162162
}
@@ -171,7 +171,7 @@ jQuery.fn.extend( {
171171
while ( ( elem = this[ i++ ] ) ) {
172172
if ( elem.nodeType === 1 &&
173173
( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
174-
return true;
174+
return true;
175175
}
176176
}
177177

src/core.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ jQuery.extend( {
305305
if ( isArrayLike( Object( arr ) ) ) {
306306
jQuery.merge( ret,
307307
typeof arr === "string" ?
308-
[ arr ] : arr
308+
[ arr ] : arr
309309
);
310310
} else {
311311
push.call( ret, arr );
@@ -407,9 +407,9 @@ if ( typeof Symbol === "function" ) {
407407

408408
// Populate the class2type map
409409
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
410-
function( _i, name ) {
411-
class2type[ "[object " + name + "]" ] = name.toLowerCase();
412-
} );
410+
function( _i, name ) {
411+
class2type[ "[object " + name + "]" ] = name.toLowerCase();
412+
} );
413413

414414
function isArrayLike( obj ) {
415415

src/core/access.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
4343
for ( ; i < len; i++ ) {
4444
fn(
4545
elems[ i ], key, raw ?
46-
value :
47-
value.call( elems[ i ], i, fn( elems[ i ], key ) )
46+
value :
47+
value.call( elems[ i ], i, fn( elems[ i ], key ) )
4848
);
4949
}
5050
}

src/core/nodeName.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function nodeName( elem, name ) {
22

3-
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
3+
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
44

55
};
66

src/css.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ jQuery.each( [ "height", "width" ], function( _i, dimension ) {
320320
// Running getBoundingClientRect on a disconnected node
321321
// in IE throws an error.
322322
( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
323-
swap( elem, cssShow, function() {
324-
return getWidthOrHeight( elem, dimension, extra );
325-
} ) :
326-
getWidthOrHeight( elem, dimension, extra );
323+
swap( elem, cssShow, function() {
324+
return getWidthOrHeight( elem, dimension, extra );
325+
} ) :
326+
getWidthOrHeight( elem, dimension, extra );
327327
}
328328
},
329329

src/deprecated/event.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ jQuery.fn.extend( {
3030

3131
jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
3232
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
33-
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
34-
function( _i, name ) {
35-
36-
// Handle event binding
37-
jQuery.fn[ name ] = function( data, fn ) {
38-
return arguments.length > 0 ?
39-
this.on( name, null, data, fn ) :
40-
this.trigger( name );
41-
};
42-
} );
33+
"change select submit keydown keypress keyup contextmenu" ).split( " " ), function( _i, name ) {
34+
35+
// Handle event binding
36+
jQuery.fn[ name ] = function( data, fn ) {
37+
return arguments.length > 0 ?
38+
this.on( name, null, data, fn ) :
39+
this.trigger( name );
40+
};
41+
} );

src/dimensions.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import "./css.js";
66

77
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
88
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9-
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
10-
function( defaultExtra, funcName ) {
9+
jQuery.each( {
10+
padding: "inner" + name,
11+
content: type,
12+
"": "outer" + name
13+
}, function( defaultExtra, funcName ) {
1114

1215
// Margin is only for outerHeight, outerWidth
1316
jQuery.fn[ funcName ] = function( margin, value ) {

0 commit comments

Comments
 (0)