diff --git a/.eslintrc.json b/.eslintrc.json index 0f1e325c9..592c053ef 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -15,6 +15,7 @@ "import/no-cycle": "error", "import/no-unresolved": "off", "@typescript-eslint/switch-exhaustiveness-check": "error", - "@typescript-eslint/no-inferrable-types": "off" + "@typescript-eslint/no-inferrable-types": "off", + "eqeqeq": "error" } } diff --git a/package.json b/package.json index 3f7cc5b6e..63f80b215 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "test": "jest --coverage", "docs": "typedoc --options typedoc.json", "serve:docs": "http-server docs -p 8081", - "lint:check": "eslint src/ts/**/*.ts", + "lint:check": "eslint 'src/ts/**/**/*.ts'", "lint:fix": "eslint src/ts/**/*.ts --fix" } } diff --git a/src/ts/defaultController/defaultControls.ts b/src/ts/defaultController/defaultControls.ts index cdf74e445..93edf92bb 100644 --- a/src/ts/defaultController/defaultControls.ts +++ b/src/ts/defaultController/defaultControls.ts @@ -90,7 +90,7 @@ export class DefaultControls implements Controls { displacement.addInPlace(upwardDisplacement); displacement.addInPlace(rightDisplacement); - if (input.getAcceleration() != 0) this.speed *= 1 + input.getAcceleration() / 10; + if (input.getAcceleration() !== 0) this.speed *= 1 + input.getAcceleration() / 10; return displacement; } diff --git a/src/ts/planets/telluricPlanet/terrain/chunks/chunkTree.ts b/src/ts/planets/telluricPlanet/terrain/chunks/chunkTree.ts index 9b89780bf..4f8334338 100644 --- a/src/ts/planets/telluricPlanet/terrain/chunks/chunkTree.ts +++ b/src/ts/planets/telluricPlanet/terrain/chunks/chunkTree.ts @@ -169,7 +169,7 @@ export class ChunkTree { * @returns The updated tree */ private updateLODRecursively(observerPositionW: Vector3, chunkForge: ChunkForge, tree: quadTree = this.tree, walked: number[] = []): quadTree { - if (walked.length == this.maxDepth) return tree; + if (walked.length === this.maxDepth) return tree; const nodeRelativePosition = getChunkSphereSpacePositionFromPath(walked, this.direction, this.rootChunkLength / 2, getRotationQuaternion(this.parent)); const nodePositionW = nodeRelativePosition.add(this.parent.getAbsolutePosition()); diff --git a/src/ts/spaceship/shipControls.ts b/src/ts/spaceship/shipControls.ts index f890e2a3c..1a9d17ab6 100644 --- a/src/ts/spaceship/shipControls.ts +++ b/src/ts/spaceship/shipControls.ts @@ -154,6 +154,10 @@ export class ShipControls implements Controls { for (const input of this.inputs) this.listenTo(input, deltaTime); + // camera shake + // this.thirdPersonCamera.alpha += (Math.random() - 0.5) / 500; + // this.thirdPersonCamera.beta += (Math.random() - 0.5) / 500; + this.getActiveCamera().getViewMatrix(true); return this.getTransform().getAbsolutePosition(); } diff --git a/src/ts/spaceship/spaceship.ts b/src/ts/spaceship/spaceship.ts index 412283ce7..ea6608a14 100644 --- a/src/ts/spaceship/spaceship.ts +++ b/src/ts/spaceship/spaceship.ts @@ -246,7 +246,7 @@ export class Spaceship implements Transformable { this.aggregate.body.setAngularDamping(1); } - if (this.state == ShipState.LANDING) { + if (this.state === ShipState.LANDING) { if (this.landingTarget === null) { throw new Error("Closest walkable object is null while landing"); } diff --git a/src/ts/spaceshipExtended/spaceship.ts b/src/ts/spaceshipExtended/spaceship.ts index 2cb1df35b..ce2688890 100644 --- a/src/ts/spaceshipExtended/spaceship.ts +++ b/src/ts/spaceshipExtended/spaceship.ts @@ -176,14 +176,14 @@ export class Spaceship { const spacePressed = keyboard.isPressed(" "); const forwardPressed = keyboard.isAnyPressed(["w", "z"]); - if (spacePressed != this.hoverThrustersRunning) { + if (spacePressed !== this.hoverThrustersRunning) { if (spacePressed) Assets.EngineRunningSound.play(); else Assets.EngineRunningSound.stop(); this.hoverThrustersRunning = spacePressed; } - if (forwardPressed != this.mainThrustersRunning) { + if (forwardPressed !== this.mainThrustersRunning) { if (forwardPressed) Assets.EngineRunningSound.play(); else Assets.EngineRunningSound.stop(); diff --git a/src/ts/spaceshipExtended/thrusterMatrix.ts b/src/ts/spaceshipExtended/thrusterMatrix.ts index adb31dfa8..79f08d315 100644 --- a/src/ts/spaceshipExtended/thrusterMatrix.ts +++ b/src/ts/spaceshipExtended/thrusterMatrix.ts @@ -45,7 +45,7 @@ export function buildThrusterMatrix(hoverThrusters: Thruster[]) { } export function getThrustAndTorque(thrusterConfiguration: number[], thrusterMatrix: Matrix): [Vector3, Vector3] { - if (thrusterMatrix.rows != 6) throw new Error("Thruster matrix must have 6 rows!"); + if (thrusterMatrix.rows !== 6) throw new Error("Thruster matrix must have 6 rows!"); const thrustAndTorque: [number, number, number, number, number, number] = [0, 0, 0, 0, 0, 0]; for (let i = 0; i < thrusterMatrix.rows; i++) { const row = thrusterMatrix.getRow(i); @@ -57,7 +57,7 @@ export function getThrustAndTorque(thrusterConfiguration: number[], thrusterMatr } export function getThrusterConfiguration(targetThrust: Vector3, targetTorque: Vector3, inverseThrusterMatrix: Matrix): number[] { - if (inverseThrusterMatrix.columns != 6) throw new Error("Inverse thruster matrix must have 6 columns!"); + if (inverseThrusterMatrix.columns !== 6) throw new Error("Inverse thruster matrix must have 6 columns!"); const targetThrustAndTorque = [targetThrust.x, targetThrust.y, targetThrust.z, targetTorque.x, targetTorque.y, targetTorque.z]; const nbThrusters = inverseThrusterMatrix.rows; const thrusterConfiguration = new Array(nbThrusters).fill(0); diff --git a/src/ts/starSystem/StarSystemView.ts b/src/ts/starSystem/StarSystemView.ts index 50a747744..78deaea16 100644 --- a/src/ts/starSystem/StarSystemView.ts +++ b/src/ts/starSystem/StarSystemView.ts @@ -337,7 +337,7 @@ export class StarSystemView { unZoom(callback: () => void) { const activeControls = this.scene.getActiveController(); - if (activeControls != this.getSpaceshipControls()) { + if (activeControls !== this.getSpaceshipControls()) { callback(); return; } diff --git a/src/ts/ui/objectOverlay.ts b/src/ts/ui/objectOverlay.ts index 0664d52ba..5dc8d6b62 100644 --- a/src/ts/ui/objectOverlay.ts +++ b/src/ts/ui/objectOverlay.ts @@ -104,7 +104,7 @@ export class ObjectOverlay { const objectRay = this.object.getTransform().getAbsolutePosition().subtract(camera.globalPosition); const distance = objectRay.length(); const deltaDistance = this.lastDistance - distance; - const speed = deltaDistance != 0 ? deltaDistance / (camera.getScene().getEngine().getDeltaTime() / 1000) : 0; + const speed = deltaDistance !== 0 ? deltaDistance / (camera.getScene().getEngine().getDeltaTime() / 1000) : 0; objectRay.scaleInPlace(1 / distance); if (Vector3.Dot(viewRay, objectRay) < 0) {