Fine-tuning the @typescript-eslint/no-unused-vars rule
We now allow parameters to be unused. This is quite common in inherited methods. This allows removing a bunch of: //eslint-disable-next-line @typescript-eslint/no-unused-vars Also, "err" variables in catch MUST now be used and the special _exhaustiveCheck variable used in ":never" assigns can be unused.
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ module.exports = {
|
||||
"eol-last": ["error", "always"],
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"no-throw-literal": "error",
|
||||
"@typescript-eslint/no-unused-vars": ["error"],
|
||||
"@typescript-eslint/no-unused-vars": ["error", { "args": "none", "caughtErrors": "all", "varsIgnorePattern": "_exhaustiveCheck" }],
|
||||
// TODO: remove those ignored rules and write a stronger code!
|
||||
"@typescript-eslint/no-unsafe-call": "off",
|
||||
"@typescript-eslint/restrict-plus-operands": "off",
|
||||
|
||||
@@ -294,7 +294,6 @@ class IframeListener {
|
||||
handleMenuUnregisterEvent(iframeEvent.data.name);
|
||||
} else {
|
||||
// Keep the line below. It will throw an error if we forget to handle one of the possible values.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const _exhaustiveCheck: never = iframeEvent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,6 @@ export function createState(target: "global" | "player"): WorkadventureStateComm
|
||||
}
|
||||
return target.loadVariable(p.toString());
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
set(target: WorkadventureStateCommands, p: PropertyKey, value: unknown, receiver: unknown): boolean {
|
||||
// Note: when using "set", there is no way to wait, so we ignore the return of the promise.
|
||||
// User must use WA.state.saveVariable to have error message.
|
||||
|
||||
@@ -303,8 +303,7 @@ export class RoomConnection implements RoomConnection {
|
||||
}
|
||||
default: {
|
||||
// Security check: if we forget a "case", the line below will catch the error at compile-time.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const tmp: never = subMessage;
|
||||
const _exhaustiveCheck: never = subMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -491,8 +490,7 @@ export class RoomConnection implements RoomConnection {
|
||||
}
|
||||
default: {
|
||||
// Security check: if we forget a "case", the line below will catch the error at compile-time.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const tmp: never = message;
|
||||
const _exhaustiveCheck: never = message;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -97,7 +97,6 @@ export class CameraManager extends Phaser.Events.EventEmitter {
|
||||
});
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
this.camera.pan(setTo.x, setTo.y, duration, Easing.SineEaseOut, true, (camera, progress, x, y) => {
|
||||
if (this.cameraMode === CameraMode.Positioned) {
|
||||
this.waScaleManager.zoomModifier = currentZoomModifier + progress * zoomModifierChange;
|
||||
@@ -139,7 +138,6 @@ export class CameraManager extends Phaser.Events.EventEmitter {
|
||||
this.emit(CameraManagerEvent.CameraUpdate, this.getCameraUpdateEventData());
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
this.camera.pan(focusOn.x, focusOn.y, duration, Easing.SineEaseOut, true, (camera, progress, x, y) => {
|
||||
this.waScaleManager.zoomModifier = currentZoomModifier + progress * zoomModifierChange;
|
||||
if (progress === 1) {
|
||||
|
||||
@@ -1695,7 +1695,6 @@ ${escapedMessage}
|
||||
private createCollisionWithPlayer() {
|
||||
//add collision layer
|
||||
for (const phaserLayer of this.gameMap.phaserLayers) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
this.physics.add.collider(this.CurrentPlayer, phaserLayer, (object1: GameObject, object2: GameObject) => {
|
||||
//this.CurrentPlayer.say("Collision with layer : "+ (object2 as Tile).layer.name)
|
||||
});
|
||||
@@ -1746,11 +1745,9 @@ ${escapedMessage}
|
||||
emoteMenuStore.openEmoteMenu();
|
||||
}
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
this.CurrentPlayer.on(Phaser.Input.Events.POINTER_OVER, (pointer: Phaser.Input.Pointer) => {
|
||||
this.CurrentPlayer.pointerOverOutline(0x365dff);
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
this.CurrentPlayer.on(Phaser.Input.Events.POINTER_OUT, (pointer: Phaser.Input.Pointer) => {
|
||||
this.CurrentPlayer.pointerOutOutline();
|
||||
});
|
||||
@@ -1852,8 +1849,7 @@ ${escapedMessage}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const tmp: never = event;
|
||||
const _exhaustiveCheck: never = event;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export class TexturesHelper {
|
||||
});
|
||||
} catch (error) {
|
||||
rt.destroy();
|
||||
throw new Error("Could not get the snapshot");
|
||||
throw new Error("Could not get the snapshot: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ export class CustomizeScene extends AbstractCharacterScene {
|
||||
this.onResize();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public update(time: number, dt: number): void {
|
||||
this.customWokaPreviewer.update();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,5 @@ export class EmptyScene extends Scene {
|
||||
|
||||
create() {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
update(time: number, delta: number): void {}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ export class EnableCameraScene extends ResizableScene {
|
||||
|
||||
public onResize(): void {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
update(time: number, delta: number): void {}
|
||||
|
||||
public login(): void {
|
||||
|
||||
@@ -49,7 +49,6 @@ export class LoginScene extends ResizableScene {
|
||||
loginSceneVisibleStore.set(false);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
update(time: number, delta: number): void {}
|
||||
|
||||
public onResize(): void {}
|
||||
|
||||
@@ -16,7 +16,6 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
|
||||
gameObjects: Phaser.GameObjects.GameObject[],
|
||||
deltaX: number,
|
||||
deltaY: number,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
deltaZ: number
|
||||
): void {
|
||||
this.gameScene.zoomByFactor(1 - (deltaY / 53) * 0.1);
|
||||
@@ -51,7 +50,6 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public handlePointerDownEvent(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]): void {}
|
||||
|
||||
public handleSpaceKeyUpEvent(event: Event): Event {
|
||||
|
||||
@@ -14,15 +14,6 @@ export function getColorRgbFromHue(hue: number): { r: number; g: number; b: numb
|
||||
return hsv_to_rgb(hue, 0.5, 0.95);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function stringToDouble(string: string): number {
|
||||
let num = 1;
|
||||
for (const char of string.split("")) {
|
||||
num *= char.charCodeAt(0);
|
||||
}
|
||||
return (num % 255) / 255;
|
||||
}
|
||||
|
||||
//todo: test this.
|
||||
function hsv_to_rgb(hue: number, saturation: number, brightness: number): { r: number; g: number; b: number } {
|
||||
const h_i = Math.floor(hue * 6);
|
||||
|
||||
Reference in New Issue
Block a user