mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Build: Correct code indentations based on jQuery Style Guide
1. Correct code indentations based on jQuery Style Guide (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. Closes gh-4672
This commit is contained in:
parent
11066a9e6a
commit
3d62d57049
@ -12,7 +12,10 @@
|
|||||||
|
|
||||||
"rules": {
|
"rules": {
|
||||||
"import/extensions": [ "error", "always" ],
|
"import/extensions": [ "error", "always" ],
|
||||||
"import/no-cycle": "error"
|
"import/no-cycle": "error",
|
||||||
|
"indent": [ "error", "tab", {
|
||||||
|
"outerIIFEBody": 0
|
||||||
|
} ]
|
||||||
},
|
},
|
||||||
|
|
||||||
"overrides": [
|
"overrides": [
|
||||||
@ -23,7 +26,17 @@
|
|||||||
"sourceType": "script"
|
"sourceType": "script"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-unused-vars": "off"
|
"no-unused-vars": "off",
|
||||||
|
"indent": [ "error", "tab", {
|
||||||
|
|
||||||
|
// Unlike other codes, "wrapper.js" is implemented in UMD.
|
||||||
|
// So it required a specific exception for jQuery's UMD
|
||||||
|
// Code Style. This makes that indentation check is not
|
||||||
|
// performed for 1 depth of outer FunctionExpressions
|
||||||
|
"ignoredNodes": [
|
||||||
|
"Program > ExpressionStatement > CallExpression > FunctionExpression > *"
|
||||||
|
]
|
||||||
|
} ]
|
||||||
},
|
},
|
||||||
"globals": {
|
"globals": {
|
||||||
"jQuery": false,
|
"jQuery": false,
|
||||||
|
@ -45,7 +45,8 @@ var
|
|||||||
|
|
||||||
// Anchor tag for parsing the document origin
|
// Anchor tag for parsing the document origin
|
||||||
originAnchor = document.createElement( "a" );
|
originAnchor = document.createElement( "a" );
|
||||||
originAnchor.href = location.href;
|
|
||||||
|
originAnchor.href = location.href;
|
||||||
|
|
||||||
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
||||||
function addToPrefiltersOrTransports( structure ) {
|
function addToPrefiltersOrTransports( structure ) {
|
||||||
|
@ -10,7 +10,7 @@ var xhrSuccessStatus = {
|
|||||||
|
|
||||||
// File protocol always yields status code 0, assume 200
|
// File protocol always yields status code 0, assume 200
|
||||||
0: 200
|
0: 200
|
||||||
};
|
};
|
||||||
|
|
||||||
jQuery.ajaxTransport( function( options ) {
|
jQuery.ajaxTransport( function( options ) {
|
||||||
var callback;
|
var callback;
|
||||||
|
@ -405,9 +405,9 @@ if ( typeof Symbol === "function" ) {
|
|||||||
|
|
||||||
// Populate the class2type map
|
// Populate the class2type map
|
||||||
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
|
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
|
||||||
function( _i, name ) {
|
function( _i, name ) {
|
||||||
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
function isArrayLike( obj ) {
|
function isArrayLike( obj ) {
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ jQuery.fn.extend( {
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
|
jQuery.each(
|
||||||
|
( "blur focus focusin focusout resize scroll click dblclick " +
|
||||||
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
||||||
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
|
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
|
||||||
function( _i, name ) {
|
function( _i, name ) {
|
||||||
@ -39,4 +40,5 @@ jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
|
|||||||
this.on( name, null, data, fn ) :
|
this.on( name, null, data, fn ) :
|
||||||
this.trigger( name );
|
this.trigger( name );
|
||||||
};
|
};
|
||||||
} );
|
}
|
||||||
|
);
|
||||||
|
@ -6,8 +6,11 @@ import "./css.js";
|
|||||||
|
|
||||||
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
||||||
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
||||||
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
|
jQuery.each( {
|
||||||
function( defaultExtra, funcName ) {
|
padding: "inner" + name,
|
||||||
|
content: type,
|
||||||
|
"": "outer" + name
|
||||||
|
}, function( defaultExtra, funcName ) {
|
||||||
|
|
||||||
// Margin is only for outerHeight, outerWidth
|
// Margin is only for outerHeight, outerWidth
|
||||||
jQuery.fn[ funcName ] = function( margin, value ) {
|
jQuery.fn[ funcName ] = function( margin, value ) {
|
||||||
|
1
src/effects.js
vendored
1
src/effects.js
vendored
@ -511,6 +511,7 @@ jQuery.fn.extend( {
|
|||||||
anim.stop( true );
|
anim.stop( true );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
doAnimation.finish = doAnimation;
|
doAnimation.finish = doAnimation;
|
||||||
|
|
||||||
return empty || optall.queue === false ?
|
return empty || optall.queue === false ?
|
||||||
|
@ -99,9 +99,7 @@ jQuery.extend( jQuery.event, {
|
|||||||
special.bindType || type;
|
special.bindType || type;
|
||||||
|
|
||||||
// jQuery handler
|
// jQuery handler
|
||||||
handle = (
|
handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
|
||||||
dataPriv.get( cur, "events" ) || Object.create( null )
|
|
||||||
)[ event.type ] &&
|
|
||||||
dataPriv.get( cur, "handle" );
|
dataPriv.get( cur, "handle" );
|
||||||
if ( handle ) {
|
if ( handle ) {
|
||||||
handle.apply( cur, data );
|
handle.apply( cur, data );
|
||||||
|
@ -602,9 +602,11 @@ Expr = jQuery.expr = {
|
|||||||
TAG: function( nodeNameSelector ) {
|
TAG: function( nodeNameSelector ) {
|
||||||
var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
|
var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
|
||||||
return nodeNameSelector === "*" ?
|
return nodeNameSelector === "*" ?
|
||||||
|
|
||||||
function() {
|
function() {
|
||||||
return true;
|
return true;
|
||||||
} :
|
} :
|
||||||
|
|
||||||
function( elem ) {
|
function( elem ) {
|
||||||
return nodeName( elem, expectedNodeName );
|
return nodeName( elem, expectedNodeName );
|
||||||
};
|
};
|
||||||
|
@ -101,16 +101,14 @@ jQuery.fn.extend( {
|
|||||||
// Can add propHook for "elements" to filter or add form elements
|
// Can add propHook for "elements" to filter or add form elements
|
||||||
var elements = jQuery.prop( this, "elements" );
|
var elements = jQuery.prop( this, "elements" );
|
||||||
return elements ? jQuery.makeArray( elements ) : this;
|
return elements ? jQuery.makeArray( elements ) : this;
|
||||||
} )
|
} ).filter( function() {
|
||||||
.filter( function() {
|
|
||||||
var type = this.type;
|
var type = this.type;
|
||||||
|
|
||||||
// Use .is( ":disabled" ) so that fieldset[disabled] works
|
// Use .is( ":disabled" ) so that fieldset[disabled] works
|
||||||
return this.name && !jQuery( this ).is( ":disabled" ) &&
|
return this.name && !jQuery( this ).is( ":disabled" ) &&
|
||||||
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
|
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
|
||||||
( this.checked || !rcheckableType.test( type ) );
|
( this.checked || !rcheckableType.test( type ) );
|
||||||
} )
|
} ).map( function( _i, elem ) {
|
||||||
.map( function( _i, elem ) {
|
|
||||||
var val = jQuery( this ).val();
|
var val = jQuery( this ).val();
|
||||||
|
|
||||||
if ( val == null ) {
|
if ( val == null ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user