Skip to content

Commit 2c01306

Browse files
committed
fix(ESLint): Fix code to comply with rules
BREAKING CHANGE: Hopefully it should be fine, but we never know...
1 parent f743868 commit 2c01306

File tree

176 files changed

+2166
-1790
lines changed

Some content is hidden

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

176 files changed

+2166
-1790
lines changed

.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ module.exports = {
2020
'import/no-named-as-default': 0,
2121
'import/no-named-as-default-member': 0,
2222
'prefer-destructuring': 0, // Can have unwanted side effect
23+
'react/jsx-filename-extension': 0,
24+
'jsx-a11y/no-static-element-interactions': 0,
25+
'jsx-a11y/click-events-have-key-events': 0,
26+
'jsx-a11y/no-noninteractive-element-interactions': 0,
2327

2428
// Introduced with new eslint
2529
// and no time to fix them...
2630
// [...]
2731
'linebreak-style': 0,
32+
'no-useless-escape': 0,
33+
'no-nested-ternary': 0,
34+
'react/forbid-prop-types': 0,
35+
'react/no-array-index-key': 0,
2836
},
2937
plugins: [
3038
'prettier'

src/Common/Core/CompositeClosureHelper/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ function dynamicArray(publicAPI, model, name) {
201201

202202
publicAPI[`get${capitalize(name)}`] = () => model[name];
203203

204-
publicAPI[`removeAll${capitalize(name)}`] = () => (model[name] = []);
204+
publicAPI[`removeAll${capitalize(name)}`] = () => {
205+
model[name] = [];
206+
return model[name];
207+
};
205208
}
206209

207210
// ----------------------------------------------------------------------------

src/Common/Core/LookupTable/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function applyRatio(a, b, ratio) {
1010
}
1111

1212
function interpolateColor(pointA, pointB, scalar) {
13-
var ratio = (scalar - pointA[0]) / (pointB[0] - pointA[0]);
13+
const ratio = (scalar - pointA[0]) / (pointB[0] - pointA[0]);
1414
return [
1515
applyRatio(pointA[1], pointB[1], ratio),
1616
applyRatio(pointA[2], pointB[2], ratio),
@@ -123,7 +123,7 @@ export default class LookupTable {
123123
}
124124

125125
build(trigger) {
126-
var currentControlIdx = 0;
126+
let currentControlIdx = 0;
127127

128128
if (this.colorTable) {
129129
return;
@@ -231,10 +231,10 @@ export default class LookupTable {
231231
}
232232

233233
drawToCanvas(canvas) {
234-
var colors = this.colorTable;
235-
var length = this.scale * colors.length;
236-
var ctx = canvas.getContext('2d');
237-
var canvasData = ctx.getImageData(0, 0, length, 1);
234+
const colors = this.colorTable;
235+
const length = this.scale * colors.length;
236+
const ctx = canvas.getContext('2d');
237+
const canvasData = ctx.getImageData(0, 0, length, 1);
238238

239239
for (let i = 0; i < length; i++) {
240240
const colorIdx = Math.floor(i / this.scale);
@@ -247,7 +247,7 @@ export default class LookupTable {
247247
}
248248

249249
getColor(scalar) {
250-
if (isNaN(scalar)) {
250+
if (Number.isNaN(scalar)) {
251251
return this.colorNaN;
252252
}
253253
const idxValue = Math.floor(

src/Common/Misc/BusyMonitor/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,14 @@ function busyMonitor(publicAPI, model) {
2424
}
2525
};
2626

27-
const success = (...args) => {
27+
const success = (args) => {
2828
checkNotifyStatus(-1);
29-
return new Promise((ok, ko) => {
30-
ok(...args);
31-
});
29+
return Promise.resolve(args);
3230
};
3331

34-
const error = (...args) => {
32+
const error = (args) => {
3533
checkNotifyStatus(-1);
36-
return new Promise((ok, ko) => {
37-
ko(...args);
38-
});
34+
return Promise.reject(args);
3935
};
4036

4137
publicAPI.busy = (promise) => {

src/Common/Misc/CanvasOffscreenBuffer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var offscreenCanvasCount = 0;
1+
let offscreenCanvasCount = 0;
22

33
// Create <canvas/> within the DOM
44
/* global document */

src/Common/Misc/Debounce/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
// leading edge, instead of the trailing.
55

66
export function debounce(func, wait, immediate) {
7-
var timeout;
7+
let timeout;
88
return (...args) => {
9-
var context = this;
10-
var later = () => {
9+
const context = this;
10+
const later = () => {
1111
timeout = null;
1212
if (!immediate) {
1313
func.apply(context, args);
1414
}
1515
};
16-
var callNow = immediate && !timeout;
16+
const callNow = immediate && !timeout;
1717
clearTimeout(timeout);
1818
timeout = setTimeout(later, wait);
1919
if (callNow) {

src/Common/Misc/ImageExporter/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export default class ImageExporter {
1212
}
1313

1414
exportImage(data) {
15-
var xhr = new XMLHttpRequest();
16-
var dataToSend = {};
17-
var ts = Number(this.counter).toString();
15+
const xhr = new XMLHttpRequest();
16+
const dataToSend = {};
17+
let ts = Number(this.counter).toString();
1818
this.counter += 1;
1919

2020
if (!data.canvas || !data.arguments) {
@@ -35,7 +35,7 @@ export default class ImageExporter {
3535

3636
xhr.onload = (e) => {
3737
if (xhr.status === 200) {
38-
return;
38+
console.log('exportImage success');
3939
}
4040
};
4141

@@ -73,7 +73,7 @@ export default class ImageExporter {
7373

7474
xhr.onload = (e) => {
7575
if (xhr.status === 200) {
76-
return;
76+
console.log('updateMetadata success');
7777
}
7878
};
7979

src/Common/Misc/Loop/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
export function loop(reverseOrder, count_, fn) {
2-
var count = count_;
2+
let count = count_;
33
if (reverseOrder) {
4-
while (count) {
5-
count -= 1;
4+
while (count--) {
65
fn(count);
76
}
87
} else {

src/Common/Misc/NumberFormatter/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class NumberFormatter {
3535
}
3636

3737
add(num) {
38-
if (!isFinite(num)) {
38+
if (!Number.isFinite(num)) {
3939
return -1;
4040
}
4141
if (!this.numbers) {
@@ -57,7 +57,7 @@ export default class NumberFormatter {
5757
}
5858

5959
del(num) {
60-
if (!isFinite(num) || !this.numbers) {
60+
if (!Number.isFinite(num) || !this.numbers) {
6161
return -1;
6262
}
6363
if (this.numbers.length > 0) {
@@ -80,7 +80,7 @@ export default class NumberFormatter {
8080
return '∞';
8181
} else if (num === -Infinity) {
8282
return '-∞';
83-
} else if (isNaN(num)) {
83+
} else if (Number.isNaN(num)) {
8484
return 'NaN';
8585
}
8686
const szn = Math.log10(Math.abs(num));
@@ -109,7 +109,7 @@ export default class NumberFormatter {
109109
return num.toFixed(prec - Math.floor(szn));
110110
}
111111
const exponent = -Math.floor(Math.log10(Math.abs(num)) / 3) * 3;
112-
const scaled = Math.pow(10, exponent) * num;
112+
const scaled = 10 ** exponent * num;
113113
// console.log(' sca ', scaled, ' exp ', exponent, ' szn ', szn, ' prec ', prec);
114114
return scaled
115115
.toFixed(prec - Math.ceil(szn + exponent))

src/Common/Misc/SizeHelper/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* global window */
2-
31
import Observable from '../Observable';
42
import { debounce } from '../Debounce';
53

@@ -33,7 +31,7 @@ function updateSize(domElement, cacheObj) {
3331
// ------ New API ------
3432

3533
function getSize(domElement, clearCache = false) {
36-
var cachedSize = domSizes.get(domElement);
34+
let cachedSize = domSizes.get(domElement);
3735
if (!cachedSize || clearCache) {
3836
cachedSize = { timestamp: -1 };
3937
domSizes.set(domElement, cachedSize);

src/Common/Misc/URLExtract/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function toNativeType(str) {
1313
return false;
1414
} else if (str === undefined || str === 'undefined') {
1515
return undefined;
16-
} else if (str === '' || isNaN(str)) {
16+
} else if (str === '' || Number.isNaN(Number(str))) {
1717
return str;
1818
}
1919
return parseFloat(str);

src/Common/Misc/Validate/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export function integer(val) {
33
}
44

55
export function double(val) {
6-
return !isNaN(parseFloat(val));
6+
return !Number.isNaN(Number(val));
77
}
88

99
export function string(val) {

0 commit comments

Comments
 (0)