Skip to content

Commit c6d33b9

Browse files
author
forrest
committed
refactor: eslint default case and regex rules
1 parent f47489e commit c6d33b9

File tree

11 files changed

+46
-45
lines changed

11 files changed

+46
-45
lines changed

Sources/Common/Core/ScalarsToColors/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,16 @@ function vtkScalarsToColors(publicAPI, model) {
351351
break;
352352
}
353353

354-
default:
355-
case VectorMode.MAGNITUDE: {
354+
case VectorMode.RGBCOLORS: {
355+
// publicAPI.mapColorsToColors(
356+
// input, output, inComponents, vectorSize,
357+
// outputFormat);
358+
break;
359+
}
360+
361+
// MAGNITUDE is considered default
362+
case VectorMode.MAGNITUDE:
363+
default: {
356364
const magValues = vtkDataArray.newInstance({
357365
numberOfComponents: 1,
358366
values: new Float32Array(input.getNumberOfTuples()),
@@ -362,13 +370,6 @@ function vtkScalarsToColors(publicAPI, model) {
362370
publicAPI.mapScalarsThroughTable(magValues, output, outputFormat, 0);
363371
break;
364372
}
365-
366-
case VectorMode.RGBCOLORS: {
367-
// publicAPI.mapColorsToColors(
368-
// input, output, inComponents, vectorSize,
369-
// outputFormat);
370-
break;
371-
}
372373
}
373374
};
374375

Sources/Common/DataModel/PiecewiseFunction/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function vtkPiecewiseFunction(publicAPI, model) {
4141
case 1:
4242
functionType = 1; // NonDecreasing
4343
break;
44-
default:
4544
case 2:
45+
default:
4646
functionType = 3; // Varied
4747
break;
4848
}
@@ -53,8 +53,8 @@ function vtkPiecewiseFunction(publicAPI, model) {
5353
case 2:
5454
functionType = 2; // NonIncreasing
5555
break;
56-
default:
5756
case 1:
57+
default:
5858
functionType = 3; // Varied
5959
break;
6060
}
@@ -76,8 +76,8 @@ function vtkPiecewiseFunction(publicAPI, model) {
7676
return 'NonDecreasing';
7777
case 2:
7878
return 'NonIncreasing';
79-
default:
8079
case 3:
80+
default:
8181
return 'Varied';
8282
}
8383
};

Sources/Imaging/Core/ImageInterpolator/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ function vtkImageInterpolator(publicAPI, model) {
9393

9494
publicAPI.interpolatePoint = (interpolationInfo, point, value) => {
9595
switch (model.interpolationMode) {
96-
case InterpolationMode.NEAREST:
97-
default:
98-
publicAPI.interpolateNearest(interpolationInfo, point, value);
99-
break;
10096
case InterpolationMode.LINEAR:
10197
console.log('LINEAR not implemented');
10298
break;
10399
case InterpolationMode.CUBIC:
104100
console.log('CUBIC not implemented');
105101
break;
102+
case InterpolationMode.NEAREST:
103+
default:
104+
publicAPI.interpolateNearest(interpolationInfo, point, value);
105+
break;
106106
}
107107
};
108108

@@ -124,16 +124,16 @@ function vtkImageInterpolator(publicAPI, model) {
124124

125125
publicAPI.interpolateRow = (weights, xIdx, yIdx, zIdx, value, n) => {
126126
switch (model.interpolationMode) {
127-
case InterpolationMode.NEAREST:
128-
default:
129-
publicAPI.interpolateRowNearest(weights, xIdx, yIdx, zIdx, value, n);
130-
break;
131127
case InterpolationMode.LINEAR:
132128
console.log('LINEAR not implemented');
133129
break;
134130
case InterpolationMode.CUBIC:
135131
console.log('CUBIC not implemented');
136132
break;
133+
case InterpolationMode.NEAREST:
134+
default:
135+
publicAPI.interpolateRowNearest(weights, xIdx, yIdx, zIdx, value, n);
136+
break;
137137
}
138138
};
139139

Sources/Imaging/Core/ImageReslice/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -835,10 +835,6 @@ function vtkImageReslice(publicAPI, model) {
835835
switch (dataType) {
836836
case 'Int8Array':
837837
return { min: -128, max: 127 };
838-
case 'Uint8Array':
839-
case 'Uint8ClampedArray':
840-
default:
841-
return { min: 0, max: 255 };
842838
case 'Int16Array':
843839
return { min: -32768, max: 32767 };
844840
case 'Uint16Array':
@@ -851,6 +847,10 @@ function vtkImageReslice(publicAPI, model) {
851847
return { min: -1.2e38, max: 1.2e38 };
852848
case 'Float64Array':
853849
return { min: -1.2e38, max: 1.2e38 };
850+
case 'Uint8Array':
851+
case 'Uint8ClampedArray':
852+
default:
853+
return { min: 0, max: 255 };
854854
}
855855
};
856856

Sources/Rendering/OpenGL/BufferObject/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ function vtkOpenGLBufferObject(publicAPI, model) {
3232
}
3333
/* eslint-disable no-fallthrough */
3434
// Intentional fallthrough in case there is no TEXTURE_BUFFER in WebGL
35-
default:
36-
/* eslint-enable no-fallthrough */
3735
case ObjectType.ARRAY_BUFFER:
36+
default:
3837
return model.context.ARRAY_BUFFER;
38+
/* eslint-enable no-fallthrough */
3939
}
4040
}
4141

Sources/Rendering/OpenGL/RenderWindow/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
528528
default:
529529
return model.context.RGBA8;
530530
}
531-
default:
532531
case VtkDataTypes.FLOAT:
532+
default:
533533
switch (numComps) {
534534
case 1:
535535
return model.context.R16F;

Sources/Rendering/OpenGL/VolumeMapper/index.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
243243
const shadowFactor = '';
244244

245245
switch (model.lastLightComplexity) {
246-
default:
247-
case 0: // no lighting, tcolor is fine as is
248-
break;
249-
250246
case 1: // headlight
251247
case 2: // light kit
252248
case 3: {
@@ -287,7 +283,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
287283
lightNum++;
288284
}
289285
});
286+
break;
290287
}
288+
case 0: // no lighting, tcolor is fine as is
289+
default:
291290
}
292291

293292
shaders.Fragment = FSSource;
@@ -702,11 +701,6 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
702701
const pos2 = new Float64Array(3);
703702
for (let i = 0; i < 6; ++i) {
704703
switch (i) {
705-
default:
706-
case 0:
707-
vec3.set(normal, 1.0, 0.0, 0.0);
708-
vec3.set(pos2, ext[1], ext[3], ext[5]);
709-
break;
710704
case 1:
711705
vec3.set(normal, -1.0, 0.0, 0.0);
712706
vec3.set(pos2, ext[0], ext[2], ext[4]);
@@ -727,6 +721,11 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
727721
vec3.set(normal, 0.0, 0.0, -1.0);
728722
vec3.set(pos2, ext[0], ext[2], ext[4]);
729723
break;
724+
case 0:
725+
default:
726+
vec3.set(normal, 1.0, 0.0, 0.0);
727+
vec3.set(pos2, ext[1], ext[3], ext[5]);
728+
break;
730729
}
731730
vec3.transformMat3(normal, normal, model.idxNormalMatrix);
732731
vec3.transformMat4(pos2, pos2, model.idxToView);
@@ -759,10 +758,6 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
759758

760759
// handle lighting values
761760
switch (model.lastLightComplexity) {
762-
default:
763-
case 0: // no lighting, tcolor is fine as is
764-
break;
765-
766761
case 1: // headlight
767762
case 2: // light kit
768763
case 3: {
@@ -799,7 +794,11 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
799794
}
800795
});
801796
// mat3.transpose(keyMats.normalMatrix, keyMats.normalMatrix);
797+
break;
802798
}
799+
case 0: // no lighting, tcolor is fine as is
800+
default:
801+
break;
803802
}
804803
};
805804

Sources/Rendering/WebGPU/HardwareSelector/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ function vtkWebGPUHardwareSelector(publicAPI, model) {
282282

283283
if (!model.WebGPURenderWindow.getInitialized()) {
284284
model.WebGPURenderWindow.initialize();
285-
await new Promise((resolve) =>
286-
model.WebGPURenderWindow.onInitialized(resolve)
287-
);
285+
await new Promise((resolve) => {
286+
model.WebGPURenderWindow.onInitialized(resolve);
287+
});
288288
}
289289

290290
const webGPURenderer = model.WebGPURenderWindow.getViewNodeFor(renderer);

Sources/Rendering/WebGPU/MapperHelper/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function vtkWebGPUMapperHelper(publicAPI, model) {
114114

115115
// look for replacements to invoke
116116
const scode = model.vertexShaderTemplate + model.fragmentShaderTemplate;
117+
// eslint-disable-next-line prefer-regex-literals
117118
const re = new RegExp('//VTK::[^:]*::', 'g');
118119
const unique = scode.match(re).filter((v, i, a) => a.indexOf(v) === i);
119120
const fnames = unique.map(

Sources/Rendering/WebGPU/PolyDataMapper/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ function vtkWebGPUPolyDataMapper(publicAPI, model) {
386386
return 'triangle-list';
387387
case BufferUsage.Verts:
388388
return 'point-list';
389-
default:
390389
case BufferUsage.Lines:
390+
default:
391391
return 'line-list';
392392
}
393393
};

0 commit comments

Comments
 (0)