Skip to content

Commit

Permalink
fix(ESLint): Fix code to comply with rules
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Hopefully it should be fine, but we never know...
  • Loading branch information
jourdain committed Feb 1, 2018
1 parent f743868 commit 2c01306
Show file tree
Hide file tree
Showing 176 changed files with 2,166 additions and 1,790 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ module.exports = {
'import/no-named-as-default': 0,
'import/no-named-as-default-member': 0,
'prefer-destructuring': 0, // Can have unwanted side effect
'react/jsx-filename-extension': 0,
'jsx-a11y/no-static-element-interactions': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/no-noninteractive-element-interactions': 0,

// Introduced with new eslint
// and no time to fix them...
// [...]
'linebreak-style': 0,
'no-useless-escape': 0,
'no-nested-ternary': 0,
'react/forbid-prop-types': 0,
'react/no-array-index-key': 0,
},
plugins: [
'prettier'
Expand Down
5 changes: 4 additions & 1 deletion src/Common/Core/CompositeClosureHelper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ function dynamicArray(publicAPI, model, name) {

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

publicAPI[`removeAll${capitalize(name)}`] = () => (model[name] = []);
publicAPI[`removeAll${capitalize(name)}`] = () => {
model[name] = [];
return model[name];
};
}

// ----------------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions src/Common/Core/LookupTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function applyRatio(a, b, ratio) {
}

function interpolateColor(pointA, pointB, scalar) {
var ratio = (scalar - pointA[0]) / (pointB[0] - pointA[0]);
const ratio = (scalar - pointA[0]) / (pointB[0] - pointA[0]);
return [
applyRatio(pointA[1], pointB[1], ratio),
applyRatio(pointA[2], pointB[2], ratio),
Expand Down Expand Up @@ -123,7 +123,7 @@ export default class LookupTable {
}

build(trigger) {
var currentControlIdx = 0;
let currentControlIdx = 0;

if (this.colorTable) {
return;
Expand Down Expand Up @@ -231,10 +231,10 @@ export default class LookupTable {
}

drawToCanvas(canvas) {
var colors = this.colorTable;
var length = this.scale * colors.length;
var ctx = canvas.getContext('2d');
var canvasData = ctx.getImageData(0, 0, length, 1);
const colors = this.colorTable;
const length = this.scale * colors.length;
const ctx = canvas.getContext('2d');
const canvasData = ctx.getImageData(0, 0, length, 1);

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

getColor(scalar) {
if (isNaN(scalar)) {
if (Number.isNaN(scalar)) {
return this.colorNaN;
}
const idxValue = Math.floor(
Expand Down
12 changes: 4 additions & 8 deletions src/Common/Misc/BusyMonitor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ function busyMonitor(publicAPI, model) {
}
};

const success = (...args) => {
const success = (args) => {
checkNotifyStatus(-1);
return new Promise((ok, ko) => {
ok(...args);
});
return Promise.resolve(args);
};

const error = (...args) => {
const error = (args) => {
checkNotifyStatus(-1);
return new Promise((ok, ko) => {
ko(...args);
});
return Promise.reject(args);
};

publicAPI.busy = (promise) => {
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Misc/CanvasOffscreenBuffer/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var offscreenCanvasCount = 0;
let offscreenCanvasCount = 0;

// Create <canvas/> within the DOM
/* global document */
Expand Down
8 changes: 4 additions & 4 deletions src/Common/Misc/Debounce/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
// leading edge, instead of the trailing.

export function debounce(func, wait, immediate) {
var timeout;
let timeout;
return (...args) => {
var context = this;
var later = () => {
const context = this;
const later = () => {
timeout = null;
if (!immediate) {
func.apply(context, args);
}
};
var callNow = immediate && !timeout;
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) {
Expand Down
10 changes: 5 additions & 5 deletions src/Common/Misc/ImageExporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class ImageExporter {
}

exportImage(data) {
var xhr = new XMLHttpRequest();
var dataToSend = {};
var ts = Number(this.counter).toString();
const xhr = new XMLHttpRequest();
const dataToSend = {};
let ts = Number(this.counter).toString();
this.counter += 1;

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

xhr.onload = (e) => {
if (xhr.status === 200) {
return;
console.log('exportImage success');
}
};

Expand Down Expand Up @@ -73,7 +73,7 @@ export default class ImageExporter {

xhr.onload = (e) => {
if (xhr.status === 200) {
return;
console.log('updateMetadata success');
}
};

Expand Down
5 changes: 2 additions & 3 deletions src/Common/Misc/Loop/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export function loop(reverseOrder, count_, fn) {
var count = count_;
let count = count_;
if (reverseOrder) {
while (count) {
count -= 1;
while (count--) {
fn(count);
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/Common/Misc/NumberFormatter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class NumberFormatter {
}

add(num) {
if (!isFinite(num)) {
if (!Number.isFinite(num)) {
return -1;
}
if (!this.numbers) {
Expand All @@ -57,7 +57,7 @@ export default class NumberFormatter {
}

del(num) {
if (!isFinite(num) || !this.numbers) {
if (!Number.isFinite(num) || !this.numbers) {
return -1;
}
if (this.numbers.length > 0) {
Expand All @@ -80,7 +80,7 @@ export default class NumberFormatter {
return '∞';
} else if (num === -Infinity) {
return '-∞';
} else if (isNaN(num)) {
} else if (Number.isNaN(num)) {
return 'NaN';
}
const szn = Math.log10(Math.abs(num));
Expand Down Expand Up @@ -109,7 +109,7 @@ export default class NumberFormatter {
return num.toFixed(prec - Math.floor(szn));
}
const exponent = -Math.floor(Math.log10(Math.abs(num)) / 3) * 3;
const scaled = Math.pow(10, exponent) * num;
const scaled = 10 ** exponent * num;
// console.log(' sca ', scaled, ' exp ', exponent, ' szn ', szn, ' prec ', prec);
return scaled
.toFixed(prec - Math.ceil(szn + exponent))
Expand Down
4 changes: 1 addition & 3 deletions src/Common/Misc/SizeHelper/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global window */

import Observable from '../Observable';
import { debounce } from '../Debounce';

Expand Down Expand Up @@ -33,7 +31,7 @@ function updateSize(domElement, cacheObj) {
// ------ New API ------

function getSize(domElement, clearCache = false) {
var cachedSize = domSizes.get(domElement);
let cachedSize = domSizes.get(domElement);
if (!cachedSize || clearCache) {
cachedSize = { timestamp: -1 };
domSizes.set(domElement, cachedSize);
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Misc/URLExtract/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function toNativeType(str) {
return false;
} else if (str === undefined || str === 'undefined') {
return undefined;
} else if (str === '' || isNaN(str)) {
} else if (str === '' || Number.isNaN(Number(str))) {
return str;
}
return parseFloat(str);
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Misc/Validate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function integer(val) {
}

export function double(val) {
return !isNaN(parseFloat(val));
return !Number.isNaN(Number(val));
}

export function string(val) {
Expand Down
Loading

0 comments on commit 2c01306

Please sign in to comment.