From: Jérôme Benoit Date: Fri, 12 Jan 2024 17:48:24 +0000 (+0100) Subject: refactor: refine prettier configuration X-Git-Tag: v1.2.32~34 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a974c8e4b8a98c9450be49546a77be0d03e9f512;p=e-mobility-charging-stations-simulator.git refactor: refine prettier configuration Signed-off-by: Jérôme Benoit --- diff --git a/.prettierrc.json b/.prettierrc.json index 6632aaeb..066e89fc 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,7 +1,8 @@ { "$schema": "https://json.schemastore.org/prettierrc", "printWidth": 100, - "semi": false, + "arrowParens": "avoid", "singleQuote": true, + "semi": false, "trailingComma": "none" } diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 04205db6..c0dc2b3d 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -424,7 +424,7 @@ export class Bootstrap extends EventEmitter { exit(exitCodes.gracefulShutdownError) }) }) - .catch((error) => { + .catch(error => { console.error(chalk.red('Error while shutdowning charging stations simulator: '), error) exit(exitCodes.gracefulShutdownError) }) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index ca8a82a5..9efe7b30 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -518,7 +518,7 @@ export class ChargingStation extends EventEmitter { this.heartbeatSetInterval = setInterval(() => { this.ocppRequestService .requestHandler(this, RequestCommand.HEARTBEAT) - .catch((error) => { + .catch(error => { logger.error( `${this.logPrefix()} Error while sending '${RequestCommand.HEARTBEAT}':`, error @@ -603,7 +603,7 @@ export class ChargingStation extends EventEmitter { meterValue: [meterValue] } ) - .catch((error) => { + .catch(error => { logger.error( `${this.logPrefix()} Error while sending '${RequestCommand.METER_VALUES}':`, error @@ -1264,7 +1264,7 @@ export class ChargingStation extends EventEmitter { this.initializeOcppConfiguration() this.initializeOcppServices() this.once(ChargingStationEvents.accepted, () => { - this.startMessageSequence().catch((error) => { + this.startMessageSequence().catch(error => { logger.error(`${this.logPrefix()} Error while starting the message sequence:`, error) }) }) @@ -1710,7 +1710,7 @@ export class ChargingStation extends EventEmitter { this.sharedLRUCache.deleteChargingStationConfiguration(this.configurationFileHash) this.sharedLRUCache.setChargingStationConfiguration(configurationData) this.configurationFileHash = configurationHash - }).catch((error) => { + }).catch(error => { handleFileException( this.configurationFile, FileType.ChargingStationConfiguration, diff --git a/src/charging-station/ConfigurationKeyUtils.ts b/src/charging-station/ConfigurationKeyUtils.ts index bb0d9978..075a4979 100644 --- a/src/charging-station/ConfigurationKeyUtils.ts +++ b/src/charging-station/ConfigurationKeyUtils.ts @@ -21,7 +21,7 @@ export const getConfigurationKey = ( key: ConfigurationKeyType, caseInsensitive = false ): ConfigurationKey | undefined => { - return chargingStation.ocppConfiguration?.configurationKey?.find((configElement) => { + return chargingStation.ocppConfiguration?.configurationKey?.find(configElement => { if (caseInsensitive) { return configElement.key.toLowerCase() === key.toLowerCase() } diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index c2694498..f15bb084 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -374,7 +374,7 @@ export const resetConnectorStatus = (connectorStatus: ConnectorStatus | undefine connectorStatus.chargingProfiles = connectorStatus.transactionId != null && isNotEmptyArray(connectorStatus.chargingProfiles) ? connectorStatus.chargingProfiles?.filter( - (chargingProfile) => chargingProfile.transactionId !== connectorStatus.transactionId + chargingProfile => chargingProfile.transactionId !== connectorStatus.transactionId ) : [] connectorStatus.idTagLocalAuthorized = false @@ -662,7 +662,7 @@ export const waitChargingStationEvents = async ( event: ChargingStationWorkerMessageEvents, eventsToWait: number ): Promise => { - return await new Promise((resolve) => { + return await new Promise(resolve => { let events = 0 if (eventsToWait === 0) { resolve(events) diff --git a/src/charging-station/IdTagsCache.ts b/src/charging-station/IdTagsCache.ts index f00a5589..d1ad32d2 100644 --- a/src/charging-station/IdTagsCache.ts +++ b/src/charging-station/IdTagsCache.ts @@ -178,7 +178,7 @@ export class IdTagsCache { deleted.push(this.idTagsCachesAddressableIndexes.delete(key)) } } - return !deleted.some((value) => !value) + return !deleted.some(value => !value) } private getIdTagsCacheIndexesAddressableKey (prefix: string, uid: string): string { diff --git a/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts index 3e34782f..3a0c75b7 100644 --- a/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts @@ -78,7 +78,7 @@ export class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChannel { } return undefined }) - .filter((hashId) => hashId != null) as string[], + .filter(hashId => hashId != null) as string[], ...(responsesStatus === ResponseStatus.FAILURE && { hashIdsFailed: this.responses .get(uuid) @@ -88,18 +88,18 @@ export class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChannel { } return undefined }) - .filter((hashId) => hashId != null) as string[] + .filter(hashId => hashId != null) as string[] }), ...(responsesStatus === ResponseStatus.FAILURE && { responsesFailed: this.responses .get(uuid) - ?.responses.map((response) => { + ?.responses.map(response => { if (response.status === ResponseStatus.FAILURE) { return response } return undefined }) - .filter((response) => response != null) as BroadcastChannelResponsePayload[] + .filter(response => response != null) as BroadcastChannelResponsePayload[] }) } } diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index d4b3c630..9d661dc6 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -1290,8 +1290,8 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { let ftpClient: Client | undefined try { const logFiles = readdirSync(resolve(dirname(fileURLToPath(import.meta.url)), '../')) - .filter((file) => file.endsWith('.log')) - .map((file) => join('./', file)) + .filter(file => file.endsWith('.log')) + .map(file => join('./', file)) const diagnosticsArchive = `${chargingStation.stationInfo?.chargingStationId}_logs.tar.gz` create({ gzip: true }, logFiles).pipe(createWriteStream(diagnosticsArchive)) ftpClient = new Client() @@ -1303,7 +1303,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { }) let uploadResponse: FTPResponse | undefined if (accessResponse.code === 220) { - ftpClient.trackProgress((info) => { + ftpClient.trackProgress(info => { logger.info( `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: ${ info.bytes / 1024 @@ -1316,7 +1316,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { >(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, { status: OCPP16DiagnosticsStatus.Uploading }) - .catch((error) => { + .catch(error => { logger.error( `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Error while sending '${ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION @@ -1418,7 +1418,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { chargingStation.bootNotificationRequest, { skipBufferingOnError: true, triggerMessage: true } ) - .then((response) => { + .then(response => { chargingStation.bootNotificationResponse = response }) .catch(Constants.EMPTY_FUNCTION) diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 570708b7..1f119a2e 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -293,7 +293,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ), chargingSchedulePeriod: [ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map((schedulePeriod) => { + ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(schedulePeriod => { return { ...schedulePeriod, startPeriod: higherFirst @@ -306,7 +306,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { } }), // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - ...compositeChargingScheduleLower!.chargingSchedulePeriod.map((schedulePeriod) => { + ...compositeChargingScheduleLower!.chargingSchedulePeriod.map(schedulePeriod => { return { ...schedulePeriod, startPeriod: higherFirst @@ -339,7 +339,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ), chargingSchedulePeriod: [ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map((schedulePeriod) => { + ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(schedulePeriod => { return { ...schedulePeriod, startPeriod: higherFirst @@ -544,7 +544,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { compositeInterval.end as Date, chargingScheduleInterval.start ), - chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter((schedulePeriod) => + chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(schedulePeriod => isWithinInterval( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!, diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 8c4c9479..6a2e28ac 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -142,7 +142,7 @@ const isIdTagLocalAuthorized = (chargingStation: ChargingStation, idTag: string) chargingStation.idTagsCache // eslint-disable-next-line @typescript-eslint/no-non-null-assertion .getIdTags(getIdTagsFile(chargingStation.stationInfo!)!) - ?.find((tag) => tag === idTag) + ?.find(tag => tag === idTag) ) ) } @@ -206,11 +206,11 @@ const checkConnectorStatusTransition = ( if ( (connectorId === 0 && OCPP16Constants.ChargePointStatusChargingStationTransitions.findIndex( - (transition) => transition.from === fromStatus && transition.to === status + transition => transition.from === fromStatus && transition.to === status ) !== -1) || (connectorId > 0 && OCPP16Constants.ChargePointStatusConnectorTransitions.findIndex( - (transition) => transition.from === fromStatus && transition.to === status + transition => transition.from === fromStatus && transition.to === status ) !== -1) ) { transitionAllowed = true @@ -221,11 +221,11 @@ const checkConnectorStatusTransition = ( if ( (connectorId === 0 && OCPP20Constants.ChargingStationStatusTransitions.findIndex( - (transition) => transition.from === fromStatus && transition.to === status + transition => transition.from === fromStatus && transition.to === status ) !== -1) || (connectorId > 0 && OCPP20Constants.ConnectorStatusTransitions.findIndex( - (transition) => transition.from === fromStatus && transition.to === status + transition => transition.from === fromStatus && transition.to === status ) !== -1) ) { transitionAllowed = true diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index eac654ee..eb355083 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -80,7 +80,7 @@ export class UIHttpServer extends AbstractUIServer { } private requestListener (req: IncomingMessage, res: ServerResponse): void { - this.authenticate(req, (err) => { + this.authenticate(req, err => { if (err != null) { res .writeHead(StatusCodes.UNAUTHORIZED, { @@ -106,7 +106,7 @@ export class UIHttpServer extends AbstractUIServer { throw new BaseError(`Unsupported UI protocol version: '${fullProtocol}'`) } this.registerProtocolVersionUIService(version) - req.on('error', (error) => { + req.on('error', error => { logger.error( `${this.logPrefix(moduleName, 'requestListener.req.onerror')} Error on HTTP request:`, error diff --git a/src/charging-station/ui-server/UIWebSocketServer.ts b/src/charging-station/ui-server/UIWebSocketServer.ts index c135cb13..42162d16 100644 --- a/src/charging-station/ui-server/UIWebSocketServer.ts +++ b/src/charging-station/ui-server/UIWebSocketServer.ts @@ -47,7 +47,7 @@ export class UIWebSocketServer extends AbstractUIServer { } const [, version] = UIServerUtils.getProtocolAndVersion(ws.protocol) this.registerProtocolVersionUIService(version) - ws.on('message', (rawData) => { + ws.on('message', rawData => { const request = this.validateRawDataRequest(rawData) if (request === false) { ws.close(WebSocketCloseEventStatusCode.CLOSE_INVALID_PAYLOAD) @@ -65,7 +65,7 @@ export class UIWebSocketServer extends AbstractUIServer { }) .catch(Constants.EMPTY_FUNCTION) }) - ws.on('error', (error) => { + ws.on('error', error => { logger.error(`${this.logPrefix(moduleName, 'start.ws.onerror')} WebSocket error:`, error) }) ws.on('close', (code, reason) => { @@ -86,7 +86,7 @@ export class UIWebSocketServer extends AbstractUIServer { } }) this.httpServer.on('upgrade', (req: IncomingMessage, socket: Duplex, head: Buffer): void => { - this.authenticate(req, (err) => { + this.authenticate(req, err => { if (err != null) { socket.write(`HTTP/1.1 ${StatusCodes.UNAUTHORIZED} Unauthorized\r\n\r\n`) socket.destroy() diff --git a/src/charging-station/ui-server/ui-services/AbstractUIService.ts b/src/charging-station/ui-server/ui-services/AbstractUIService.ts index 799a6651..c0a7c799 100644 --- a/src/charging-station/ui-server/ui-services/AbstractUIService.ts +++ b/src/charging-station/ui-server/ui-services/AbstractUIService.ts @@ -163,7 +163,7 @@ export abstract class AbstractUIService { ): void { if (isNotEmptyArray(payload.hashIds)) { payload.hashIds = payload.hashIds - ?.map((hashId) => { + ?.map(hashId => { if (this.uiServer.chargingStations.has(hashId)) { return hashId } @@ -175,7 +175,7 @@ export abstract class AbstractUIService { ) return undefined }) - .filter((hashId) => hashId != null) as string[] + .filter(hashId => hashId != null) as string[] } else { delete payload.hashIds } diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index 2f109606..e8740d29 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -190,7 +190,7 @@ export class PerformanceStatistics { } private initializePerformanceObserver (): void { - this.performanceObserver = new PerformanceObserver((performanceObserverList) => { + this.performanceObserver = new PerformanceObserver(performanceObserverList => { const lastPerformanceEntry = performanceObserverList.getEntries()[0] // logger.debug( // `${this.logPrefix()} '${lastPerformanceEntry.name}' performance entry: %j`, diff --git a/src/performance/storage/JsonFileStorage.ts b/src/performance/storage/JsonFileStorage.ts index f44d9f2b..f4a88814 100644 --- a/src/performance/storage/JsonFileStorage.ts +++ b/src/performance/storage/JsonFileStorage.ts @@ -34,7 +34,7 @@ export class JsonFileStorage extends Storage { 0, 'utf8' ) - }).catch((error) => { + }).catch(error => { handleFileException( this.dbName, FileType.PerformanceRecords, diff --git a/src/utils/AsyncLock.ts b/src/utils/AsyncLock.ts index c6b35b84..099aac15 100644 --- a/src/utils/AsyncLock.ts +++ b/src/utils/AsyncLock.ts @@ -35,7 +35,7 @@ export class AsyncLock { asyncLock.acquired = true return } - await new Promise((resolve) => { + await new Promise(resolve => { asyncLock.resolveQueue.enqueue(resolve) }) } @@ -48,7 +48,7 @@ export class AsyncLock { } // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const queuedResolve = asyncLock.resolveQueue.dequeue()! - await new Promise((resolve) => { + await new Promise(resolve => { queuedResolve() resolve() }) diff --git a/src/utils/ChargingStationConfigurationUtils.ts b/src/utils/ChargingStationConfigurationUtils.ts index fc8fc901..0e32c7e6 100644 --- a/src/utils/ChargingStationConfigurationUtils.ts +++ b/src/utils/ChargingStationConfigurationUtils.ts @@ -35,7 +35,7 @@ export const buildEvsesStatus = ( outputFormat: OutputFormat = OutputFormat.configuration ): Array => { // eslint-disable-next-line array-callback-return - return [...chargingStation.evses.values()].map((evseStatus) => { + return [...chargingStation.evses.values()].map(evseStatus => { const connectorsStatus = [...evseStatus.connectors.values()].map( ({ transactionSetInterval, ...connectorStatusRest }) => connectorStatusRest ) diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 596b685c..dc3ca595 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -559,7 +559,7 @@ export class Configuration { Configuration.configurationSectionCache.clear() if (Configuration.configurationChangeCallback !== undefined) { Configuration.configurationChangeCallback() - .catch((error) => { + .catch(error => { throw typeof error === 'string' ? new Error(error) : error }) .finally(() => { diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index b8083596..df802f3e 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -29,7 +29,7 @@ export const validateUUID = (uuid: string): boolean => { } export const sleep = async (milliSeconds: number): Promise => { - return await new Promise((resolve) => + return await new Promise(resolve => setTimeout(resolve as () => void, milliSeconds) ) } @@ -203,7 +203,7 @@ export const getRandomFloatFluctuatedRounded = ( } export const extractTimeSeriesValues = (timeSeries: TimestampedData[]): number[] => { - return timeSeries.map((timeSeriesItem) => timeSeriesItem.value) + return timeSeries.map(timeSeriesItem => timeSeriesItem.value) } export const isObject = (item: unknown): boolean => { diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index ea5d654c..ea1ed241 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -86,7 +86,7 @@ export class WorkerSet extends WorkerAbstract { public async stop (): Promise { for (const workerSetElement of this.workerSet) { const worker = workerSetElement.worker - const waitWorkerExit = new Promise((resolve) => { + const waitWorkerExit = new Promise(resolve => { worker.once('exit', () => { resolve() }) @@ -137,7 +137,7 @@ export class WorkerSet extends WorkerAbstract { } }) worker.on('error', this.workerOptions.poolOptions?.errorHandler ?? EMPTY_FUNCTION) - worker.on('error', (error) => { + worker.on('error', error => { this.emitter?.emit(WorkerSetEvents.error, error) if ( this.workerOptions.poolOptions?.restartWorkerOnError === true && diff --git a/src/worker/WorkerUtils.ts b/src/worker/WorkerUtils.ts index 5cd19f12..f36c6046 100644 --- a/src/worker/WorkerUtils.ts +++ b/src/worker/WorkerUtils.ts @@ -3,7 +3,7 @@ import { getRandomValues } from 'node:crypto' import chalk from 'chalk' export const sleep = async (milliSeconds: number): Promise => { - return await new Promise((resolve) => + return await new Promise(resolve => setTimeout(resolve as () => void, milliSeconds) ) } diff --git a/ui/web/.eslintrc.cjs b/ui/web/.eslintrc.cjs index 75c92c6a..128bff5f 100644 --- a/ui/web/.eslintrc.cjs +++ b/ui/web/.eslintrc.cjs @@ -6,7 +6,7 @@ module.exports = defineConfig({ root: true, env: { - node: true, + node: true }, plugins: ['import'], @@ -16,19 +16,19 @@ module.exports = defineConfig({ 'plugin:import/recommended', 'plugin:vue/vue3-recommended', '@vue/eslint-config-typescript/recommended', - '@vue/eslint-config-prettier', + '@vue/eslint-config-prettier' ], settings: { 'import/resolver': { typescript: { - project: './tsconfig.json', - }, - }, + project: './tsconfig.json' + } + } }, parserOptions: { - ecmaVersion: 'latest', + ecmaVersion: 'latest' }, rules: { @@ -39,9 +39,9 @@ module.exports = defineConfig({ 'sort-imports': [ 'error', { - ignoreDeclarationSort: true, - }, + ignoreDeclarationSort: true + } ], - 'import/order': 'error', - }, + 'import/order': 'error' + } }) diff --git a/ui/web/.lintstagedrc.js b/ui/web/.lintstagedrc.js index 59a73cec..a8ba217a 100644 --- a/ui/web/.lintstagedrc.js +++ b/ui/web/.lintstagedrc.js @@ -1,5 +1,5 @@ export default { '*.{.css,json,md,yml,yaml,html,js,jsx,cjs,mjs,ts,tsx,cts,mts}': 'prettier --cache --write', '*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}': - 'eslint . --cache --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore', + 'eslint . --cache --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore' } diff --git a/ui/web/.prettierrc.json b/ui/web/.prettierrc.json index 6632aaeb..066e89fc 100644 --- a/ui/web/.prettierrc.json +++ b/ui/web/.prettierrc.json @@ -1,7 +1,8 @@ { "$schema": "https://json.schemastore.org/prettierrc", "printWidth": 100, - "semi": false, + "arrowParens": "avoid", "singleQuote": true, + "semi": false, "trailingComma": "none" } diff --git a/ui/web/src/assets/config.ts b/ui/web/src/assets/config.ts index c9068f9b..cf6f3eb2 100644 --- a/ui/web/src/assets/config.ts +++ b/ui/web/src/assets/config.ts @@ -4,8 +4,8 @@ const config: BaseConfig = { uiServer: { host: 'localhost', port: 8080, - protocol: 'ui0.0.1', - }, + protocol: 'ui0.0.1' + } } export default config diff --git a/ui/web/src/composables/UIClient.ts b/ui/web/src/composables/UIClient.ts index 10f2d3de..49ca3018 100644 --- a/ui/web/src/composables/UIClient.ts +++ b/ui/web/src/composables/UIClient.ts @@ -3,7 +3,7 @@ import { type ProtocolResponse, type RequestPayload, type ResponsePayload, - ResponseStatus, + ResponseStatus } from '@/types' import config from '@/assets/config' @@ -57,13 +57,13 @@ export class UIClient { public async openConnection(hashId: string): Promise { return this.sendRequest(ProcedureName.OPEN_CONNECTION, { - hashIds: [hashId], + hashIds: [hashId] }) } public async closeConnection(hashId: string): Promise { return this.sendRequest(ProcedureName.CLOSE_CONNECTION, { - hashIds: [hashId], + hashIds: [hashId] }) } @@ -75,7 +75,7 @@ export class UIClient { return this.sendRequest(ProcedureName.START_TRANSACTION, { hashIds: [hashId], connectorId, - idTag, + idTag }) } @@ -85,7 +85,7 @@ export class UIClient { ): Promise { return this.sendRequest(ProcedureName.STOP_TRANSACTION, { hashIds: [hashId], - transactionId, + transactionId }) } @@ -95,7 +95,7 @@ export class UIClient { ): Promise { return this.sendRequest(ProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, { hashIds: [hashId], - connectorIds: [connectorId], + connectorIds: [connectorId] }) } @@ -105,7 +105,7 @@ export class UIClient { ): Promise { return this.sendRequest(ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, { hashIds: [hashId], - connectorIds: [connectorId], + connectorIds: [connectorId] }) } @@ -115,10 +115,10 @@ export class UIClient { config.uiServer.protocol ) this.ws.onmessage = this.responseHandler.bind(this) - this.ws.onerror = (errorEvent) => { + this.ws.onerror = errorEvent => { console.error('WebSocket error: ', errorEvent) } - this.ws.onclose = (closeEvent) => { + this.ws.onclose = closeEvent => { console.info('WebSocket closed: ', closeEvent) } } diff --git a/ui/web/src/router/index.ts b/ui/web/src/router/index.ts index b58a4d2a..1015d923 100644 --- a/ui/web/src/router/index.ts +++ b/ui/web/src/router/index.ts @@ -5,13 +5,13 @@ const routes: RouteRecordRaw[] = [ { path: '/', name: 'charging-stations', - component: ChargingStationsView, - }, + component: ChargingStationsView + } ] const router = createRouter({ history: createWebHistory(), - routes, + routes }) export default router diff --git a/ui/web/src/types/ChargingStationType.ts b/ui/web/src/types/ChargingStationType.ts index 1479e1d7..2e79fbc8 100644 --- a/ui/web/src/types/ChargingStationType.ts +++ b/ui/web/src/types/ChargingStationType.ts @@ -21,11 +21,11 @@ export enum OCPP16FirmwareStatus { Idle = 'Idle', InstallationFailed = 'InstallationFailed', Installing = 'Installing', - Installed = 'Installed', + Installed = 'Installed' } export const FirmwareStatus = { - ...OCPP16FirmwareStatus, + ...OCPP16FirmwareStatus } as const export type FirmwareStatus = OCPP16FirmwareStatus @@ -99,11 +99,11 @@ export enum OCPP16IncomingRequestCommand { REMOTE_START_TRANSACTION = 'RemoteStartTransaction', REMOTE_STOP_TRANSACTION = 'RemoteStopTransaction', GET_DIAGNOSTICS = 'GetDiagnostics', - TRIGGER_MESSAGE = 'TriggerMessage', + TRIGGER_MESSAGE = 'TriggerMessage' } export const IncomingRequestCommand = { - ...OCPP16IncomingRequestCommand, + ...OCPP16IncomingRequestCommand } as const export type IncomingRequestCommand = OCPP16IncomingRequestCommand @@ -115,11 +115,11 @@ export enum OCPP16RequestCommand { START_TRANSACTION = 'StartTransaction', STOP_TRANSACTION = 'StopTransaction', METER_VALUES = 'MeterValues', - DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification', + DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification' } export const RequestCommand = { - ...OCPP16RequestCommand, + ...OCPP16RequestCommand } as const export type RequestCommand = OCPP16RequestCommand @@ -128,7 +128,7 @@ export type BootNotificationResponse = OCPP16BootNotificationResponse export enum OCPP16RegistrationStatus { ACCEPTED = 'Accepted', PENDING = 'Pending', - REJECTED = 'Rejected', + REJECTED = 'Rejected' } export interface OCPP16BootNotificationResponse extends JsonObject { @@ -143,11 +143,11 @@ export enum OCPP16MessageTrigger { FirmwareStatusNotification = 'FirmwareStatusNotification', Heartbeat = 'Heartbeat', MeterValues = 'MeterValues', - StatusNotification = 'StatusNotification', + StatusNotification = 'StatusNotification' } export const MessageTrigger = { - ...OCPP16MessageTrigger, + ...OCPP16MessageTrigger } as const export type MessageTrigger = OCPP16MessageTrigger @@ -158,30 +158,30 @@ type CommandsSupport = { export enum OCPPVersion { VERSION_16 = '1.6', - VERSION_20 = '2.0', + VERSION_20 = '2.0' } export enum OCPPProtocol { - JSON = 'json', + JSON = 'json' } export enum CurrentType { AC = 'AC', - DC = 'DC', + DC = 'DC' } export enum Voltage { VOLTAGE_110 = 110, VOLTAGE_230 = 230, VOLTAGE_400 = 400, - VOLTAGE_800 = 800, + VOLTAGE_800 = 800 } export enum AmpereUnits { MILLI_AMPERE = 'mA', CENTI_AMPERE = 'cA', DECI_AMPERE = 'dA', - AMPERE = 'A', + AMPERE = 'A' } export type ConnectorStatus = { @@ -207,7 +207,7 @@ export type EvseStatus = { export enum OCPP16AvailabilityType { INOPERATIVE = 'Inoperative', - OPERATIVE = 'Operative', + OPERATIVE = 'Operative' } export type AvailabilityType = OCPP16AvailabilityType @@ -221,7 +221,7 @@ export enum OCPP16ChargePointStatus { FINISHING = 'Finishing', RESERVED = 'Reserved', UNAVAILABLE = 'Unavailable', - FAULTED = 'Faulted', + FAULTED = 'Faulted' } export type ChargePointStatus = OCPP16ChargePointStatus diff --git a/ui/web/src/types/UIProtocol.ts b/ui/web/src/types/UIProtocol.ts index 48b0f1a8..07eb5212 100644 --- a/ui/web/src/types/UIProtocol.ts +++ b/ui/web/src/types/UIProtocol.ts @@ -1,16 +1,16 @@ import type { JsonObject } from './JsonType' export enum Protocol { - UI = 'ui', + UI = 'ui' } export enum ApplicationProtocol { HTTP = 'http', - WS = 'ws', + WS = 'ws' } export enum ProtocolVersion { - '0.0.1' = '0.0.1', + '0.0.1' = '0.0.1' } export type ProtocolRequest = [string, ProcedureName, RequestPayload] @@ -31,7 +31,7 @@ export enum ProcedureName { START_AUTOMATIC_TRANSACTION_GENERATOR = 'startAutomaticTransactionGenerator', STOP_AUTOMATIC_TRANSACTION_GENERATOR = 'stopAutomaticTransactionGenerator', START_TRANSACTION = 'startTransaction', - STOP_TRANSACTION = 'stopTransaction', + STOP_TRANSACTION = 'stopTransaction' } export interface RequestPayload extends JsonObject { @@ -41,7 +41,7 @@ export interface RequestPayload extends JsonObject { export enum ResponseStatus { SUCCESS = 'success', - FAILURE = 'failure', + FAILURE = 'failure' } export interface ResponsePayload extends JsonObject { diff --git a/ui/web/src/types/index.ts b/ui/web/src/types/index.ts index d866d361..ec7821f3 100644 --- a/ui/web/src/types/index.ts +++ b/ui/web/src/types/index.ts @@ -1,7 +1,7 @@ export type { ChargingStationData, ChargingStationInfo, - ConnectorStatus, + ConnectorStatus } from './ChargingStationType' export type { BaseConfig } from './ConfigurationType' export { @@ -9,5 +9,5 @@ export { type ProtocolResponse, type RequestPayload, type ResponsePayload, - ResponseStatus, + ResponseStatus } from './UIProtocol' diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index 707cce54..5e385955 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -39,7 +39,7 @@ type State = { const state: State = reactive({ isLoading: false, chargingStations: [], - idTag: '', + idTag: '' }) async function load(): Promise { diff --git a/ui/web/tests/unit/CSTable.spec.ts b/ui/web/tests/unit/CSTable.spec.ts index a725df55..39c980c5 100644 --- a/ui/web/tests/unit/CSTable.spec.ts +++ b/ui/web/tests/unit/CSTable.spec.ts @@ -6,7 +6,7 @@ import type { ChargingStationData } from '@/types' test('renders CS table columns name', () => { const chargingStations: ChargingStationData[] = [] const wrapper = shallowMount(CSTable, { - props: { chargingStations, idTag: '0' }, + props: { chargingStations, idTag: '0' } }) expect(wrapper.text()).to.include('Action') expect(wrapper.text()).to.include('Connector') diff --git a/ui/web/vite.config.ts b/ui/web/vite.config.ts index c258c4b1..a5a1d533 100644 --- a/ui/web/vite.config.ts +++ b/ui/web/vite.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ plugins: [vue(), vueJsx()], resolve: { alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)), - }, - }, + '@': fileURLToPath(new URL('./src', import.meta.url)) + } + } }) diff --git a/ui/web/vitest.config.ts b/ui/web/vitest.config.ts index b772de17..39905b29 100644 --- a/ui/web/vitest.config.ts +++ b/ui/web/vitest.config.ts @@ -12,8 +12,8 @@ export default mergeConfig( root: fileURLToPath(new URL('./', import.meta.url)), coverage: { provider: 'v8', - reporter: ['text', 'lcov'], - }, - }, + reporter: ['text', 'lcov'] + } + } }) )