]> 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)
committerGitHub <noreply@github.com>
Mon, 2 Mar 2020 21:25:35 +0000 (22:25 +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

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

index 127fc6ce88480555c48dda851f81525dc455396e..3727632273205954fae88012e6e4fce17f4f2c0f 100644 (file)
@@ -19,6 +19,7 @@
        },
 
        "rules": {
+               "one-var": ["error", {"var": "always"}],
                "strict": ["error", "function"]
        }
 }
index c2259f1499bcf9ce03ad88a31b1852c39264e187..af08e681200cda5bf07c499791dbec455fb6bd39 100644 (file)
@@ -19,7 +19,8 @@
 
                        "rules": {
                                // That is okay for the built version
-                               "no-multiple-empty-lines": "off"
+                               "no-multiple-empty-lines": "off",
+                               "one-var": "off"
                        }
                }
        ]
index 505adafb69540bc70ccc888cb8eae595750d5b37..dc18708c128c6a857c8ce2aaaf1bfb8d729017ea 100644 (file)
@@ -8,7 +8,7 @@ var reliableTrDimensionsVal;
 // IE/Edge misreport `getComputedStyle` of table rows with width/height
 // set in CSS while `offset*` properties report correct values.
 support.reliableTrDimensions = function() {
-       var table, tr, trChild;
+       var table, tr, trChild, trStyle;
        if ( reliableTrDimensionsVal == null ) {
                table = document.createElement( "table" );
                tr = document.createElement( "tr" );
@@ -23,7 +23,7 @@ support.reliableTrDimensions = function() {
                        .appendChild( tr )
                        .appendChild( trChild );
 
-               var trStyle = window.getComputedStyle( tr );
+               trStyle = window.getComputedStyle( tr );
                reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
 
                documentElement.removeChild( table );
index a79552c17b3a1a0fdd3abbbbd9ace5bab89b2300..f6dd709dca96e2f7638e15590eb7f3df9a96f2df 100644 (file)
@@ -288,11 +288,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 f5a3fa591f8a39d64374e59bfe3ffbde8de8f3db..f52842efa3a1ea61631bf1a898ed2b5a796785f4 100644 (file)
@@ -47,6 +47,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