refactor: silence linter on code duplication
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 26 Jul 2023 22:55:11 +0000 (00:55 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 26 Jul 2023 22:55:11 +0000 (00:55 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/charging-station/ChargingStation.ts

index 6f4b4a130d0214095ab7c86fff4538b98f1ee1a8..3be6dfd931712306226100fcea9d500b6e93c5f4 100644 (file)
@@ -1110,9 +1110,11 @@ export class ChargingStation {
 
   private getNumberOfReservationsOnConnectorZero(): number {
     let numberOfReservations = 0;
-    if (this.hasEvses && this.evses.get(0)?.connectors.get(0)?.reservation) {
-      ++numberOfReservations;
-    } else if (this.connectors.get(0)?.reservation) {
+    if (
+      // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
+      (this.hasEvses && this.evses.get(0)?.connectors.get(0)?.reservation) ||
+      (!this.hasEvses && this.connectors.get(0)?.reservation)
+    ) {
       ++numberOfReservations;
     }
     return numberOfReservations;