Skip to content

Commit 5358296

Browse files
committed
Fix eslint errors
1 parent 6fa5340 commit 5358296

File tree

10 files changed

+123
-122
lines changed

10 files changed

+123
-122
lines changed

src/components/go-light-modal/light-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class LightModal {
9090
// }
9191

9292
render() {
93-
let classes = "modal-card";
93+
const classes = "modal-card";
9494
let styles = {};
9595
if (this.x != -1 && this.y != -1) {
9696
styles = { top: this.y + "px", left: this.x + "px" };

src/components/go-ribbon-cell/ribbon-cell.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class RibbonCell {
9696
@Prop() hovered = false;
9797

9898
cellColor(nbClasses, nbAnnotations) {
99-
var levels =
99+
const levels =
100100
this.colorBy == COLOR_BY.CLASS_COUNT ? nbClasses : nbAnnotations;
101101
let newColor = heatColor(
102102
levels,
@@ -106,8 +106,8 @@ export class RibbonCell {
106106
this.binaryColor,
107107
);
108108
if (this.hovered) {
109-
let tmp = newColor.replace(/[^\d,]/g, "").split(",");
110-
let val = darken(tmp, 0.4);
109+
const tmp = newColor.replace(/[^\d,]/g, "").split(",");
110+
const val = darken(tmp, 0.4);
111111
newColor = "rgb(" + val.join(",") + ")";
112112
}
113113
return newColor;
@@ -117,9 +117,9 @@ export class RibbonCell {
117117
if (this.group.type == "GlobalAll") {
118118
return this.subject.nb_classes;
119119
}
120-
let cellid =
120+
const cellid =
121121
this.group.id + (this.group.type == CELL_TYPES.OTHER ? "-other" : "");
122-
let cell =
122+
const cell =
123123
cellid in this.subject.groups ? this.subject.groups[cellid] : undefined;
124124
return cell ? cell["ALL"]["nb_classes"] : 0;
125125
}
@@ -128,9 +128,9 @@ export class RibbonCell {
128128
if (this.group.type == "GlobalAll") {
129129
return this.subject.nb_annotations;
130130
}
131-
let cellid =
131+
const cellid =
132132
this.group.id + (this.group.type == CELL_TYPES.OTHER ? "-other" : "");
133-
let cell =
133+
const cell =
134134
cellid in this.subject.groups ? this.subject.groups[cellid] : undefined;
135135
return cell ? cell["ALL"]["nb_annotations"] : 0;
136136
}
@@ -151,18 +151,18 @@ export class RibbonCell {
151151

152152
render() {
153153
if (!this.available) {
154-
let title =
154+
const title =
155155
this.subject.label + " can not have data for " + this.group.label;
156-
let classes = "ribbon__subject--cell unavailable";
156+
const classes = "ribbon__subject--cell unavailable";
157157
return (
158158
<td title={title} class={classes}>
159159
{" "}
160160
</td>
161161
);
162162
}
163163

164-
let nbClasses = this.getNbClasses();
165-
let nbAnnotations = this.getNbAnnotations();
164+
const nbClasses = this.getNbClasses();
165+
const nbAnnotations = this.getNbAnnotations();
166166

167167
let title =
168168
"Subject: " +

src/components/go-ribbon-cell/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export function darken(color, factor) {
2-
var newColor = [...color];
2+
const newColor = [...color];
33
for (let i = 0; i < newColor.length; i++) {
44
if (newColor[i] < 255) {
55
newColor[i] = Math.round(Math.max(0, newColor[i] * (1 - factor)));
@@ -34,11 +34,11 @@ export function heatColor(
3434

3535
// this is the log version for interpolation (better highlight the most annotated classes)
3636
// note: safari needs integer and not float for rgb function
37-
let fraction =
37+
const fraction =
3838
Math.min(10 * Math.log(level + 1), maxHeatLevel) / maxHeatLevel;
3939

4040
// there are some annotations and we want a continuous color (r, g, b)
41-
let itemColor = []; // [r,g,b]
41+
const itemColor = []; // [r,g,b]
4242
itemColor[0] = Math.round(
4343
minColor[0] + fraction * (maxColor[0] - minColor[0]),
4444
);

src/components/go-ribbon-strips/ribbon-strips.tsx

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ export class RibbonStrips {
260260
getGroup(group_id) {
261261
if (!this.ribbonSummary) return null;
262262
if (group_id == "all") return this.groupAll;
263-
for (let cat of this.ribbonSummary.categories) {
264-
for (let gp of cat.groups) {
263+
for (const cat of this.ribbonSummary.categories) {
264+
for (const gp of cat.groups) {
265265
if (gp.id == group_id) return gp;
266266
}
267267
}
@@ -346,11 +346,11 @@ export class RibbonStrips {
346346
this.formerColors = new Map();
347347

348348
// change header style
349-
let el = this.ribbonElement.querySelector("#" + groupKey(group));
349+
const el = this.ribbonElement.querySelector("#" + groupKey(group));
350350
el.classList.add("selected");
351351

352-
for (let subject of subjects) {
353-
let el = this.ribbonElement.querySelector(
352+
for (const subject of subjects) {
353+
const el = this.ribbonElement.querySelector(
354354
"#" + subjectGroupKey(subject, group),
355355
);
356356
el.hovered = true;
@@ -386,18 +386,18 @@ export class RibbonStrips {
386386
el.classList.add("selected");
387387
}
388388
}
389-
let event: RibbonCellEvent = { subjects: subjects, group: group };
389+
const event: RibbonCellEvent = { subjects: subjects, group: group };
390390
this.cellEnter.emit(event);
391391
}
392392

393393
onCellLeave(subjects, group) {
394394
if (subjects instanceof Array) {
395395
// change the header style
396-
let el = this.ribbonElement.querySelector("#" + groupKey(group));
396+
const el = this.ribbonElement.querySelector("#" + groupKey(group));
397397
el.classList.remove("selected");
398398

399-
for (let subject of subjects) {
400-
let el = this.ribbonElement.querySelector(
399+
for (const subject of subjects) {
400+
const el = this.ribbonElement.querySelector(
401401
"#" + subjectGroupKey(subject, group),
402402
);
403403
el.hovered = false;
@@ -414,7 +414,7 @@ export class RibbonStrips {
414414
el = this.ribbonElement.querySelector("#" + groupKey(group));
415415
el.classList.remove("selected");
416416
}
417-
let event: RibbonCellEvent = { subjects: subjects, group: group };
417+
const event: RibbonCellEvent = { subjects: subjects, group: group };
418418
this.cellLeave.emit(event);
419419
}
420420

@@ -424,24 +424,24 @@ export class RibbonStrips {
424424
subjects = [subjects];
425425
}
426426

427-
let subs = subjects.map(
427+
const subs = subjects.map(
428428
(elt) => elt.id + "@" + group.id + "@" + group.type,
429429
);
430-
let prevSubs = this.previouslyHovered.map(
430+
const prevSubs = this.previouslyHovered.map(
431431
(elt) => elt.subject.id + "@" + elt.group.id + "@" + elt.group.type,
432432
);
433-
let same = sameArray(subs, prevSubs);
433+
const same = sameArray(subs, prevSubs);
434434

435435
if (!same) {
436-
for (let cell of this.previouslyHovered) {
436+
for (const cell of this.previouslyHovered) {
437437
cell.hovered = false;
438438
}
439439
}
440440
this.previouslyHovered = [];
441441

442-
let hovered: boolean[] = [];
443-
for (let subject of subjects) {
444-
let cell = this.ribbonElement.querySelector(
442+
const hovered: boolean[] = [];
443+
for (const subject of subjects) {
444+
const cell = this.ribbonElement.querySelector(
445445
"#" + subjectGroupKey(subject, group),
446446
);
447447
cell.hovered = !cell.hovered;
@@ -457,25 +457,25 @@ export class RibbonStrips {
457457
subjects = [subjects];
458458
}
459459

460-
let subs = subjects.map(
460+
const subs = subjects.map(
461461
(elt) => elt.id + "@" + group.id + "@" + group.type,
462462
);
463-
let prevSubs = this.previouslySelected.map(
463+
const prevSubs = this.previouslySelected.map(
464464
(elt) => elt.subject.id + "@" + elt.group.id + "@" + elt.group.type,
465465
);
466-
let same = sameArray(subs, prevSubs);
466+
const same = sameArray(subs, prevSubs);
467467

468468
if (!same) {
469-
for (let cell of this.previouslySelected) {
469+
for (const cell of this.previouslySelected) {
470470
cell.selected = false;
471471
}
472472
}
473473
this.previouslySelected = [];
474474

475-
let selected: boolean[] = [];
475+
const selected: boolean[] = [];
476476
let lastCell;
477-
for (let subject of subjects) {
478-
let cell = this.ribbonElement.querySelector(
477+
for (const subject of subjects) {
478+
const cell = this.ribbonElement.querySelector(
479479
"#" + subjectGroupKey(subject, group),
480480
);
481481
cell.selected = toggle ? !cell.selected : true;
@@ -501,15 +501,15 @@ export class RibbonStrips {
501501
let hasAnnotations = false;
502502
// if single cell selection, check if it has annotations
503503
if (this.selectionMode == SELECTION.CELL) {
504-
let keys = Object.keys(subjects[0].groups);
505-
for (let key of keys) {
504+
const keys = Object.keys(subjects[0].groups);
505+
for (const key of keys) {
506506
if (subjects[0].groups[key]["ALL"].nb_annotations > 0)
507507
hasAnnotations = true;
508508
}
509509

510510
// if multiple cells selection, check if at least one has annotations
511511
} else {
512-
for (let sub of subjects) {
512+
for (const sub of subjects) {
513513
if (group.id == "all") {
514514
hasAnnotations = hasAnnotations || sub.nb_annotations > 0;
515515
} else {
@@ -525,9 +525,9 @@ export class RibbonStrips {
525525
}
526526
}
527527

528-
let selected = this.selectCells(subjects, group);
528+
const selected = this.selectCells(subjects, group);
529529

530-
let event: RibbonCellClick = {
530+
const event: RibbonCellClick = {
531531
subjects: subjects,
532532
group: group,
533533
selected: selected,
@@ -537,13 +537,13 @@ export class RibbonStrips {
537537

538538
onGroupClick(category, group) {
539539
this.selectCells(this.ribbonSummary.subjects, group);
540-
let event = { category: category, group: group };
540+
const event = { category: category, group: group };
541541
this.groupClick.emit(event);
542542
}
543543

544544
onGroupEnter(category, group) {
545545
this.overCells(this.ribbonSummary.subjects, group);
546-
let event: RibbonGroupEvent = {
546+
const event: RibbonGroupEvent = {
547547
subjects: this.ribbonSummary.subjects,
548548
category: category,
549549
group: group,
@@ -553,7 +553,7 @@ export class RibbonStrips {
553553

554554
onGroupLeave(category, group) {
555555
this.overCells(this.ribbonSummary.subjects, group);
556-
let event: RibbonGroupEvent = {
556+
const event: RibbonGroupEvent = {
557557
subjects: this.ribbonSummary.subjects,
558558
category: category,
559559
group: group,
@@ -562,14 +562,14 @@ export class RibbonStrips {
562562
}
563563

564564
applyCategoryStyling(category) {
565-
let cc0 = truncate(category, this.groupMaxLabelSize, "...");
566-
let cc1 = this.applyCategoryCase(cc0);
567-
let cc2 = this.applyCategoryBold(cc1);
565+
const cc0 = truncate(category, this.groupMaxLabelSize, "...");
566+
const cc1 = this.applyCategoryCase(cc0);
567+
const cc2 = this.applyCategoryBold(cc1);
568568
return cc2;
569569
}
570570

571571
applyCategoryBold(category) {
572-
let lc = category.toLowerCase();
572+
const lc = category.toLowerCase();
573573
if (lc.startsWith("all") && this.categoryAllStyle == FONT_STYLE.BOLD) {
574574
return <b>{category}</b>;
575575
}
@@ -592,7 +592,7 @@ export class RibbonStrips {
592592
async selectGroup(group_id) {
593593
setTimeout(() => {
594594
if (group_id && this.ribbonSummary) {
595-
let gp = this.getGroup(group_id);
595+
const gp = this.getGroup(group_id);
596596
if (gp) {
597597
this.selectCells(this.ribbonSummary.subjects, gp, false);
598598
} else {
@@ -623,7 +623,7 @@ export class RibbonStrips {
623623
}
624624

625625
// API request done but not subject retrieved
626-
let nbSubjects: number = this.ribbonSummary.subjects.length;
626+
const nbSubjects: number = this.ribbonSummary.subjects.length;
627627
if (nbSubjects == 0) {
628628
return <div>Must provide at least one subject</div>;
629629
}
@@ -683,7 +683,7 @@ export class RibbonStrips {
683683
return;
684684
}
685685

686-
let classes = this.groupClickable
686+
const classes = this.groupClickable
687687
? "ribbon__category--cell clickable"
688688
: "ribbon__category--cell";
689689
return (
@@ -725,7 +725,7 @@ export class RibbonStrips {
725725

726726
renderSubjects() {
727727
return this.ribbonSummary.subjects.map((subject: RibbonSubject) => {
728-
let subjects =
728+
const subjects =
729729
this.selectionMode == SELECTION.CELL
730730
? subject
731731
: this.ribbonSummary.subjects;
@@ -767,18 +767,21 @@ export class RibbonStrips {
767767
return [
768768
<td class="ribbon__subject--separator"></td>,
769769
category.groups.map((group: RibbonGroup) => {
770-
let cellid =
770+
const cellid =
771771
group.id + (group.type == CELL_TYPES.OTHER ? "-other" : "");
772-
let cell =
772+
const cell =
773773
cellid in subject.groups ? subject.groups[cellid] : undefined;
774774

775-
let nbAnnotations = cell ? cell["ALL"]["nb_annotations"] : 0;
775+
const nbAnnotations = cell ? cell["ALL"]["nb_annotations"] : 0;
776776

777777
// by default the group should be available
778778
let available = true;
779779

780780
// if a value was given, then override the default value
781-
if (cell && cell.hasOwnProperty("available")) {
781+
if (
782+
cell &&
783+
Object.prototype.hasOwnProperty.call(cell, "available")
784+
) {
782785
available = cell.available;
783786
}
784787

src/components/go-ribbon-subject/ribbon-subject.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class RibbonSubject {
4747
subjectClick: EventEmitter;
4848

4949
onSubjectClick(event, subject) {
50-
let ev = { originalEvent: event, subject: subject };
50+
const ev = { originalEvent: event, subject: subject };
5151
this.subjectClick.emit(ev);
5252
}
5353

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export function formatTaxonLabel(species) {
2-
let split = species.split(" ");
2+
const split = species.split(" ");
33
return split[0].substring(0, 1) + split[1].substring(0, 2);
44
}

0 commit comments

Comments
 (0)