Skip to content

Commit b48e4ea

Browse files
committed
Build: Fix remaining ESLint violations
1 parent bde5b7b commit b48e4ea

File tree

17 files changed

+57
-33
lines changed

17 files changed

+57
-33
lines changed

demos/.eslintrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"root": true,
3+
4+
"extends": "../ui/.eslintrc.json"
5+
}

demos/bootstrap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* globals window, document */
22
( function() {
3+
"use strict";
34

45
// Find the script element
56
var scripts = document.getElementsByTagName( "script" );

tests/.eslintrc.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010
},
1111

1212
"rules": {
13-
"strict": [ "error", "function" ],
14-
15-
// The following rule is relaxed due to too many violations:
16-
"no-unused-vars": [ "error", { "vars": "all", "args": "after-used" } ],
17-
1813
// Too many violations:
19-
"max-len": "off"
14+
"max-len": "off",
15+
"no-unused-vars": "off",
16+
"strict": "off" // ideally, `[ "error", "function" ]`
2017
},
2118

2219
"globals": {

tests/unit/dialog/methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ QUnit.test( "destroy", function( assert ) {
6969
assert.equal( $( ".ui-widget-overlay" ).length, 0, "overlay does not exist" );
7070
assert.equal( $( document ).data( "ui-dialog-overlays" ), undefined, "ui-dialog-overlays equals the number of open overlays" );
7171

72-
element = $( "#dialog1" ).dialog( { modal: true } ),
72+
element = $( "#dialog1" ).dialog( { modal: true } );
7373
element2 = $( "#dialog2" ).dialog( { modal: true } );
7474
assert.equal( $( ".ui-widget-overlay" ).length, 2, "overlays created when dialogs are open" );
7575
assert.equal( $( document ).data( "ui-dialog-overlays" ), 2, "ui-dialog-overlays equals the number of open overlays" );

tests/unit/droppable/core.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ QUnit.test( "element types", function( assert ) {
2121
var typeName = typeNames[ i ],
2222
el = $( document.createElement( typeName ) ).appendTo( "body" );
2323

24-
( typeName === "table" && el.append( "<tr><td>content</td></tr>" ) );
24+
if ( typeName === "table" ) {
25+
el.append( "<tr><td>content</td></tr>" );
26+
}
2527
el.droppable();
2628
testHelper.shouldDrop( assert );
2729
el.droppable( "destroy" );

tests/unit/droppable/methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ QUnit.test( "enable", function( assert ) {
6262
assert.equal( el.droppable( "option", "disabled" ), false, "disabled option setter" );
6363
testHelper.shouldDrop( assert );
6464

65-
expected = $( "<div></div>" ).droppable(),
65+
expected = $( "<div></div>" ).droppable();
6666
actual = expected.droppable( "enable" );
6767
assert.equal( actual, expected, "enable is chainable" );
6868
} );

tests/unit/effects/scale.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@ function run( position, v, h, vo, ho ) {
3535

3636
css[ h ] = 33;
3737
css[ v ] = 33;
38-
target[ h ] = h === ho ? css[ h ] : ho === "center" ? css[ h ] - 35 : css[ h ] - 70;
39-
target[ v ] = v === vo ? css[ v ] : vo === "middle" ? css[ v ] - 35 : css[ v ] - 70;
38+
if ( h === ho ) {
39+
target[ h ] = css[ h ];
40+
} else {
41+
target[ h ] = ho === "center" ? css[ h ] - 35 : css[ h ] - 70;
42+
}
43+
if ( v === vo ) {
44+
target[ v ] = css[ v ];
45+
} else {
46+
target[ v ] = vo === "middle" ? css[ v ] - 35 : css[ v ] - 70;
47+
}
4048
if ( relative && h === "right" ) {
4149
target[ h ] += 70;
4250
}

tests/unit/slider/events.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,16 @@ QUnit.test( "mouse based interaction part two: when handles overlap", function(
125125
start: function( event, ui ) {
126126
assert.equal( handles.index( ui.handle ), 0, "leftmost handle activated when overlapping at maximum" );
127127
}
128-
} ),
129-
handles = element.find( ".ui-slider-handle" );
128+
} );
129+
handles = element.find( ".ui-slider-handle" );
130130
handles.eq( 0 ).simulate( "drag", { dx: -10 } );
131131
element.slider( "destroy" );
132132

133133
element = $( "#slider1" )
134134
.slider( {
135135
values: [ 19, 20 ]
136-
} ),
137-
handles = element.find( ".ui-slider-handle" );
136+
} );
137+
handles = element.find( ".ui-slider-handle" );
138138
handles.eq( 0 ).simulate( "drag", { dx: 10 } );
139139
element.one( "slidestart", function( event, ui ) {
140140
assert.equal( handles.index( ui.handle ), 0, "left handle activated if left was moved last" );
@@ -145,8 +145,8 @@ QUnit.test( "mouse based interaction part two: when handles overlap", function(
145145
element = $( "#slider1" )
146146
.slider( {
147147
values: [ 19, 20 ]
148-
} ),
149-
handles = element.find( ".ui-slider-handle" );
148+
} );
149+
handles = element.find( ".ui-slider-handle" );
150150
handles.eq( 1 ).simulate( "drag", { dx: -10 } );
151151
element.one( "slidestart", function( event, ui ) {
152152
assert.equal( handles.index( ui.handle ), 1, "right handle activated if right was moved last (#3467)" );
@@ -159,8 +159,8 @@ QUnit.test( "mouse based interaction part two: when handles overlap", function(
159159
min: 0,
160160
max: 100,
161161
values: [ 0, 50 ]
162-
} ),
163-
handles = element.find( ".ui-slider-handle" );
162+
} );
163+
handles = element.find( ".ui-slider-handle" );
164164

165165
element.slider( "option", { values: [ 100, 100 ] } );
166166
handles.eq( 0 ).simulate( "drag", { dx: -10 } );

tests/unit/sortable/methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ QUnit.test( "enable", function( assert ) {
6363

6464
testHelper.sort( assert, $( "li", el )[ 0 ], 0, 44, 2, ".sortable('option', 'disabled', false)" );
6565

66-
expected = $( "<div></div>" ).sortable(),
66+
expected = $( "<div></div>" ).sortable();
6767
actual = expected.sortable( "enable" );
6868
assert.equal( actual, expected, "enable is chainable" );
6969
} );

tests/unit/tooltip/helper.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ define( [
1414
timers = jQuery.timers;
1515

1616
jQuery.fx.stop();
17-
var x = false;
1817

1918
for ( index = timers.length; index--; ) {
20-
x = true;
2119
timer = timers[ index ];
2220
timer.anim.stop();
2321
timers.splice( index, 1 );

ui/core.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// This file is deprecated in 1.12.0 to be removed in 1.13
22
( function() {
3+
"use strict";
4+
35
define( [
46
"jquery",
57
"./data",

ui/effect.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ if ( $.uiBackCompat !== false ) {
342342
// Firefox incorrectly exposes anonymous content
343343
// https://bugzilla.mozilla.org/show_bug.cgi?id=561664
344344
try {
345+
// eslint-disable-next-line no-unused-expressions
345346
active.id;
346347
} catch ( e ) {
347348
active = document.body;

ui/widgets/autocomplete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ $.widget( "ui.autocomplete", {
619619
var editable = element.prop( "contentEditable" );
620620

621621
if ( editable === "inherit" ) {
622-
return this._isContentEditable( element.parent() );
622+
return this._isContentEditable( element.parent() );
623623
}
624624

625625
return editable === "true";

ui/widgets/datepicker.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,10 +2216,12 @@ $.fn.datepicker = function( options ) {
22162216
apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
22172217
}
22182218
return this.each( function() {
2219-
typeof options === "string" ?
2220-
$.datepicker[ "_" + options + "Datepicker" ].
2221-
apply( $.datepicker, [ this ].concat( otherArgs ) ) :
2219+
if ( typeof options === "string" ) {
2220+
$.datepicker[ "_" + options + "Datepicker" ]
2221+
.apply( $.datepicker, [ this ].concat( otherArgs ) );
2222+
} else {
22222223
$.datepicker._attachDatepicker( this, options );
2224+
}
22232225
} );
22242226
};
22252227

ui/widgets/draggable.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ $.widget( "ui.draggable", $.ui.mouse, {
204204
this.originalPageY = event.pageY;
205205

206206
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
207-
( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
207+
if ( o.cursorAt ) {
208+
this._adjustOffsetFromHelper( o.cursorAt );
209+
}
208210

209211
//Set a containment if given in the options
210212
this._setContainment();
@@ -1119,12 +1121,13 @@ $.ui.plugin.add( "draggable", "snap", {
11191121
!$.contains( inst.snapElements[ i ].item.ownerDocument,
11201122
inst.snapElements[ i ].item ) ) {
11211123
if ( inst.snapElements[ i ].snapping ) {
1122-
( inst.options.snap.release &&
1124+
if ( inst.options.snap.release ) {
11231125
inst.options.snap.release.call(
11241126
inst.element,
11251127
event,
11261128
$.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
1127-
) );
1129+
);
1130+
}
11281131
}
11291132
inst.snapElements[ i ].snapping = false;
11301133
continue;
@@ -1195,13 +1198,14 @@ $.ui.plugin.add( "draggable", "snap", {
11951198
}
11961199

11971200
if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
1198-
( inst.options.snap.snap &&
1201+
if ( inst.options.snap.snap ) {
11991202
inst.options.snap.snap.call(
12001203
inst.element,
12011204
event,
12021205
$.extend( inst._uiHash(), {
12031206
snapItem: inst.snapElements[ i ].item
1204-
} ) ) );
1207+
} ) );
1208+
}
12051209
}
12061210
inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
12071211

ui/widgets/droppable.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ $.widget( "ui.droppable", {
8383

8484
this._addToManager( o.scope );
8585

86-
o.addClasses && this._addClass( "ui-droppable" );
86+
if ( o.addClasses ) {
87+
this._addClass( "ui-droppable" );
88+
}
8789

8890
},
8991

ui/widgets/resizable.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,9 @@ $.widget( "ui.resizable", $.ui.mouse, {
779779

780780
_propagate: function( n, event ) {
781781
$.ui.plugin.call( this, n, [ event, this.ui() ] );
782-
( n !== "resize" && this._trigger( n, event, this.ui() ) );
782+
if ( n !== "resize" ) {
783+
this._trigger( n, event, this.ui() );
784+
}
783785
},
784786

785787
plugins: {},

0 commit comments

Comments
 (0)