]> source.dussan.org Git - jquery.git/commitdiff
Build: Correct code indentations based on jQuery Style Guide
authorWonseop Kim <wonseop.kim@samsung.com>
Tue, 5 May 2020 08:49:27 +0000 (17:49 +0900)
committerGitHub <noreply@github.com>
Tue, 5 May 2020 08:49:27 +0000 (10:49 +0200)
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

16 files changed:
src/.eslintrc.json
src/ajax.js
src/ajax/xhr.js
src/attributes/classes.js
src/core.js
src/core/access.js
src/core/nodeName.js
src/css.js
src/deprecated/event.js
src/dimensions.js
src/effects.js
src/effects/Tween.js
src/event.js
src/event/trigger.js
src/selector.js
src/serialize.js

index 4ac59e28b6992e12c6a253baf40f248bca2950d6..0c1f3f8a789c43468afe4f26eddd853a612847b8 100644 (file)
 
        "rules": {
                "import/extensions": [ "error", "always" ],
-               "import/no-cycle": "error"
+               "import/no-cycle": "error",
+               "indent": [ "error", "tab", {
+                       "outerIIFEBody": 0
+               } ]
        },
 
        "overrides": [
                                "sourceType": "script"
                        },
                        "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": {
                                "jQuery": false,
index 0563c924b5009ef155ab56473ff0f8fb66a4203f..61079883ed0ccc3ba36b5ee1a6c4b8c9b0a1271d 100644 (file)
@@ -45,7 +45,8 @@ var
 
        // Anchor tag for parsing the document origin
        originAnchor = document.createElement( "a" );
-       originAnchor.href = location.href;
+
+originAnchor.href = location.href;
 
 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
 function addToPrefiltersOrTransports( structure ) {
@@ -426,8 +427,8 @@ jQuery.extend( {
                        // Context for global events is callbackContext if it is a DOM node or jQuery collection
                        globalEventContext = s.context &&
                                ( callbackContext.nodeType || callbackContext.jquery ) ?
-                                       jQuery( callbackContext ) :
-                                       jQuery.event,
+                               jQuery( callbackContext ) :
+                               jQuery.event,
 
                        // Deferreds
                        deferred = jQuery.Deferred(),
index f6bd52337fc6edf96e799904f6fab4177b39fa98..2c9bc81258866e1625d16532d66082ca48deebd9 100644 (file)
@@ -8,9 +8,9 @@ jQuery.ajaxSettings.xhr = function() {
 
 var xhrSuccessStatus = {
 
-               // File protocol always yields status code 0, assume 200
-               0: 200
-       };
+       // File protocol always yields status code 0, assume 200
+       0: 200
+};
 
 jQuery.ajaxTransport( function( options ) {
        var callback;
index e020aa5cfc0cf1d00941548b206869d8c260992a..dcd8ad05974335754bea841ded58547e17f73c74 100644 (file)
@@ -155,8 +155,8 @@ jQuery.fn.extend( {
                                if ( this.setAttribute ) {
                                        this.setAttribute( "class",
                                                className || value === false ?
-                                               "" :
-                                               dataPriv.get( this, "__className__" ) || ""
+                                                       "" :
+                                                       dataPriv.get( this, "__className__" ) || ""
                                        );
                                }
                        }
@@ -171,7 +171,7 @@ jQuery.fn.extend( {
                while ( ( elem = this[ i++ ] ) ) {
                        if ( elem.nodeType === 1 &&
                                ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
-                                       return true;
+                               return true;
                        }
                }
 
index d05d8488854717abc5d34e8ac15ebee12df6ca85..ccc5389c53591ec0332927c9e337701e3e2a4537 100644 (file)
@@ -303,7 +303,7 @@ jQuery.extend( {
                        if ( isArrayLike( Object( arr ) ) ) {
                                jQuery.merge( ret,
                                        typeof arr === "string" ?
-                                       [ arr ] : arr
+                                               [ arr ] : arr
                                );
                        } else {
                                push.call( ret, arr );
@@ -405,9 +405,9 @@ if ( typeof Symbol === "function" ) {
 
 // Populate the class2type map
 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
-function( _i, name ) {
-       class2type[ "[object " + name + "]" ] = name.toLowerCase();
-} );
+       function( _i, name ) {
+               class2type[ "[object " + name + "]" ] = name.toLowerCase();
+       } );
 
 function isArrayLike( obj ) {
 
index 4eaec46957dfd2f6a38b052778c99051c0821819..6b717b9ba4b96945c8c4b3755d914d1837e53681 100644 (file)
@@ -43,8 +43,8 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
                        for ( ; i < len; i++ ) {
                                fn(
                                        elems[ i ], key, raw ?
-                                       value :
-                                       value.call( elems[ i ], i, fn( elems[ i ], key ) )
+                                               value :
+                                               value.call( elems[ i ], i, fn( elems[ i ], key ) )
                                );
                        }
                }
index d10e484bc779d3e5d1d42bed2416a6d79248776e..7d38916b76da4b8236a18c3d1098d61089fd86de 100644 (file)
@@ -1,6 +1,6 @@
 function nodeName( elem, name ) {
 
-  return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+       return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
 
 };
 
index 2bffa9610c0e356c1e00f2962626aefc84654b4a..8c4070c71d1deb88b847f0e07f47566f4bd78079 100644 (file)
@@ -320,10 +320,10 @@ jQuery.each( [ "height", "width" ], function( _i, dimension ) {
                                        // Running getBoundingClientRect on a disconnected node
                                        // in IE throws an error.
                                        ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
-                                               swap( elem, cssShow, function() {
-                                                       return getWidthOrHeight( elem, dimension, extra );
-                                               } ) :
-                                               getWidthOrHeight( elem, dimension, extra );
+                                       swap( elem, cssShow, function() {
+                                               return getWidthOrHeight( elem, dimension, extra );
+                                       } ) :
+                                       getWidthOrHeight( elem, dimension, extra );
                        }
                },
 
index 7ad4492f0e8a53d4f747d8dfc592e10d3b139aac..84ff5bad00c52af517570f039bbd728f8d3b292c 100644 (file)
@@ -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 " +
        "change select submit keydown keypress keyup contextmenu" ).split( " " ),
        function( _i, name ) {
@@ -39,4 +40,5 @@ jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
                                this.on( name, null, data, fn ) :
                                this.trigger( name );
                };
-       } );
+       }
+);
index 6f1bf7d2f558b78cdf59998326010ff894b98116..42e445362bb5295722d7efae196e933a2f38a32f 100644 (file)
@@ -6,8 +6,11 @@ import "./css.js";
 
 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
-       jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
-               function( defaultExtra, funcName ) {
+       jQuery.each( {
+               padding: "inner" + name,
+               content: type,
+               "": "outer" + name
+       }, function( defaultExtra, funcName ) {
 
                // Margin is only for outerHeight, outerWidth
                jQuery.fn[ funcName ] = function( margin, value ) {
index 030d3c7ba0717e9773d4cc3739dbb4fcfb416582..f94da06a95f58c9d601d6c06689be8c7c911639a 100644 (file)
@@ -338,7 +338,7 @@ function Animation( elem, properties, options ) {
                        tweens: [],
                        createTween: function( prop, end ) {
                                var tween = jQuery.Tween( elem, animation.opts, prop, end,
-                                               animation.opts.specialEasing[ prop ] || animation.opts.easing );
+                                       animation.opts.specialEasing[ prop ] || animation.opts.easing );
                                animation.tweens.push( tween );
                                return tween;
                        },
@@ -511,7 +511,8 @@ jQuery.fn.extend( {
                                        anim.stop( true );
                                }
                        };
-                       doAnimation.finish = doAnimation;
+
+               doAnimation.finish = doAnimation;
 
                return empty || optall.queue === false ?
                        this.each( doAnimation ) :
index 9a75a9af2760650df269faa7e1fe0a182b77bb39..c0220bd10b639f10f3e24e4c8d57cc0fcc17169d 100644 (file)
@@ -84,7 +84,7 @@ Tween.propHooks = {
                        if ( jQuery.fx.step[ tween.prop ] ) {
                                jQuery.fx.step[ tween.prop ]( tween );
                        } else if ( tween.elem.nodeType === 1 && (
-                                       jQuery.cssHooks[ tween.prop ] ||
+                               jQuery.cssHooks[ tween.prop ] ||
                                        tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
                                jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
                        } else {
index c7812508bf822c2379b84b24958aa22f3e129395..96056a13815f6b1710221fcf678a581a2fee007a 100644 (file)
@@ -295,8 +295,8 @@ jQuery.event = {
                        event = jQuery.event.fix( nativeEvent ),
 
                        handlers = (
-                                       dataPriv.get( this, "events" ) || Object.create( null )
-                               )[ event.type ] || [],
+                               dataPriv.get( this, "events" ) || Object.create( null )
+                       )[ event.type ] || [],
                        special = jQuery.event.special[ event.type ] || {};
 
                // Use the fix-ed jQuery.Event rather than the (read-only) native event
@@ -416,12 +416,12 @@ jQuery.event = {
                        get: typeof hook === "function" ?
                                function() {
                                        if ( this.originalEvent ) {
-                                                       return hook( this.originalEvent );
+                                               return hook( this.originalEvent );
                                        }
                                } :
                                function() {
                                        if ( this.originalEvent ) {
-                                                       return this.originalEvent[ name ];
+                                               return this.originalEvent[ name ];
                                        }
                                },
 
index 0d1cd4c56c3df5d3fd831ea038b65c0465dac1de..f36000af78c80cdcd98a301dc17b4e91015a9361 100644 (file)
@@ -99,9 +99,7 @@ jQuery.extend( jQuery.event, {
                                special.bindType || type;
 
                        // jQuery handler
-                       handle = (
-                                       dataPriv.get( cur, "events" ) || Object.create( null )
-                               )[ event.type ] &&
+                       handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
                                dataPriv.get( cur, "handle" );
                        if ( handle ) {
                                handle.apply( cur, data );
index 66abe793514a86d8c8dd8a3d35af847079379a3c..0d80c6fd3699470e7f466f8138e774bc7997fe06 100644 (file)
@@ -602,9 +602,11 @@ Expr = jQuery.expr = {
                TAG: function( nodeNameSelector ) {
                        var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
                        return nodeNameSelector === "*" ?
+
                                function() {
- return true;
-} :
+                                       return true;
+                               } :
+
                                function( elem ) {
                                        return nodeName( elem, expectedNodeName );
                                };
index a25097edcf128b80663096fb8e6c738b721aa9ba..ebe73345011ba730f0c8d80dcf6b157220833aa0 100644 (file)
@@ -101,16 +101,14 @@ jQuery.fn.extend( {
                        // Can add propHook for "elements" to filter or add form elements
                        var elements = jQuery.prop( this, "elements" );
                        return elements ? jQuery.makeArray( elements ) : this;
-               } )
-               .filter( function() {
+               } ).filter( function() {
                        var type = this.type;
 
                        // Use .is( ":disabled" ) so that fieldset[disabled] works
                        return this.name && !jQuery( this ).is( ":disabled" ) &&
                                rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
                                ( this.checked || !rcheckableType.test( type ) );
-               } )
-               .map( function( _i, elem ) {
+               } ).map( function( _i, elem ) {
                        var val = jQuery( this ).val();
 
                        if ( val == null ) {