How to automatically fix ESlint no-unused-expressions, no-sequences

26 Views Asked by At

So I got the following code snippet from minimized JavaScript code that shows ESlint errors, no-unused-expressions", "no-sequences".

export class EventsHandler {
    onDestroy() {
        this.eventHandler.removeListener(this.leftClickHandle),
            (this.leftClickHandle = null),
            this.eventHandler.removeListener(this.rightClickHandle),
            (this.rightClickHandle = null),
            this.eventHandler.removeListener(this.mouseDownHandle),
            (this.mouseDownHandle = null),
            this.eventHandler.removeListener(this.mouseUpHandle),
            (this.mouseUpHandle = null),
            this.eventHandler.removeListener(this.mouseMoveHandle),
            (this.mouseMoveHandle = null);
    }
}

Of course, I can fix all ESlint errors manually, but it would be time-consuming.
I want to automatically fix ESlint's "no-unused-expressions", "no-sequences" for the above code.
This is what I want.

export class EventsHandler {
    onDestroy() {
        this.eventHandler.removeListener(this.leftClickHandle);
        this.leftClickHandle = null;
        this.eventHandler.removeListener(this.rightClickHandle);
        this.rightClickHandle = null;
        this.eventHandler.removeListener(this.mouseDownHandle);
        this.mouseDownHandle = null;
        this.eventHandler.removeListener(this.mouseUpHandle);
        this.mouseUpHandle = null;
        this.eventHandler.removeListener(this.mouseMoveHandle);
        this.mouseMoveHandle = null;
    }
}

Is this possible?
Any idea or suggestion would be thankful.

0

There are 0 best solutions below