From 55a17ee03b588b4cd5b14276b1f103bcdd3ec0a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 22 Nov 2024 13:54:23 +0100 Subject: [PATCH] fix: ensure undefined is handled at computing power limitation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit closes #1223 Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 12 ++++-------- ui/web/src/composables/Utils.ts | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 45a2f94e..ed7449a9 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -419,19 +419,15 @@ export class ChargingStation extends EventEmitter { const connectorChargingProfilesLimit = getConnectorChargingProfilesLimit(this, connectorId) return min( Number.isNaN(connectorMaximumPower) ? Number.POSITIVE_INFINITY : connectorMaximumPower, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - Number.isNaN(connectorAmperageLimitationLimit!) + connectorAmperageLimitationLimit == null || Number.isNaN(connectorAmperageLimitationLimit) ? Number.POSITIVE_INFINITY - : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - connectorAmperageLimitationLimit!, + : connectorAmperageLimitationLimit, Number.isNaN(chargingStationChargingProfilesLimit) ? Number.POSITIVE_INFINITY : chargingStationChargingProfilesLimit, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - Number.isNaN(connectorChargingProfilesLimit!) + connectorChargingProfilesLimit == null || Number.isNaN(connectorChargingProfilesLimit) ? Number.POSITIVE_INFINITY - : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - connectorChargingProfilesLimit! + : connectorChargingProfilesLimit ) } diff --git a/ui/web/src/composables/Utils.ts b/ui/web/src/composables/Utils.ts index 5fcc4093..d34749e4 100644 --- a/ui/web/src/composables/Utils.ts +++ b/ui/web/src/composables/Utils.ts @@ -29,7 +29,7 @@ export const convertToInt = (value: unknown): number => { if (typeof value === 'string') { changedValue = Number.parseInt(value) } - if (isNaN(changedValue)) { + if (Number.isNaN(changedValue)) { // eslint-disable-next-line @typescript-eslint/no-base-to-string throw new Error(`Cannot convert to integer: '${value.toString()}'`) } -- 2.34.1