Skip to content

Commit 6f5757e

Browse files
committed
Lint updates
1 parent e9702a3 commit 6f5757e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+418
-431
lines changed

srcts/src/bindings/input/actionbutton.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ActionButtonInputBinding extends InputBinding {
2020
}
2121
getType(el: HTMLElement): string {
2222
return "shiny.action";
23-
el;
23+
el; // eslint-disable-line @typescript-eslint/no-unused-expressions
2424
}
2525
subscribe(el: HTMLElement, callback: (x: boolean) => void): void {
2626
$(el).on(
@@ -33,7 +33,7 @@ class ActionButtonInputBinding extends InputBinding {
3333
$el.data("val", val + 1);
3434

3535
callback(false);
36-
}
36+
},
3737
);
3838
}
3939
getState(el: HTMLElement): { value: number } {
@@ -62,11 +62,11 @@ class ActionButtonInputBinding extends InputBinding {
6262

6363
// update the requested properties
6464
if (hasDefinedProperty(data, "label")) {
65-
label = data.label;
65+
label = data.label!;
6666
}
6767
if (hasDefinedProperty(data, "icon")) {
6868
// `data.icon` can be an [] if user gave `character(0)`.
69-
icon = Array.isArray(data.icon) ? "" : data.icon ?? "";
69+
icon = Array.isArray(data.icon) ? "" : (data.icon ?? "");
7070
}
7171

7272
// produce new html

srcts/src/bindings/input/checkbox.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ class CheckboxInputBinding extends InputBinding {
3434
}
3535
receiveMessage(
3636
el: CheckedHTMLElement,
37-
data: CheckboxReceiveMessageData
37+
data: CheckboxReceiveMessageData,
3838
): void {
3939
if (hasDefinedProperty(data, "value")) {
40-
el.checked = data.value;
40+
el.checked = data.value!;
4141
}
4242

4343
// checkboxInput()'s label works different from other
4444
// input labels...the label container should always exist
4545
if (hasDefinedProperty(data, "label")) {
46-
$(el).parent().find("span").text(data.label);
46+
$(el).parent().find("span").text(data.label!);
4747
}
4848

4949
$(el).trigger("change");
5050
}
5151
}
5252

5353
export { CheckboxInputBinding };
54-
export type { CheckedHTMLElement, CheckboxReceiveMessageData };
54+
export type { CheckboxReceiveMessageData, CheckedHTMLElement };

srcts/src/bindings/input/checkboxgroup.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class CheckboxGroupInputBinding extends InputBinding {
7777
$escape(el.id) +
7878
'"][value="' +
7979
$escape(value[i]) +
80-
'"]'
80+
'"]',
8181
).prop("checked", true);
8282
}
8383
// Else assume it's a single value
@@ -87,7 +87,7 @@ class CheckboxGroupInputBinding extends InputBinding {
8787
$escape(el.id) +
8888
'"][value="' +
8989
$escape(value) +
90-
'"]'
90+
'"]',
9191
).prop("checked", true);
9292
}
9393
}
@@ -97,7 +97,7 @@ class CheckboxGroupInputBinding extends InputBinding {
9797
options: ValueLabelObject[];
9898
} {
9999
const $objs = $(
100-
'input:checkbox[name="' + $escape(el.id) + '"]'
100+
'input:checkbox[name="' + $escape(el.id) + '"]',
101101
) as JQuery<CheckboxGroupHTMLElement>;
102102

103103
// Store options in an array of objects, each with with value and label
@@ -115,7 +115,7 @@ class CheckboxGroupInputBinding extends InputBinding {
115115
}
116116
receiveMessage(
117117
el: CheckboxGroupHTMLElement,
118-
data: CheckboxGroupReceiveMessageData
118+
data: CheckboxGroupReceiveMessageData,
119119
): void {
120120
const $el = $(el);
121121

@@ -125,11 +125,11 @@ class CheckboxGroupInputBinding extends InputBinding {
125125
$el.find("div.shiny-options-group").remove();
126126
// Backward compatibility: for HTML generated by shinybootstrap2 package
127127
$el.find("label.checkbox").remove();
128-
$el.append(data.options);
128+
$el.append(data.options!);
129129
}
130130

131131
if (hasDefinedProperty(data, "value")) {
132-
this.setValue(el, data.value);
132+
this.setValue(el, data.value!);
133133
}
134134

135135
updateLabel(data.label, getLabelNode(el));
@@ -138,7 +138,7 @@ class CheckboxGroupInputBinding extends InputBinding {
138138
}
139139
subscribe(
140140
el: CheckboxGroupHTMLElement,
141-
callback: (x: boolean) => void
141+
callback: (x: boolean) => void,
142142
): void {
143143
$(el).on("change.checkboxGroupInputBinding", function () {
144144
callback(false);

srcts/src/bindings/input/date.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ declare global {
1515
bsDatepicker(methodName: "getUTCDate"): Date;
1616
// Infinity is not allowed as a literal return type. Using `1e9999` as a placeholder that resolves to Infinity
1717
// https://github.com/microsoft/TypeScript/issues/32277
18-
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
19-
bsDatepicker(methodName: "getStartDate"): Date | -1e9999;
20-
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
21-
bsDatepicker(methodName: "getEndDate"): Date | 1e9999;
18+
19+
bsDatepicker(methodName: "getStartDate"): Date | -1e9999; // eslint-disable-line no-loss-of-precision
20+
21+
bsDatepicker(methodName: "getEndDate"): Date | 1e9999; // eslint-disable-line no-loss-of-precision
2222
bsDatepicker(methodName: string): void;
2323
bsDatepicker(methodName: string, params: Date | null): void;
2424
}
@@ -37,7 +37,7 @@ class DateInputBindingBase extends InputBinding {
3737
}
3838
getType(el: HTMLElement): string {
3939
return "shiny.date";
40-
el;
40+
el; // eslint-disable-line @typescript-eslint/no-unused-expressions
4141
}
4242
subscribe(el: HTMLElement, callback: (x: boolean) => void): void {
4343
// Don't update when in the middle of typing; listening on keyup or input
@@ -50,7 +50,7 @@ class DateInputBindingBase extends InputBinding {
5050
// Send immediately when clicked
5151
// Or if typing, when enter pressed or focus lost
5252
callback(false);
53-
}
53+
},
5454
);
5555
}
5656
unsubscribe(el: HTMLElement): void {
@@ -66,8 +66,8 @@ class DateInputBindingBase extends InputBinding {
6666

6767
setValue(el: HTMLElement, data: unknown): void {
6868
throw "not implemented";
69-
el;
70-
data;
69+
el; // eslint-disable-line @typescript-eslint/no-unused-expressions
70+
data; // eslint-disable-line @typescript-eslint/no-unused-expressions
7171
}
7272
initialize(el: HTMLElement): void {
7373
const $input = $(el).find("input");
@@ -297,14 +297,14 @@ class DateInputBinding extends DateInputBindingBase {
297297

298298
updateLabel(data.label, this._getLabelNode(el));
299299

300-
if (hasDefinedProperty(data, "min")) this._setMin($input[0], data.min);
300+
if (hasDefinedProperty(data, "min")) this._setMin($input[0], data.min!);
301301

302-
if (hasDefinedProperty(data, "max")) this._setMax($input[0], data.max);
302+
if (hasDefinedProperty(data, "max")) this._setMax($input[0], data.max!);
303303

304304
// Must set value only after min and max have been set. If new value is
305305
// outside the bounds of the previous min/max, then the result will be a
306306
// blank input.
307-
if (hasDefinedProperty(data, "value")) this.setValue(el, data.value);
307+
if (hasDefinedProperty(data, "value")) this.setValue(el, data.value!);
308308

309309
$(el).trigger("change");
310310
}

srcts/src/bindings/input/daterange.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,20 @@ class DateRangeInputBinding extends DateInputBindingBase {
115115
updateLabel(data.label, getLabelNode(el));
116116

117117
if (hasDefinedProperty(data, "min")) {
118-
this._setMin($startinput[0], data.min);
119-
this._setMin($endinput[0], data.min);
118+
this._setMin($startinput[0], data.min!);
119+
this._setMin($endinput[0], data.min!);
120120
}
121121

122122
if (hasDefinedProperty(data, "max")) {
123-
this._setMax($startinput[0], data.max);
124-
this._setMax($endinput[0], data.max);
123+
this._setMax($startinput[0], data.max!);
124+
this._setMax($endinput[0], data.max!);
125125
}
126126

127127
// Must set value only after min and max have been set. If new value is
128128
// outside the bounds of the previous min/max, then the result will be a
129129
// blank input.
130130
if (hasDefinedProperty(data, "value")) {
131-
this.setValue(el, data.value);
131+
this.setValue(el, data.value!);
132132
}
133133

134134
$el.trigger("change");
@@ -171,7 +171,7 @@ class DateRangeInputBinding extends DateInputBindingBase {
171171
// Send immediately when clicked
172172
// Or if typing, when enter pressed or focus lost
173173
callback(false);
174-
}
174+
},
175175
);
176176
}
177177
unsubscribe(el: HTMLElement): void {

srcts/src/bindings/input/fileinput.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ function canSetFiles(fileList: FileList): boolean {
8888
testEl.files = fileList;
8989
} catch (e) {
9090
return false;
91+
e; // eslint-disable-line @typescript-eslint/no-unused-expressions
9192
}
9293
return true;
9394
}
@@ -99,7 +100,7 @@ function handleDrop(e: JQuery.DragEventBase, el: HTMLInputElement): void {
99100
// 1. The FileList object isn't supported by this browser, and
100101
// there's nothing else we can try. (< IE 10)
101102
console.log(
102-
"Dropping files is not supported on this browser. (no FileList)"
103+
"Dropping files is not supported on this browser. (no FileList)",
103104
);
104105
} else if (!canSetFiles(files)) {
105106
// 2. The browser doesn't support assigning a type=file input's .files
@@ -146,7 +147,7 @@ function abortCurrentUpload($el: JQuery<EventTarget>) {
146147

147148
function uploadDroppedFilesIE10Plus(
148149
el: HTMLInputElement,
149-
files: FileList
150+
files: FileList,
150151
): void {
151152
const $el = $(el);
152153

@@ -158,7 +159,7 @@ function uploadDroppedFilesIE10Plus(
158159
// Start the new upload and put the uploader in 'currentUploader'.
159160
$el.data(
160161
"currentUploader",
161-
new FileUploader(shinyShinyApp(), fileInputBindingGetId(el), files, el)
162+
new FileUploader(shinyShinyApp(), fileInputBindingGetId(el), files, el),
162163
);
163164
}
164165

@@ -178,7 +179,7 @@ function uploadFiles(evt: JQuery.DragEvent): void {
178179
// Start the new upload and put the uploader in 'currentUploader'.
179180
$el.data(
180181
"currentUploader",
181-
new FileUploader(shinyShinyApp(), id, files, evt.target)
182+
new FileUploader(shinyShinyApp(), id, files, evt.target),
182183
);
183184
}
184185

@@ -237,17 +238,18 @@ class FileInputBinding extends InputBinding {
237238
}
238239
setValue(el: HTMLElement, value: void): void {
239240
// Not implemented
240-
el;
241-
value;
241+
return;
242+
el; // eslint-disable-line @typescript-eslint/no-unused-expressions
243+
value; // eslint-disable-line @typescript-eslint/no-unused-expressions
242244
}
243245
getType(el: HTMLElement): string {
244246
// This will be used only when restoring a file from a saved state.
245247
return "shiny.file";
246-
el;
248+
el; // eslint-disable-line @typescript-eslint/no-unused-expressions
247249
}
248250

249251
subscribe(el: HTMLInputElement, callback: (x: boolean) => void): void {
250-
callback;
252+
callback; // eslint-disable-line @typescript-eslint/no-unused-expressions
251253

252254
$(el).on("change.fileInputBinding", uploadFiles);
253255
// Here we try to set up the necessary events for Drag and Drop ("DnD").
@@ -257,8 +259,9 @@ class FileInputBinding extends InputBinding {
257259

258260
enableDraghover($zone).on({
259261
"draghover:enter.draghover": (e) => {
260-
e;
261262
$zone.addClass(zoneOver);
263+
return;
264+
e; // eslint-disable-line @typescript-eslint/no-unused-expressions
262265
},
263266
"draghover:leave.draghover": (e) => {
264267
$zone.removeClass(zoneOver);
@@ -267,8 +270,9 @@ class FileInputBinding extends InputBinding {
267270
e.stopPropagation();
268271
},
269272
"draghover:drop.draghover": (e, dropEvent) => {
270-
e;
271273
handleDrop(dropEvent, el);
274+
return;
275+
e; // eslint-disable-line @typescript-eslint/no-unused-expressions
272276
},
273277
});
274278
}

srcts/src/bindings/input/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function initInputBindings(): {
3131
inputBindings.register(new CheckboxInputBinding(), "shiny.checkboxInput");
3232
inputBindings.register(
3333
new CheckboxGroupInputBinding(),
34-
"shiny.checkboxGroupInput"
34+
"shiny.checkboxGroupInput",
3535
);
3636
inputBindings.register(new RadioInputBinding(), "shiny.radioInput");
3737
inputBindings.register(new SliderInputBinding(), "shiny.sliderInput");
@@ -40,11 +40,11 @@ function initInputBindings(): {
4040
inputBindings.register(new SelectInputBinding(), "shiny.selectInput");
4141
inputBindings.register(
4242
new ActionButtonInputBinding(),
43-
"shiny.actionButtonInput"
43+
"shiny.actionButtonInput",
4444
);
4545
inputBindings.register(
4646
new BootstrapTabInputBinding(),
47-
"shiny.bootstrapTabInput"
47+
"shiny.bootstrapTabInput",
4848
);
4949
const fileInputBinding = new FileInputBinding();
5050

0 commit comments

Comments
 (0)