diff options
author | Wonseop Kim <wonseop.kim@samsung.com> | 2020-05-05 17:49:27 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-05 10:49:27 +0200 |
commit | 3d62d5704989f17d3a20ae7521d52e9c8c60b4ee (patch) | |
tree | e65bc1fe0f602abb63c9de17f75ab85524a35f61 | |
parent | 11066a9e6ac183dd710d1bc7aa74a3f809757136 (diff) | |
download | jquery-3d62d5704989f17d3a20ae7521d52e9c8c60b4ee.tar.gz jquery-3d62d5704989f17d3a20ae7521d52e9c8c60b4ee.zip |
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
-rw-r--r-- | src/.eslintrc.json | 17 | ||||
-rw-r--r-- | src/ajax.js | 7 | ||||
-rw-r--r-- | src/ajax/xhr.js | 6 | ||||
-rw-r--r-- | src/attributes/classes.js | 6 | ||||
-rw-r--r-- | src/core.js | 8 | ||||
-rw-r--r-- | src/core/access.js | 4 | ||||
-rw-r--r-- | src/core/nodeName.js | 2 | ||||
-rw-r--r-- | src/css.js | 8 | ||||
-rw-r--r-- | src/deprecated/event.js | 6 | ||||
-rw-r--r-- | src/dimensions.js | 7 | ||||
-rw-r--r-- | src/effects.js | 5 | ||||
-rw-r--r-- | src/effects/Tween.js | 2 | ||||
-rw-r--r-- | src/event.js | 8 | ||||
-rw-r--r-- | src/event/trigger.js | 4 | ||||
-rw-r--r-- | src/selector.js | 6 | ||||
-rw-r--r-- | src/serialize.js | 6 |
16 files changed, 60 insertions, 42 deletions
diff --git a/src/.eslintrc.json b/src/.eslintrc.json index 4ac59e28b..0c1f3f8a7 100644 --- a/src/.eslintrc.json +++ b/src/.eslintrc.json @@ -12,7 +12,10 @@ "rules": { "import/extensions": [ "error", "always" ], - "import/no-cycle": "error" + "import/no-cycle": "error", + "indent": [ "error", "tab", { + "outerIIFEBody": 0 + } ] }, "overrides": [ @@ -23,7 +26,17 @@ "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, diff --git a/src/ajax.js b/src/ajax.js index 0563c924b..61079883e 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -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(), diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js index f6bd52337..2c9bc8125 100644 --- a/src/ajax/xhr.js +++ b/src/ajax/xhr.js @@ -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; diff --git a/src/attributes/classes.js b/src/attributes/classes.js index e020aa5cf..dcd8ad059 100644 --- a/src/attributes/classes.js +++ b/src/attributes/classes.js @@ -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; } } diff --git a/src/core.js b/src/core.js index d05d84888..ccc5389c5 100644 --- a/src/core.js +++ b/src/core.js @@ -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 ) { diff --git a/src/core/access.js b/src/core/access.js index 4eaec4695..6b717b9ba 100644 --- a/src/core/access.js +++ b/src/core/access.js @@ -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 ) ) ); } } diff --git a/src/core/nodeName.js b/src/core/nodeName.js index d10e484bc..7d38916b7 100644 --- a/src/core/nodeName.js +++ b/src/core/nodeName.js @@ -1,6 +1,6 @@ function nodeName( elem, name ) { - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); }; diff --git a/src/css.js b/src/css.js index 2bffa9610..8c4070c71 100644 --- a/src/css.js +++ b/src/css.js @@ -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 ); } }, diff --git a/src/deprecated/event.js b/src/deprecated/event.js index 7ad4492f0..84ff5bad0 100644 --- a/src/deprecated/event.js +++ b/src/deprecated/event.js @@ -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 ); }; - } ); + } +); diff --git a/src/dimensions.js b/src/dimensions.js index 6f1bf7d2f..42e445362 100644 --- a/src/dimensions.js +++ b/src/dimensions.js @@ -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 ) { diff --git a/src/effects.js b/src/effects.js index 030d3c7ba..f94da06a9 100644 --- a/src/effects.js +++ b/src/effects.js @@ -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 ) : diff --git a/src/effects/Tween.js b/src/effects/Tween.js index 9a75a9af2..c0220bd10 100644 --- a/src/effects/Tween.js +++ b/src/effects/Tween.js @@ -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 { diff --git a/src/event.js b/src/event.js index c7812508b..96056a138 100644 --- a/src/event.js +++ b/src/event.js @@ -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 ]; } }, diff --git a/src/event/trigger.js b/src/event/trigger.js index 0d1cd4c56..f36000af7 100644 --- a/src/event/trigger.js +++ b/src/event/trigger.js @@ -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 ); diff --git a/src/selector.js b/src/selector.js index 66abe7935..0d80c6fd3 100644 --- a/src/selector.js +++ b/src/selector.js @@ -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 ); }; diff --git a/src/serialize.js b/src/serialize.js index a25097edc..ebe733450 100644 --- a/src/serialize.js +++ b/src/serialize.js @@ -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 ) { |