Skip to content

Commit 4a7fc85

Browse files
authored
Build: Enable ESLint one-var rule for var declarations in browser code
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
1 parent 364476c commit 4a7fc85

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

.eslintrc-browser.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020

2121
"rules": {
22+
"one-var": ["error", {"var": "always"}],
2223
"strict": ["error", "function"]
2324
}
2425
}

dist/.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
"rules": {
2121
// That is okay for the built version
22-
"no-multiple-empty-lines": "off"
22+
"no-multiple-empty-lines": "off",
23+
"one-var": "off"
2324
}
2425
}
2526
]

src/css/support.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var reliableTrDimensionsVal;
88
// IE/Edge misreport `getComputedStyle` of table rows with width/height
99
// set in CSS while `offset*` properties report correct values.
1010
support.reliableTrDimensions = function() {
11-
var table, tr, trChild;
11+
var table, tr, trChild, trStyle;
1212
if ( reliableTrDimensionsVal == null ) {
1313
table = document.createElement( "table" );
1414
tr = document.createElement( "tr" );
@@ -23,7 +23,7 @@ support.reliableTrDimensions = function() {
2323
.appendChild( tr )
2424
.appendChild( trChild );
2525

26-
var trStyle = window.getComputedStyle( tr );
26+
trStyle = window.getComputedStyle( tr );
2727
reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
2828

2929
documentElement.removeChild( table );

src/event.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,12 @@ jQuery.event = {
288288

289289
dispatch: function( nativeEvent ) {
290290

291-
// Make a writable jQuery.Event from the native event object
292-
var event = jQuery.event.fix( nativeEvent );
293-
294291
var i, j, ret, matched, handleObj, handlerQueue,
295292
args = new Array( arguments.length ),
293+
294+
// Make a writable jQuery.Event from the native event object
295+
event = jQuery.event.fix( nativeEvent ),
296+
296297
handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
297298
special = jQuery.event.special[ event.type ] || {};
298299

test/.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"brace-style": "off",
4848
"key-spacing": "off",
4949
"camelcase": "off",
50+
"one-var": "off",
5051
"strict": "off",
5152

5253
// Not really too many - waiting for autofix features for these rules

0 commit comments

Comments
 (0)