Skip to content

Commit

Permalink
fix(ESLint): Update lint rules while fixing code base
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Oct 12, 2016
1 parent 00b3ced commit a451b5a
Show file tree
Hide file tree
Showing 34 changed files with 213 additions and 216 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
// Not for us ;-)
'jsx-a11y/label-has-for': 0,
'no-console': 0,
'no-plusplus': 0,

// Not for vtk.js
'import/no-named-as-default': 0,
Expand Down
3 changes: 2 additions & 1 deletion Sources/Common/Core/Math/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// ----------------------------------------------------------------------------
/* eslint-disable camelcase */
/* eslint-disable no-cond-assign */
/* eslint-disable no-bitwise */
// ----------------------------------------------------------------------------
const VTK_MAX_ROTATIONS = 20;
const VTK_SMALL_NUMBER = 1.0e-12;

function notImplemented(method) {
return () => console.log('vtkMath::${method} - NOT IMPLEMENTED');
return () => console.log(`vtkMath::${method} - NOT IMPLEMENTED`);
}

function vtkSwapVectors3(v1, v2) {
Expand Down
12 changes: 6 additions & 6 deletions Sources/Common/DataModel/BoundingBox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function vtkBoundingBox(publicAPI, model) {
/* eslint-enable no-use-before-define */
};

publicAPI.equals = other => {
publicAPI.equals = (other) => {
const a = model.bounds;
const b = other.getBounds();
return a[0] === b[0]
Expand Down Expand Up @@ -164,13 +164,13 @@ function vtkBoundingBox(publicAPI, model) {
];
};

publicAPI.addBox = other => {
publicAPI.addBox = (other) => {
publicAPI.addBounds(...other.getBounds());
};

publicAPI.isValid = () => isValid(model.bounds);

publicAPI.intersect = bbox => {
publicAPI.intersect = (bbox) => {
if (!(publicAPI.isValid() && bbox.isValid())) {
return false;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ function vtkBoundingBox(publicAPI, model) {
return true;
};

publicAPI.intersects = bbox => {
publicAPI.intersects = (bbox) => {
if (!(publicAPI.isValid() && bbox.isValid())) {
return false;
}
Expand Down Expand Up @@ -326,7 +326,7 @@ function vtkBoundingBox(publicAPI, model) {
publicAPI.getMaxPoint = () => [model.bounds[1], model.bounds[3], model.bounds[5]];
publicAPI.getBound = index => model.bound[index];

publicAPI.contains = bbox => {
publicAPI.contains = (bbox) => {
// if either box is not valid or they don't intersect
if (!publicAPI.intersects(bbox)) {
return false;
Expand All @@ -351,7 +351,7 @@ function vtkBoundingBox(publicAPI, model) {

publicAPI.reset = () => publicAPI.setBounds([].concat(INIT_BOUNDS));

publicAPI.inflate = delta => {
publicAPI.inflate = (delta) => {
model.bounds = model.bounds.map((value, index) => {
if (index % 2 === 0) {
return value - delta;
Expand Down
6 changes: 3 additions & 3 deletions Sources/Common/DataModel/DataSetAttributes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function vtkDataSetAttributes(publicAPI, model) {
return null;
};

publicAPI.addArray = array => {
publicAPI.addArray = (array) => {
if (model.arrays[array.getName()]) {
throw new Error('Array with same name already exist', array, model.arrays);
}
Expand All @@ -84,7 +84,7 @@ function vtkDataSetAttributes(publicAPI, model) {

// Process dataArrays if any
if (model.dataArrays && Object.keys(model.dataArrays).length) {
Object.keys(model.dataArrays).forEach(name => {
Object.keys(model.dataArrays).forEach((name) => {
if (!model.dataArrays[name].ref && model.dataArrays[name].type === 'vtkDataArray') {
publicAPI.addArray(vtkDataArray.newInstance(model.dataArrays[name]));
}
Expand All @@ -97,7 +97,7 @@ function vtkDataSetAttributes(publicAPI, model) {
const copyInst = newInstance(newIntsanceModel);

// Shallow copy each array
publicAPI.getArrayNames().forEach(name => {
publicAPI.getArrayNames().forEach((name) => {
copyInst.addArray(publicAPI.getArray(name).shallowCopy());
});

Expand Down
4 changes: 2 additions & 2 deletions Sources/Common/DataModel/PolyData/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function vtkPolyData(publicAPI, model) {
}

// build empty cell arrays and set methods
['Verts', 'Lines', 'Polys', 'Strips'].forEach(type => {
['Verts', 'Lines', 'Polys', 'Strips'].forEach((type) => {
const lowerType = type.toLowerCase();
// Don't create array if already available
if (model[lowerType]) {
Expand All @@ -50,7 +50,7 @@ function vtkPolyData(publicAPI, model) {
];

// Start to shallow copy each piece
fieldList.forEach(field => {
fieldList.forEach((field) => {
modelInstance[field] = model[field].shallowCopy();
});

Expand Down
4 changes: 2 additions & 2 deletions Sources/Filters/Sources/ConeSource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export function vtkConeSource(publicAPI, model) {
};

// Add parameter used to create dataset as metadata.state[*]
['height', 'radius', 'resolution', 'capping'].forEach(field => {
['height', 'radius', 'resolution', 'capping'].forEach((field) => {
state[field] = model[field];
});
['center', 'direction'].forEach(field => {
['center', 'direction'].forEach((field) => {
state[field] = [].concat(model[field]);
});

Expand Down
4 changes: 2 additions & 2 deletions Sources/Filters/Sources/SphereSource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export function vtkSphereSource(publicAPI, model) {
};

// Add parameter used to create dataset as metadata.state[*]
['radius', 'latLongTessellation', 'thetaResolution', 'startTheta', 'endTheta', 'phiResolution', 'startPhi', 'endPhi'].forEach(field => {
['radius', 'latLongTessellation', 'thetaResolution', 'startTheta', 'endTheta', 'phiResolution', 'startPhi', 'endPhi'].forEach((field) => {
state[field] = model[field];
});
['center'].forEach(field => {
['center'].forEach((field) => {
state[field] = [].concat(model[field]);
});

Expand Down
34 changes: 17 additions & 17 deletions Sources/IO/Core/HttpDataSetReader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const GEOMETRY_ARRAYS = {
vtkPolyData(dataset) {
const arrayToDownload = [];
arrayToDownload.push(dataset.vtkPolyData.Points);
Object.keys(dataset.vtkPolyData).forEach(cellName => {
Object.keys(dataset.vtkPolyData).forEach((cellName) => {
if (dataset.vtkPolyData[cellName]) {
arrayToDownload.push(dataset.vtkPolyData[cellName]);
}
Expand Down Expand Up @@ -49,7 +49,7 @@ const GEOMETRY_ARRAYS = {

vtkMultiBlock(dataset) {
let arrayToDownload = [];
Object.keys(dataset.vtkMultiBlock.Blocks).forEach(blockName => {
Object.keys(dataset.vtkMultiBlock.Blocks).forEach((blockName) => {
const fn = GEOMETRY_ARRAYS[dataset.vtkMultiBlock.Blocks[blockName].type];
if (fn) {
arrayToDownload = [].concat(arrayToDownload, fn(dataset.vtkMultiBlock.Blocks[blockName]));
Expand Down Expand Up @@ -79,7 +79,7 @@ export function vtkHttpDataSetReader(publicAPI, model) {
const xhr = new XMLHttpRequest();
const url = [model.baseURL, array.ref.basepath, fetchGzip ? `${array.ref.id}.gz` : array.ref.id].join('/');

xhr.onreadystatechange = e => {
xhr.onreadystatechange = (e) => {
if (xhr.readyState === 1) {
array.ref.pending = true;
if (++model.requestCount === 1) {
Expand Down Expand Up @@ -143,17 +143,17 @@ export function vtkHttpDataSetReader(publicAPI, model) {
// Internal method to fill block information and state
function fillBlocks(dataset, block, arraysToList, enable) {
if (dataset.type === 'vtkMultiBlock') {
Object.keys(dataset.MultiBlock.Blocks).forEach(blockName => {
Object.keys(dataset.MultiBlock.Blocks).forEach((blockName) => {
block[blockName] = fillBlocks(dataset.MultiBlock.Blocks[blockName], {}, arraysToList, enable);
block[blockName].enable = enable;
});
} else {
block.type = dataset.type;
block.enable = enable;
const container = dataset[dataset.type];
LOCATIONS.forEach(location => {
LOCATIONS.forEach((location) => {
if (container[location]) {
Object.keys(container[location]).forEach(name => {
Object.keys(container[location]).forEach((name) => {
if (arraysToList[`${location}_:|:_${name}`]) {
arraysToList[`${location}_:|:_${name}`].ds.push(container);
} else {
Expand All @@ -176,7 +176,7 @@ export function vtkHttpDataSetReader(publicAPI, model) {

// Find corresponding datasetBlock
if (root.MultiBlock && root.MultiBlock.Blocks) {
Object.keys(root.MultiBlock.Blocks).forEach(blockName => {
Object.keys(root.MultiBlock.Blocks).forEach((blockName) => {
if (enable) {
return;
}
Expand All @@ -203,7 +203,7 @@ export function vtkHttpDataSetReader(publicAPI, model) {
const xhr = new XMLHttpRequest();
let dataset = model.dataset;

xhr.onreadystatechange = e => {
xhr.onreadystatechange = (e) => {
if (xhr.readyState === 1) {
if (++model.requestCount === 1) {
publicAPI.invokeBusy(true);
Expand All @@ -227,14 +227,14 @@ export function vtkHttpDataSetReader(publicAPI, model) {
model.blocks = {};
const arraysToList = {};
fillBlocks(dataset, model.blocks, arraysToList, enable);
Object.keys(arraysToList).forEach(id => {
Object.keys(arraysToList).forEach((id) => {
model.arrays.push(arraysToList[id]);
});
} else {
// Regular dataset
LOCATIONS.forEach(location => {
LOCATIONS.forEach((location) => {
if (container[location]) {
Object.keys(container[location]).forEach(name => {
Object.keys(container[location]).forEach((name) => {
model.arrays.push({ name, enable, location, ds: [container] });
});
}
Expand All @@ -243,19 +243,19 @@ export function vtkHttpDataSetReader(publicAPI, model) {

// Fetch geometry arrays
const pendingPromises = [];
GEOMETRY_ARRAYS[dataset.type](dataset).forEach(array => {
GEOMETRY_ARRAYS[dataset.type](dataset).forEach((array) => {
pendingPromises.push(fetchArray(array, model.fetchGzip));
});

// Wait for all geometry array to be fetched
if (pendingPromises.length) {
Promise.all(pendingPromises)
.then(
ok => {
(ok) => {
model.output[0] = vtk(dataset);
resolve(publicAPI, model.output[0]);
},
err => {
(err) => {
reject(err);
}
);
Expand All @@ -276,7 +276,7 @@ export function vtkHttpDataSetReader(publicAPI, model) {
});

// Set DataSet url
publicAPI.setUrl = url => {
publicAPI.setUrl = (url) => {
if (url.indexOf('index.json') === -1) {
model.baseURL = url;
model.url = `${url}/index.json`;
Expand All @@ -301,8 +301,8 @@ export function vtkHttpDataSetReader(publicAPI, model) {
const arrayMappingFunc = [];
model.arrays
.filter(array => array.enable)
.forEach(array => {
array.ds.forEach(ds => {
.forEach((array) => {
array.ds.forEach((ds) => {
if (isDatasetEnable(datasetStruct, model.blocks, ds)) {
if (ds[array.location][array.name].ref) {
arrayToFecth.push(ds[array.location][array.name]);
Expand Down
Loading

0 comments on commit a451b5a

Please sign in to comment.