From: Jérôme Benoit Date: Sat, 5 Mar 2022 21:44:24 +0000 (+0100) Subject: Fix remaining linter errors properly X-Git-Tag: v1.1.52~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c0f4be747574980ada77fd4be1c691637fa69347;p=e-mobility-charging-stations-simulator.git Fix remaining linter errors properly Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index d136a150..7a8e8751 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1401,8 +1401,7 @@ export default class ChargingStation { key: string ): void { if (!Utils.isUndefined(template[deprecatedKey])) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - template[key] = template[deprecatedKey]; + template[key] = template[deprecatedKey] as unknown; delete template[deprecatedKey]; } } diff --git a/src/charging-station/ChargingStationWorker.ts b/src/charging-station/ChargingStationWorker.ts index de0a47fe..6a6f631c 100644 --- a/src/charging-station/ChargingStationWorker.ts +++ b/src/charging-station/ChargingStationWorker.ts @@ -24,10 +24,8 @@ if (Utils.workerPoolInUse()) { addMessageListener(); if (!Utils.isUndefined(workerData)) { startChargingStation({ - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - index: workerData.index as number, - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - templateFile: workerData.templateFile as string, + index: (workerData as Record).index as number, + templateFile: (workerData as Record).templateFile as string, }); } } diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 0e50589a..5cd71f42 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -18,6 +18,9 @@ import { OCPP16RequestCommand, StatusNotificationRequest, } from '../../../types/ocpp/1.6/Requests'; +import MeasurandPerPhaseSampledValueTemplates, { + SampledValueTemplate, +} from '../../../types/MeasurandPerPhaseSampledValueTemplates'; import { MeterValueUnit, MeterValuesRequest, @@ -29,7 +32,6 @@ import { import type ChargingStation from '../../ChargingStation'; import Constants from '../../../utils/Constants'; import { ErrorType } from '../../../types/ocpp/ErrorType'; -import MeasurandPerPhaseSampledValueTemplates from '../../../types/MeasurandPerPhaseSampledValueTemplates'; import MeasurandValues from '../../../types/MeasurandValues'; import { OCPP16BootNotificationResponse } from '../../../types/ocpp/1.6/Responses'; import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode'; @@ -471,8 +473,9 @@ export default class OCPP16RequestService extends OCPPRequestService { const phaseValue = `L${phase}-N`; meterValue.sampledValue.push( OCPP16ServiceUtils.buildSampledValue( - powerPerPhaseSampledValueTemplates[`L${phase}`] ?? powerSampledValueTemplate, - powerMeasurandValues[`L${phase}`], + (powerPerPhaseSampledValueTemplates[`L${phase}`] as SampledValueTemplate) ?? + powerSampledValueTemplate, + powerMeasurandValues[`L${phase}`] as number, null, phaseValue as OCPP16MeterValuePhase ) @@ -651,8 +654,9 @@ export default class OCPP16RequestService extends OCPPRequestService { const phaseValue = `L${phase}`; meterValue.sampledValue.push( OCPP16ServiceUtils.buildSampledValue( - currentPerPhaseSampledValueTemplates[phaseValue] ?? currentSampledValueTemplate, - currentMeasurandValues[phaseValue], + (currentPerPhaseSampledValueTemplates[phaseValue] as SampledValueTemplate) ?? + currentSampledValueTemplate, + currentMeasurandValues[phaseValue] as number, null, phaseValue as OCPP16MeterValuePhase ) diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 0120fdba..702fa582 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -300,8 +300,9 @@ export default class Configuration { if ( sectionName && !Configuration.isUndefined(Configuration.getConfig()[sectionName]) && - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - !Configuration.isUndefined(Configuration.getConfig()[sectionName][key]) + !Configuration.isUndefined(Configuration.getConfig()[sectionName] as Record)[ + key + ] ) { console.error( chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage in section '${sectionName}'${ diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index a72bcbe6..5a98ed99 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -3,6 +3,7 @@ import { Logger, createLogger, format, transport } from 'winston'; import Configuration from './Configuration'; import DailyRotateFile from 'winston-daily-rotate-file'; +import { Format } from 'logform'; import Utils from './Utils'; let transports: transport[]; @@ -36,7 +37,7 @@ if (Configuration.getLogRotate()) { const logger: Logger = createLogger({ level: Configuration.getLogLevel(), - format: format.combine(format.splat(), format[Configuration.getLogFormat()]()), + format: format.combine(format.splat(), (format[Configuration.getLogFormat()] as () => Format)()), transports: transports, }); @@ -47,7 +48,10 @@ const logger: Logger = createLogger({ if (Configuration.getLogConsole()) { logger.add( new Console({ - format: format.combine(format.splat(), format[Configuration.getLogFormat()]()), + format: format.combine( + format.splat(), + (format[Configuration.getLogFormat()] as () => Format)() + ), }) ); }