]> source.dussan.org Git - jquery.git/commitdiff
Build: Update eslint config and fix associated errors
authorOleg Gaidarenko <markelog@gmail.com>
Fri, 15 Jul 2016 17:42:25 +0000 (21:42 +0400)
committerGitHub <noreply@github.com>
Fri, 15 Jul 2016 17:42:25 +0000 (21:42 +0400)
15 files changed:
.eslintrc
dist/.eslintrc
package.json
src/attributes/prop.js
src/attributes/val.js
src/core.js
src/core/access.js
src/css.js
src/data.js
src/effects.js
src/event.js
src/manipulation/getAll.js
src/serialize.js
src/traversing/findFilter.js
test/.eslintrc

index bbf96f80912e92d3113ff7b8f2d69f34ec2cc7ac..6dcb6353a48f180fc77fd2b3233b83959fa6aa7d 100644 (file)
--- a/.eslintrc
+++ b/.eslintrc
@@ -3,9 +3,5 @@
        "root": true,
        "env": {
                "node": true
-       },
-       rules: {
-               // Until https://github.com/jquery/eslint-config-jquery/issues/7 is resolved
-               "no-unused-expressions": "error"
        }
 }
index 22a970f8ae319e8440c6eaff71827daf9c44eaa6..d21ae4d16bb384748b3510a103e69212cd260d9a 100644 (file)
@@ -5,6 +5,7 @@
                "no-multiple-empty-lines": "off",
 
                // Because sizze is not compatible to jquery code style
+               "no-nested-ternary": "off",
                "no-unused-expressions": "off",
                "lines-around-comment": "off",
                "space-in-parens": "off",
index 6ef29dc0e4548d7375768ca2a56f898c936b0fb9..c5cdc6a3c42edd00aeb16940c4b81204d1a9cf71 100644 (file)
@@ -29,7 +29,7 @@
     "commitplease": "2.3.1",
     "core-js": "2.2.2",
     "cross-spawn": "2.2.3",
-    "eslint-config-jquery": "0.1.6",
+    "eslint-config-jquery": "1.0.0",
     "grunt": "1.0.1",
     "grunt-babel": "6.0.0",
     "grunt-cli": "1.2.0",
index b69177adfb07640d3aa83b1b07d124c248083b54..49ac244dfdfd8ffc1c648141558e4982628e658b 100644 (file)
@@ -66,12 +66,19 @@ jQuery.extend( {
                                // Use proper attribute retrieval(#12072)
                                var tabindex = jQuery.find.attr( elem, "tabindex" );
 
-                               return tabindex ?
-                                       parseInt( tabindex, 10 ) :
+                               if ( tabindex ) {
+                                       return parseInt( tabindex, 10 );
+                               }
+
+                               if (
                                        rfocusable.test( elem.nodeName ) ||
-                                               rclickable.test( elem.nodeName ) && elem.href ?
-                                                       0 :
-                                                       -1;
+                                       rclickable.test( elem.nodeName ) &&
+                                       elem.href
+                               ) {
+                                       return 0;
+                               }
+
+                               return -1;
                        }
                }
        },
index 1ba42a5c8ae40b97fc003e8eff754600760ffa64..e23aa9a21dc24c99b173f7afedb2240b1d289ca0 100644 (file)
@@ -28,13 +28,13 @@ jQuery.fn.extend( {
 
                                ret = elem.value;
 
-                               return typeof ret === "string" ?
-
-                                       // Handle most common string cases
-                                       ret.replace( rreturn, "" ) :
+                               // Handle most common string cases
+                               if ( typeof ret === "string" ) {
+                                       return ret.replace( rreturn, "" );
+                               }
 
-                                       // Handle cases where value is null/undef or number
-                                       ret == null ? "" : ret;
+                               // Handle cases where value is null/undef or number
+                               return ret == null ? "" : ret;
                        }
 
                        return;
@@ -96,15 +96,19 @@ jQuery.extend( {
                },
                select: {
                        get: function( elem ) {
-                               var value, option,
+                               var value, option, i,
                                        options = elem.options,
                                        index = elem.selectedIndex,
                                        one = elem.type === "select-one",
                                        values = one ? null : [],
-                                       max = one ? index + 1 : options.length,
-                                       i = index < 0 ?
-                                               max :
-                                               one ? index : 0;
+                                       max = one ? index + 1 : options.length;
+
+                               if ( index < 0 ) {
+                                       i = max;
+
+                               } else {
+                                       i = one ? index : 0;
+                               }
 
                                // Loop through all the selected options
                                for ( ; i < max; i++ ) {
index 5bdb2169cea8c0b3a581a2997429012e14b95f13..68ba9a5c24d18c9f70ed14efbcaacabf07139c4d 100644 (file)
@@ -64,13 +64,14 @@ jQuery.fn = jQuery.prototype = {
        // Get the Nth element in the matched element set OR
        // Get the whole matched element set as a clean array
        get: function( num ) {
-               return num != null ?
 
-                       // Return just the one element from the set
-                       ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
+               // Return all the elements in a clean array
+               if ( num == null ) {
+                       return slice.call( this );
+               }
 
-                       // Return all the elements in a clean array
-                       slice.call( this );
+               // Return just the one element from the set
+               return num < 0 ? this[ num + this.length ] : this[ num ];
        },
 
        // Take an array of elements and push it onto the stack
index 735c75711c2480430186362f854892abaf266671..86cdbc7e68e4a5c1a47e865849232609ea3ffece 100644 (file)
@@ -53,13 +53,16 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
                }
        }
 
-       return chainable ?
-               elems :
+       if ( chainable ) {
+               return elems;
+       }
+
+       // Gets
+       if ( bulk ) {
+               return fn.call( elems );
+       }
 
-               // Gets
-               bulk ?
-                       fn.call( elems ) :
-                       len ? fn( elems[ 0 ], key ) : emptyGet;
+       return len ? fn( elems[ 0 ], key ) : emptyGet;
 };
 
 return access;
index 795ca2796daf181415f0ede1b4b15e697bad0db1..5e445119396c99be2c3e6aa892b35c4944fe0806 100644 (file)
@@ -70,15 +70,17 @@ function setPositiveNumber( elem, value, subtract ) {
 }
 
 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
-       var i = extra === ( isBorderBox ? "border" : "content" ) ?
-
-               // If we already have the right measurement, avoid augmentation
-               4 :
+       var i,
+               val = 0;
 
-               // Otherwise initialize for horizontal or vertical properties
-               name === "width" ? 1 : 0,
+       // If we already have the right measurement, avoid augmentation
+       if ( extra === ( isBorderBox ? "border" : "content" ) ) {
+               i = 4;
 
-               val = 0;
+       // Otherwise initialize for horizontal or vertical properties
+       } else {
+               i = name === "width" ? 1 : 0;
+       }
 
        for ( ; i < 4; i += 2 ) {
 
index 49964f7d516651db22ff0661da9072481426ef45..087ce4eb72b3cdf8c9d34f81bacce4334dc570d7 100644 (file)
@@ -20,6 +20,31 @@ define( [
 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
        rmultiDash = /[A-Z]/g;
 
+function getData( data ) {
+       if ( data === "true" ) {
+               return true;
+       }
+
+       if ( data === "false" ) {
+               return false;
+       }
+
+       if ( data === "null" ) {
+               return null;
+       }
+
+       // Only convert to a number if it doesn't change the string
+       if ( data === +data + "" ) {
+               return +data;
+       }
+
+       if ( rbrace.test( data ) ) {
+               return JSON.parse( data );
+       }
+
+       return data;
+}
+
 function dataAttr( elem, key, data ) {
        var name;
 
@@ -31,14 +56,7 @@ function dataAttr( elem, key, data ) {
 
                if ( typeof data === "string" ) {
                        try {
-                               data = data === "true" ? true :
-                                       data === "false" ? false :
-                                       data === "null" ? null :
-
-                                       // Only convert to a number if it doesn't change the string
-                                       +data + "" === data ? +data :
-                                       rbrace.test( data ) ? JSON.parse( data ) :
-                                       data;
+                               data = getData( data );
                        } catch ( e ) {}
 
                        // Make sure we set the data so it isn't changed later
index cc21cfcfa8e7cdaee56b9db14124d232fd131467..287ecfde167a4a214dec856109d4578cbec4082e 100644 (file)
@@ -453,9 +453,14 @@ jQuery.speed = function( speed, easing, fn ) {
                opt.duration = 0;
 
        } else {
-               opt.duration = typeof opt.duration === "number" ?
-                       opt.duration : opt.duration in jQuery.fx.speeds ?
-                               jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
+               if ( typeof opt.duration !== "number" ) {
+                       if ( opt.duration in jQuery.fx.speeds ) {
+                               opt.duration = jQuery.fx.speeds[ opt.duration ];
+
+                       } else {
+                               opt.duration = jQuery.fx.speeds._default;
+                       }
+               }
        }
 
        // Normalize opt.queue - true/undefined/null -> "fx"
index cf10953f00262293676940437215bcb83608b2d1..b3fa59de562a15fc30872f697e08fe594d5d2cd2 100644 (file)
@@ -633,7 +633,19 @@ jQuery.each( {
 
                // Add which for click: 1 === left; 2 === middle; 3 === right
                if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
-                       return ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
+                       if ( button & 1 ) {
+                               return 1;
+                       }
+
+                       if ( button & 2 ) {
+                               return 3;
+                       }
+
+                       if ( button & 4 ) {
+                               return 2;
+                       }
+
+                       return 0;
                }
 
                return event.which;
index 85490d50e7dd37569ab18f270f99236a35153bac..f68e3219e0285dd3013432f8c5e312a3a18153dd 100644 (file)
@@ -8,15 +8,23 @@ function getAll( context, tag ) {
 
        // Support: IE <=9 - 11 only
        // Use typeof to avoid zero-argument method invocation on host objects (#15151)
-       var ret = typeof context.getElementsByTagName !== "undefined" ?
-                       context.getElementsByTagName( tag || "*" ) :
-                       typeof context.querySelectorAll !== "undefined" ?
-                               context.querySelectorAll( tag || "*" ) :
-                       [];
-
-       return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
-               jQuery.merge( [ context ], ret ) :
-               ret;
+       var ret;
+
+       if ( typeof context.getElementsByTagName !== "undefined" ) {
+               ret = context.getElementsByTagName( tag || "*" );
+
+       } else if ( typeof context.querySelectorAll !== "undefined" ) {
+               ret = context.querySelectorAll( tag || "*" );
+
+       } else {
+               ret = [];
+       }
+
+       if ( tag === undefined || tag && jQuery.nodeName( context, tag ) ) {
+               return jQuery.merge( [ context ], ret );
+       }
+
+       return ret;
 }
 
 return getAll;
index 60d9362519497f70b97414c5919ba7df34fdc961..35dcf04f9b22bfa2cc2b182ef7608de3db4cebe9 100644 (file)
@@ -111,13 +111,17 @@ jQuery.fn.extend( {
                .map( function( i, elem ) {
                        var val = jQuery( this ).val();
 
-                       return val == null ?
-                               null :
-                               jQuery.isArray( val ) ?
-                                       jQuery.map( val, function( val ) {
-                                               return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
-                                       } ) :
-                                       { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+                       if ( val == null ) {
+                               return null;
+                       }
+
+                       if ( jQuery.isArray( val ) ) {
+                               return jQuery.map( val, function( val ) {
+                                       return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+                               } );
+                       }
+
+                       return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
                } ).get();
        }
 } );
index c742fb5c317a3a68b5bbdc3336578714647f66c0..92d6753b4e8761c4970ae5a848f44414376cf752 100644 (file)
@@ -45,11 +45,13 @@ jQuery.filter = function( expr, elems, not ) {
                expr = ":not(" + expr + ")";
        }
 
-       return elems.length === 1 && elem.nodeType === 1 ?
-               jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
-               jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
-                       return elem.nodeType === 1;
-               } ) );
+       if ( elems.length === 1 && elem.nodeType === 1 ) {
+               return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
+       }
+
+       return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
+               return elem.nodeType === 1;
+       } ) );
 };
 
 jQuery.fn.extend( {
index 7887ec567d812d727a7220873b33b3dc460d85e7..744de89ec3adb42561cd273a42cb5b2886011234 100644 (file)
@@ -50,7 +50,6 @@
                "brace-style": "off",
                "key-spacing": "off",
                "camelcase": "off",
-               "dot-notaion": "off",
 
                // Not really too much - waiting autofix features for these rules
                "lines-around-comment": "off",