From: Jérôme Benoit Date: Thu, 25 Jul 2024 18:04:00 +0000 (+0200) Subject: build(ci): reenabled auto code formating and linting on simulator X-Git-Tag: ocpp-server@v1.5.1~18 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1e4b13ce2da1be9ee2437dd057d477309168b716;p=e-mobility-charging-stations-simulator.git build(ci): reenabled auto code formating and linting on simulator Signed-off-by: Jérôme Benoit --- diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index dbfdb997..8492b788 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -30,8 +30,7 @@ jobs: - run: pnpm install --ignore-scripts - # - run: pnpm format - - run: pnpm lint:fix + - run: pnpm format - working-directory: ui/web run: | diff --git a/.lintstagedrc.js b/.lintstagedrc.js index 45396f97..0eef8bcc 100644 --- a/.lintstagedrc.js +++ b/.lintstagedrc.js @@ -1,8 +1,5 @@ export default { - '{src,tests}/**/*.{ts,tsx,cts,mts}': [ - // 'prettier --cache --write', - 'eslint --cache --fix', - ], + '{src,tests}/**/*.{ts,tsx,cts,mts}': ['prettier --cache --write', 'eslint --cache --fix'], '**/*.{json,md,yml,yaml}': ['prettier --cache --write'], '**/*.{js,jsx,cjs,mjs}': ['prettier --cache --write', 'eslint --cache --fix'], } diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 3cfe3253..02419444 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -229,8 +229,7 @@ export class AutomaticTransactionGenerator { ) ) logger.info( - `${this.logPrefix(connectorId)} transaction started with id ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${this.logPrefix(connectorId)} transaction started with id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions this.chargingStation .getConnectorStatus(connectorId) ?.transactionId?.toString()} and will stop in ${formatDurationMilliSeconds(waitTrxEnd)}` @@ -341,8 +340,7 @@ export class AutomaticTransactionGenerator { const connectorStatus = this.chargingStation.getConnectorStatus(connectorId) if (connectorStatus?.transactionStarted === true) { logger.info( - `${this.logPrefix(connectorId)} entered in transaction loop while a transaction ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${this.logPrefix(connectorId)} entered in transaction loop while a transaction ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions connectorStatus.transactionId?.toString()} is already started on connector ${connectorId.toString()}` ) return false @@ -386,8 +384,7 @@ export class AutomaticTransactionGenerator { while (connectorStatus?.transactionStarted === true) { if (!logged) { logger.info( - `${this.logPrefix(connectorId)} transaction loop waiting for started transaction ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${this.logPrefix(connectorId)} transaction loop waiting for started transaction ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions connectorStatus.transactionId?.toString()} on connector ${connectorId.toString()} to be stopped` ) logged = true diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 6f6ac3e3..dfd91916 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -227,14 +227,14 @@ export class Bootstrap extends EventEmitter { chalk.green( `Charging stations simulator ${this.version} started with ${this.numberOfConfiguredChargingStations.toString()} configured and ${this.numberOfProvisionedChargingStations.toString()} provisioned charging station(s) from ${this.numberOfChargingStationTemplates.toString()} charging station template(s) and ${ Configuration.workerDynamicPoolInUse() - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - ? `${workerConfiguration.poolMinSize?.toString()}/` + ? // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${workerConfiguration.poolMinSize?.toString()}/` : '' // eslint-disable-next-line @typescript-eslint/restrict-template-expressions }${this.workerImplementation?.size.toString()}${ Configuration.workerPoolInUse() - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - ? `/${workerConfiguration.poolMaxSize?.toString()}` + ? // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `/${workerConfiguration.poolMaxSize?.toString()}` : '' // eslint-disable-next-line @typescript-eslint/restrict-template-expressions } worker(s) concurrently running in '${workerConfiguration.processType}' mode${ diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 32b04650..866302b0 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -427,16 +427,16 @@ export class ChargingStation extends EventEmitter { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion isNaN(connectorAmperageLimitationLimit!) ? Number.POSITIVE_INFINITY - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - : connectorAmperageLimitationLimit!, + : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + connectorAmperageLimitationLimit!, isNaN(chargingStationChargingProfilesLimit) ? Number.POSITIVE_INFINITY : chargingStationChargingProfilesLimit, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion isNaN(connectorChargingProfilesLimit!) ? Number.POSITIVE_INFINITY - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - : connectorChargingProfilesLimit! + : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + connectorChargingProfilesLimit! ) } diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index d234dced..d40bce23 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -438,8 +438,7 @@ export const initializeConnectorsMapStatus = ( for (const connectorId of connectors.keys()) { if (connectorId > 0 && connectors.get(connectorId)?.transactionStarted === true) { logger.warn( - `${logPrefix} Connector id ${connectorId.toString()} at initialization has a transaction started with id ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${logPrefix} Connector id ${connectorId.toString()} at initialization has a transaction started with id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions connectors.get(connectorId)?.transactionId?.toString()}` ) } @@ -798,8 +797,8 @@ const buildChargingProfilesLimit = ( case CurrentType.DC: return chargingProfile.chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT ? limit - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - : DCElectricUtils.power(chargingStation.stationInfo.voltageOut!, limit) + : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + DCElectricUtils.power(chargingStation.stationInfo.voltageOut!, limit) default: logger.error( `${chargingStation.logPrefix()} ${moduleName}.buildChargingProfilesLimit: ${errorMsg}` diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 1204e2b3..eae051ad 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -347,8 +347,7 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId.toString()}, transaction id ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }: connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions connector?.transactionId?.toString()}, value: ${socMinimumValue.toString()}/${ meterValue.sampledValue[sampledValuesIndex].value }/${socMaximumValue.toString()}` @@ -681,8 +680,7 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId.toString()}, transaction id ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }: connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions connector?.transactionId?.toString()}, value: ${connectorMinimumPowerRounded.toString()}/${ meterValue.sampledValue[sampledValuesIndex].value }/${connectorMaximumPowerRounded.toString()}` @@ -729,8 +727,7 @@ export const buildMeterValue = ( }: phase ${ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions meterValue.sampledValue[sampledValuesPerPhaseIndex].phase - }, connector id ${connectorId.toString()}, transaction id ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }, connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions connector?.transactionId?.toString()}, value: ${connectorMinimumPowerPerPhaseRounded.toString()}/${ meterValue.sampledValue[sampledValuesPerPhaseIndex].value }/${connectorMaximumPowerPerPhaseRounded.toString()}` @@ -943,8 +940,7 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId.toString()}, transaction id ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }: connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions connector?.transactionId?.toString()}, value: ${connectorMinimumAmperage.toString()}/${ meterValue.sampledValue[sampledValuesIndex].value }/${connectorMaximumAmperage.toString()}` @@ -981,8 +977,7 @@ export const buildMeterValue = ( }: phase ${ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions meterValue.sampledValue[sampledValuesPerPhaseIndex].phase - }, connector id ${connectorId.toString()}, transaction id ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }, connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions connector?.transactionId?.toString()}, value: ${connectorMinimumAmperage.toString()}/${ meterValue.sampledValue[sampledValuesPerPhaseIndex].value }/${connectorMaximumAmperage.toString()}` @@ -1057,8 +1052,7 @@ export const buildMeterValue = ( `${chargingStation.logPrefix()} MeterValues measurand ${ meterValue.sampledValue[sampledValuesIndex].measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER - }: connector id ${connectorId.toString()}, transaction id ${ - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + }: connector id ${connectorId.toString()}, transaction id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions connector?.transactionId?.toString()}, value: ${connectorMinimumEnergyRounded.toString()}/${energyValueRounded.toString()}/${connectorMaximumEnergyRounded.toString()}, duration: ${interval.toString()}ms` ) }