Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
BarthPaleologue committed Jan 28, 2024
1 parent 4ce44de commit 59fe055
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion src/ts/defaultController/defaultControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/planets/telluricPlanet/terrain/chunks/chunkTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 4 additions & 0 deletions src/ts/spaceship/shipControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/spaceship/spaceship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
4 changes: 2 additions & 2 deletions src/ts/spaceshipExtended/spaceship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions src/ts/spaceshipExtended/thrusterMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ts/starSystem/StarSystemView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/ui/objectOverlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 59fe055

Please sign in to comment.