Skip to content

Commit

Permalink
style(eslint): Update code to follow rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Jun 18, 2017
1 parent d4cba24 commit 4b82fbe
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 23 deletions.
3 changes: 2 additions & 1 deletion Sources/Common/Core/DataArray/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ function vtkDataArray(publicAPI, model) {
}

// Need to compute ranges...
range = model.ranges[rangeIdx] = computeRange(model.values, componentIndex, model.numberOfComponents);
range = computeRange(model.values, componentIndex, model.numberOfComponents);
model.ranges[rangeIdx] = range;
return [range.min, range.max];
};

Expand Down
1 change: 1 addition & 0 deletions Sources/Common/Core/Math/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { vtkErrorMacro, vtkWarningMacro } = macro;
/* eslint-disable camelcase */
/* eslint-disable no-cond-assign */
/* eslint-disable no-bitwise */
/* eslint-disable no-multi-assign */
// ----------------------------------------------------------------------------
let randomSeedValue = 0;
const VTK_MAX_ROTATIONS = 20;
Expand Down
5 changes: 4 additions & 1 deletion Sources/Common/Core/ScalarsToColors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ function vtkScalarsToColors(publicAPI, model) {

//----------------------------------------------------------------------------
publicAPI.getIndexedColor = (val, rgba) => {
rgba[0] = rgba[1] = rgba[2] = rgba[3] = 0.0;
rgba[0] = 0.0;
rgba[1] = 0.0;
rgba[2] = 0.0;
rgba[3] = 0.0;
};

//----------------------------------------------------------------------------
Expand Down
22 changes: 16 additions & 6 deletions Sources/Common/Transform/LandmarkTransform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ function vtkLandmarkTransform(publicAPI, model) {

// Convert a mat4 matrix to a Matrix 2 dimensions
function mat4To2DArray(mat) {
const output = [[0.0, 0.0, 0.0, 0.0],
const output = [
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0]];
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
];
let cpt = 0;
for (let c = 0; c < 4; c++) {
for (let r = 0; r < 4; r++) {
Expand Down Expand Up @@ -72,9 +74,13 @@ function vtkLandmarkTransform(publicAPI, model) {
// -- build the 3x3 matrix M --

const M = mat3.create();
M[0] = M[4] = M[8] = 0;
M[0] = 0;
M[4] = 0;
M[8] = 0;
const AAT = mat3.create();
AAT[0] = AAT[4] = AAT[8] = 0;
AAT[0] = 0;
AAT[4] = 0;
AAT[8] = 0;

const a = [0, 0, 0];
const b = [0, 0, 0];
Expand Down Expand Up @@ -131,22 +137,26 @@ function vtkLandmarkTransform(publicAPI, model) {
// -- build the 4x4 matrix N --

const N = mat4.create();
N[0] = N[5] = N[10] = N[15] = 0;

N[0] = 0;
N[5] = 0;
N[10] = 0;
N[15] = 0;

// on-diagonal elements
N[0] = M[0] + M[4] + M[8];
N[5] = M[0] - M[4] - M[8];
N[10] = -M[0] + M[4] - M[8];
N[15] = -M[0] - M[4] + M[8];
// off-diagonal elements
/* eslint-disable no-multi-assign */
N[4] = N[1] = (M[7] - M[5]);
N[8] = N[2] = (M[2] - M[6]);
N[12] = N[3] = (M[3] - M[1]);

N[9] = N[6] = (M[3] + M[1]);
N[13] = N[7] = (M[2] + M[6]);
N[14] = N[11] = (M[7] + M[5]);
/* eslint-enable no-multi-assign */

// -- eigen-decompose N (is symmetric) --

Expand Down
9 changes: 6 additions & 3 deletions Sources/Filters/Sources/CubeSource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ function vtkCubeSource(publicAPI, model) {

x[0] = model.center[0] - (model.xLength / 2.0);
n[0] = (-1.0);
n[1] = n[2] = 0.0;
n[1] = 0.0;
n[2] = 0.0;
for (let i = 0; i < 2; i++) {
x[1] = model.center[1] - (model.yLength / 2.0);

Expand Down Expand Up @@ -85,7 +86,8 @@ function vtkCubeSource(publicAPI, model) {

x[1] = model.center[1] - (model.yLength / 2.0);
n[1] = (-1.0);
n[0] = n[2] = 0.0;
n[0] = 0.0;
n[2] = 0.0;
for (let i = 0; i < 2; i++) {
x[0] = model.center[0] - (model.xLength / 2.0);

Expand Down Expand Up @@ -124,7 +126,8 @@ function vtkCubeSource(publicAPI, model) {

x[2] = model.center[2] - (model.zLength / 2.0);
n[2] = (-1.0);
n[0] = n[1] = 0.0;
n[0] = 0.0;
n[1] = 0.0;
for (let i = 0; i < 2; i++) {
x[1] = model.center[1] - (model.yLength / 2.0);

Expand Down
2 changes: 2 additions & 0 deletions Sources/Rendering/Core/Actor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ function vtkActor(publicAPI, model) {
mat4.transpose(tmp4, model.matrix);
bbox.forEach(pt => vec3.transformMat4(pt, pt, tmp4));

/* eslint-disable no-multi-assign */
model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE;
model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE;
/* eslint-enable no-multi-assign */
model.bounds = model.bounds.map((d, i) => ((i % 2 === 0) ?
bbox.reduce((a, b) => (a > b[i / 2] ? b[i / 2] : a), d) :
bbox.reduce((a, b) => (a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a), d)));
Expand Down
2 changes: 2 additions & 0 deletions Sources/Rendering/Core/ImageSlice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ function vtkImageSlice(publicAPI, model) {
mat4.transpose(tmp4, model.matrix);
bbox.forEach(pt => vec3.transformMat4(pt, pt, tmp4));

/* eslint-disable no-multi-assign */
model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE;
model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE;
/* eslint-enable no-multi-assign */
model.bounds = model.bounds.map((d, i) => ((i % 2 === 0) ?
bbox.reduce((a, b) => (a > b[i / 2] ? b[i / 2] : a), d) :
bbox.reduce((a, b) => (a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a), d)));
Expand Down
10 changes: 5 additions & 5 deletions Sources/Rendering/Core/Prop3D/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,21 @@ function vtkProp3D(publicAPI, model) {
publicAPI.getUserMatrix = notImplemented('GetUserMatrix');

function updateIdentityFlag() {
let noChange = true;
[model.origin, model.position].forEach((array) => {
if (array.filter(v => v !== 0).length) {
if (noChange && array.filter(v => v !== 0).length) {
model.isIdentity = false;
return;
noChange = false;
}
});

// if (model.userMatrix || model.userTransform) {
// model.isIdentity = false;
// return;
// noChange = false;
// }

if (model.scale.filter(v => v !== 1).length) {
if (noChange && model.scale.filter(v => v !== 1).length) {
model.isIdentity = false;
return;
}
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/Rendering/Core/Volume/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ function vtkVolume(publicAPI, model) {
mat4.transpose(tmp4, model.matrix);
bbox.forEach(pt => vec3.transformMat4(pt, pt, tmp4));

/* eslint-disable no-multi-assign */
model.bounds[0] = model.bounds[2] = model.bounds[4] = Number.MAX_VALUE;
model.bounds[1] = model.bounds[3] = model.bounds[5] = -Number.MAX_VALUE;
/* eslint-enable no-multi-assign */
model.bounds = model.bounds.map((d, i) => ((i % 2 === 0) ?
bbox.reduce((a, b) => (a > b[i / 2] ? b[i / 2] : a), d) :
bbox.reduce((a, b) => (a < b[(i - 1) / 2] ? b[(i - 1) / 2] : a), d)));
Expand Down
7 changes: 3 additions & 4 deletions Sources/Rendering/OpenGL/HardwareSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
publicAPI.renderCompositeIndex = (index) => {
if (index > 0xffffff) {
vtkErrorMacro('Indices > 0xffffff are not supported.');
return;
}
};

Expand All @@ -169,9 +168,9 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
model.maxAttributeId = (attribid > model.maxAttributeId)
? attribid : model.maxAttributeId;

if (model.currentPass < PassTypes.ID_LOW24) {
return;
}
// if (model.currentPass < PassTypes.ID_LOW24) {
// return; // useless...
// }
};

//----------------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions Sources/Rendering/OpenGL/PolyDataMapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1121,9 +1121,10 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
program.setUniformi('numberOfLights', numberOfLights);

// // we are done unless we have positional lights
if (lastLightComplexity < 3) {
return;
}
// ===> FIXME should be uncommented if we do something below otherwise it is useless
// if (lastLightComplexity < 3) {
// return;
// }

// // if positional lights pass down more parameters
// let lightAttenuation[6][3];
Expand Down

0 comments on commit 4b82fbe

Please sign in to comment.