From 335f6ed984d28694fc5bf7df0d521f013112542f Mon Sep 17 00:00:00 2001 From: Lucas Dower Date: Wed, 13 Apr 2022 20:04:19 +0100 Subject: [PATCH] Updated switch indentation linting --- .eslintrc.json | 7 +- src/ui/elements/vector_spinbox.ts | 42 +++---- .../normal-corrected-ray-voxeliser.ts | 18 +-- src/voxelisers/ray-voxeliser.ts | 18 +-- tools/build-atlas.ts | 104 +++++++++--------- 5 files changed, 96 insertions(+), 93 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1249633..1cf0389 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,7 +19,7 @@ "object-curly-spacing": "off", "max-len": "off", "require-jsdoc": "off", - "indent": ["error", 4], + "indent": ["error", 4, { "SwitchCase": 1 }], "no-multi-spaces": "off", "no-array-constructor": "off", "guard-for-in": "off", @@ -27,6 +27,9 @@ "no-trailing-spaces": "off", "new-cap": "off", "no-console": "warn", - "no-unused-vars": "warn" + "no-unused-vars": "warn", + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "block-spacing": [2, "always"], + "semi": "error" } } diff --git a/src/ui/elements/vector_spinbox.ts b/src/ui/elements/vector_spinbox.ts index 7dbc694..1549f29 100644 --- a/src/ui/elements/vector_spinbox.ts +++ b/src/ui/elements/vector_spinbox.ts @@ -119,18 +119,18 @@ export class VectorSpinboxElement extends LabelledElement { const elementZV = document.getElementById(this._id + '-vz') as HTMLDivElement; switch (this._dragging) { - case EAxis.X: - elementXK.classList.remove('spinbox-key-hover'); - elementXV.classList.remove('spinbox-value-hover'); - break; - case EAxis.Y: - elementYK.classList.remove('spinbox-key-hover'); - elementYV.classList.remove('spinbox-value-hover'); - break; - case EAxis.Z: - elementZK.classList.remove('spinbox-key-hover'); - elementZV.classList.remove('spinbox-value-hover'); - break; + case EAxis.X: + elementXK.classList.remove('spinbox-key-hover'); + elementXV.classList.remove('spinbox-value-hover'); + break; + case EAxis.Y: + elementYK.classList.remove('spinbox-key-hover'); + elementYV.classList.remove('spinbox-value-hover'); + break; + case EAxis.Z: + elementZK.classList.remove('spinbox-key-hover'); + elementZV.classList.remove('spinbox-value-hover'); + break; } this._dragging = EAxis.None; }); @@ -145,15 +145,15 @@ export class VectorSpinboxElement extends LabelledElement { this._lastClientX = e.clientX; switch (this._dragging) { - case EAxis.X: - this._value.x += deltaX; - break; - case EAxis.Y: - this._value.y += deltaX; - break; - case EAxis.Z: - this._value.z += deltaX; - break; + case EAxis.X: + this._value.x += deltaX; + break; + case EAxis.Y: + this._value.y += deltaX; + break; + case EAxis.Z: + this._value.z += deltaX; + break; } const elementXV = document.getElementById(this._id + '-vx') as HTMLDivElement; diff --git a/src/voxelisers/normal-corrected-ray-voxeliser.ts b/src/voxelisers/normal-corrected-ray-voxeliser.ts index b8320e7..c37cffd 100644 --- a/src/voxelisers/normal-corrected-ray-voxeliser.ts +++ b/src/voxelisers/normal-corrected-ray-voxeliser.ts @@ -70,15 +70,15 @@ export class NormalCorrectedRayVoxeliser extends IVoxeliser { let voxelPosition: Vector3; switch (ray.axis) { - case Axes.x: - voxelPosition = new Vector3(Math.round(intersection.x), intersection.y, intersection.z); - break; - case Axes.y: - voxelPosition = new Vector3(intersection.x, Math.round(intersection.y), intersection.z); - break; - case Axes.z: - voxelPosition = new Vector3(intersection.x, intersection.y, Math.round(intersection.z)); - break; + case Axes.x: + voxelPosition = new Vector3(Math.round(intersection.x), intersection.y, intersection.z); + break; + case Axes.y: + voxelPosition = new Vector3(intersection.x, Math.round(intersection.y), intersection.z); + break; + case Axes.z: + voxelPosition = new Vector3(intersection.x, intersection.y, Math.round(intersection.z)); + break; } voxelPosition.round(); diff --git a/src/voxelisers/ray-voxeliser.ts b/src/voxelisers/ray-voxeliser.ts index b656b87..b42629c 100644 --- a/src/voxelisers/ray-voxeliser.ts +++ b/src/voxelisers/ray-voxeliser.ts @@ -60,15 +60,15 @@ export class RayVoxeliser extends IVoxeliser { )); let voxelPosition: Vector3; switch (ray.axis) { - case Axes.x: - voxelPosition = new Vector3(Math.round(intersection.x), intersection.y, intersection.z); - break; - case Axes.y: - voxelPosition = new Vector3(intersection.x, Math.round(intersection.y), intersection.z); - break; - case Axes.z: - voxelPosition = new Vector3(intersection.x, intersection.y, Math.round(intersection.z)); - break; + case Axes.x: + voxelPosition = new Vector3(Math.round(intersection.x), intersection.y, intersection.z); + break; + case Axes.y: + voxelPosition = new Vector3(intersection.x, Math.round(intersection.y), intersection.z); + break; + case Axes.z: + voxelPosition = new Vector3(intersection.x, intersection.y, Math.round(intersection.z)); + break; } let voxelColour: RGB; diff --git a/tools/build-atlas.ts b/tools/build-atlas.ts index a03efce..3840d9b 100644 --- a/tools/build-atlas.ts +++ b/tools/build-atlas.ts @@ -205,58 +205,58 @@ async function buildAtlas() { let faceData: { [face: string]: Texture } = {}; switch (modelData.parent) { - case parentModel.CubeAll: - faceData = { - up: { name: modelData.textures.all }, - down: { name: modelData.textures.all }, - north: { name: modelData.textures.all }, - south: { name: modelData.textures.all }, - east: { name: modelData.textures.all }, - west: { name: modelData.textures.all }, - }; - break; - case parentModel.CubeColumn: - faceData = { - up: { name: modelData.textures.end }, - down: { name: modelData.textures.end }, - north: { name: modelData.textures.side }, - south: { name: modelData.textures.side }, - east: { name: modelData.textures.side }, - west: { name: modelData.textures.side }, - }; - break; - case parentModel.Cube: - faceData = { - up: { name: modelData.textures.up }, - down: { name: modelData.textures.down }, - north: { name: modelData.textures.north }, - south: { name: modelData.textures.south }, - east: { name: modelData.textures.east }, - west: { name: modelData.textures.west }, - }; - break; - case parentModel.TemplateSingleFace: - faceData = { - up: { name: modelData.textures.texture }, - down: { name: modelData.textures.texture }, - north: { name: modelData.textures.texture }, - south: { name: modelData.textures.texture }, - east: { name: modelData.textures.texture }, - west: { name: modelData.textures.texture }, - }; - break; - case parentModel.TemplateGlazedTerracotta: - faceData = { - up: { name: modelData.textures.pattern }, - down: { name: modelData.textures.pattern }, - north: { name: modelData.textures.pattern }, - south: { name: modelData.textures.pattern }, - east: { name: modelData.textures.pattern }, - west: { name: modelData.textures.pattern }, - }; - break; - default: - return; + case parentModel.CubeAll: + faceData = { + up: { name: modelData.textures.all }, + down: { name: modelData.textures.all }, + north: { name: modelData.textures.all }, + south: { name: modelData.textures.all }, + east: { name: modelData.textures.all }, + west: { name: modelData.textures.all }, + }; + break; + case parentModel.CubeColumn: + faceData = { + up: { name: modelData.textures.end }, + down: { name: modelData.textures.end }, + north: { name: modelData.textures.side }, + south: { name: modelData.textures.side }, + east: { name: modelData.textures.side }, + west: { name: modelData.textures.side }, + }; + break; + case parentModel.Cube: + faceData = { + up: { name: modelData.textures.up }, + down: { name: modelData.textures.down }, + north: { name: modelData.textures.north }, + south: { name: modelData.textures.south }, + east: { name: modelData.textures.east }, + west: { name: modelData.textures.west }, + }; + break; + case parentModel.TemplateSingleFace: + faceData = { + up: { name: modelData.textures.texture }, + down: { name: modelData.textures.texture }, + north: { name: modelData.textures.texture }, + south: { name: modelData.textures.texture }, + east: { name: modelData.textures.texture }, + west: { name: modelData.textures.texture }, + }; + break; + case parentModel.TemplateGlazedTerracotta: + faceData = { + up: { name: modelData.textures.pattern }, + down: { name: modelData.textures.pattern }, + north: { name: modelData.textures.pattern }, + south: { name: modelData.textures.pattern }, + east: { name: modelData.textures.pattern }, + west: { name: modelData.textures.pattern }, + }; + break; + default: + return; } for (const face of faces) {