Fix remaining linter errors properly
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 5 Mar 2022 21:44:24 +0000 (22:44 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 5 Mar 2022 21:44:24 +0000 (22:44 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/charging-station/ChargingStationWorker.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/utils/Configuration.ts
src/utils/Logger.ts

index d136a1504e473d221c5b22cfa1df5fb40eeca143..7a8e8751a1268c11931d434bdcaba2b759d4ddee 100644 (file)
@@ -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];
     }
   }
index de0a47fe5d5745fd29b477ac072c046024922686..6a6f631ca4597809fedafcaaeb696e8c35bd50d1 100644 (file)
@@ -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<string, unknown>).index as number,
+      templateFile: (workerData as Record<string, unknown>).templateFile as string,
     });
   }
 }
index 0e50589a51f9b8c539f8e438f8912c7ddf1e3be9..5cd71f426278f051bca58b17a1c5ad316def3d69 100644 (file)
@@ -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
           )
index 0120fdbaadb102855f8d289bd0d6d155b6546911..702fa582c46e26934d22e1151b761f9c66fa9467 100644 (file)
@@ -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<string, unknown>)[
+        key
+      ]
     ) {
       console.error(
         chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage in section '${sectionName}'${
index a72bcbe6db3bfbbb8042afd93b64ba91a3546224..5a98ed990dad3117e9c0257013fb2e43c80d0b98 100644 (file)
@@ -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)()
+      ),
     })
   );
 }