]> source.dussan.org Git - jquery.git/commitdiff
Build: Enable ESLint one-var rule for var declarations in browser code
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 2 Mar 2020 21:25:35 +0000 (22:25 +0100)
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 2 Mar 2020 21:30:00 +0000 (22:30 +0100)
Node.js code is written more & more commonly in ES6+ so it doesn't make sense
to enable it there. There are many violations in test code so it's disabled
there as well.

Closes gh-4615

(cherry picked from commit 4a7fc8544e2020c75047456d11979e4e3a517fdf)

.eslintrc-browser.json
dist/.eslintrc.json
src/css/support.js
src/event.js
test/.eslintrc.json

index ffd5b64674e25091d19e660e21c8e0b7d6ccb76d..d580883b2d4a9e5d70cfa40465ba37e4b74055e0 100644 (file)
@@ -24,6 +24,7 @@
        },
 
        "rules": {
+               "one-var": ["error", {"var": "always"}],
                "strict": ["error", "function"]
        }
 }
index ff02f72bc7ab2a1bf59f7b9e55547350b8c84bd1..a86695799937dfdc6a9b76b70dc177bc186b38a5 100644 (file)
@@ -14,6 +14,7 @@
                        "rules": {
                                // That is okay for the built version
                                "no-multiple-empty-lines": "off",
+                               "one-var": "off",
 
                                // Sizzle is not compatible with jQuery code style
                                "no-nested-ternary": "off",
index 6d9561def16dccc47c2c612bd7b7b350ae07ba18..fb2a1b2045a3b35405459f458f6994edb11aabf8 100644 (file)
@@ -103,7 +103,7 @@ define( [
                // Behavior in IE 9 is more subtle than in newer versions & it passes
                // some versions of this test; make sure not to make it pass there!
                reliableTrDimensions: function() {
-                       var table, tr, trChild;
+                       var table, tr, trChild, trStyle;
                        if ( reliableTrDimensionsVal == null ) {
                                table = document.createElement( "table" );
                                tr = document.createElement( "tr" );
@@ -118,7 +118,7 @@ define( [
                                        .appendChild( tr )
                                        .appendChild( trChild );
 
-                               var trStyle = window.getComputedStyle( tr );
+                               trStyle = window.getComputedStyle( tr );
                                reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
 
                                documentElement.removeChild( table );
index 79abf561488aa4be047521f5d2af12a20b449f21..734f6f020a9302197e55862736978796c3211299 100644 (file)
@@ -308,11 +308,12 @@ jQuery.event = {
 
        dispatch: function( nativeEvent ) {
 
-               // Make a writable jQuery.Event from the native event object
-               var event = jQuery.event.fix( nativeEvent );
-
                var i, j, ret, matched, handleObj, handlerQueue,
                        args = new Array( arguments.length ),
+
+                       // Make a writable jQuery.Event from the native event object
+                       event = jQuery.event.fix( nativeEvent ),
+
                        handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
                        special = jQuery.event.special[ event.type ] || {};
 
index a23ea5f98466f60ff932bb1f625df1928d70ad44..4d85386e6d8f84cb47ba4076e5c883b8ed7b796d 100644 (file)
@@ -46,6 +46,7 @@
                "brace-style": "off",
                "key-spacing": "off",
                "camelcase": "off",
+               "one-var": "off",
                "strict": "off",
 
                // Not really too many - waiting for autofix features for these rules