From: Jérôme Benoit Date: Fri, 19 Jul 2024 13:10:04 +0000 (+0200) Subject: chore: align code formatting configuration X-Git-Tag: ocpp-server@v1.5.0~15 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b015f7768af5a9b67a4c615c660551faa29c35c2;p=e-mobility-charging-stations-simulator.git chore: align code formatting configuration Signed-off-by: Jérôme Benoit --- diff --git a/ui/web/.eslintrc.cjs b/ui/web/.eslintrc.cjs index b6252bbc..fa60a70a 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: ['simple-import-sort'], @@ -17,20 +17,20 @@ module.exports = defineConfig({ 'plugin:import/typescript', '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: { sourceType: 'module', - ecmaVersion: 'latest' + ecmaVersion: 'latest', }, rules: { @@ -38,6 +38,6 @@ module.exports = defineConfig({ 'no-debugger': env.NODE_ENV === 'production' ? 'warn' : 'off', 'simple-import-sort/imports': 'error', 'simple-import-sort/exports': 'error', - 'vue/multi-word-component-names': 'off' - } + 'vue/multi-word-component-names': 'off', + }, }) diff --git a/ui/web/.lintstagedrc.js b/ui/web/.lintstagedrc.js index a8ba217a..96426a9f 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' + // '*.{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', } diff --git a/ui/web/.prettierrc.json b/ui/web/.prettierrc.json index 066e89fc..b962a2dd 100644 --- a/ui/web/.prettierrc.json +++ b/ui/web/.prettierrc.json @@ -4,5 +4,5 @@ "arrowParens": "avoid", "singleQuote": true, "semi": false, - "trailingComma": "none" + "trailingComma": "es5" } diff --git a/ui/web/src/components/actions/AddChargingStations.vue b/ui/web/src/components/actions/AddChargingStations.vue index a95cba2b..9c87a489 100644 --- a/ui/web/src/components/actions/AddChargingStations.vue +++ b/ui/web/src/components/actions/AddChargingStations.vue @@ -75,7 +75,7 @@ autoStart: convertToBoolean(state.autoStart), persistentConfiguration: convertToBoolean(state.persistentConfiguration), ocppStrictCompliance: convertToBoolean(state.ocppStrictCompliance), - enableStatistics: convertToBoolean(state.enableStatistics) + enableStatistics: convertToBoolean(state.enableStatistics), }) .then(() => { $toast.success('Charging stations successfully added') @@ -117,7 +117,7 @@ const state = ref<{ autoStart: false, persistentConfiguration: true, ocppStrictCompliance: true, - enableStatistics: false + enableStatistics: false, }) watch(getCurrentInstance()!.appContext.config.globalProperties.$templates, () => { diff --git a/ui/web/src/components/actions/SetSupervisionUrl.vue b/ui/web/src/components/actions/SetSupervisionUrl.vue index edefc8a5..7c43f2c5 100644 --- a/ui/web/src/components/actions/SetSupervisionUrl.vue +++ b/ui/web/src/components/actions/SetSupervisionUrl.vue @@ -44,7 +44,7 @@ defineProps<{ }>() const state = ref<{ supervisionUrl: string }>({ - supervisionUrl: '' + supervisionUrl: '', }) diff --git a/ui/web/src/components/actions/StartTransaction.vue b/ui/web/src/components/actions/StartTransaction.vue index a0ab5cec..b47f7118 100644 --- a/ui/web/src/components/actions/StartTransaction.vue +++ b/ui/web/src/components/actions/StartTransaction.vue @@ -41,7 +41,7 @@ defineProps<{ }>() const state = ref<{ idTag: string }>({ - idTag: '' + idTag: '', }) diff --git a/ui/web/src/components/buttons/ToggleButton.vue b/ui/web/src/components/buttons/ToggleButton.vue index 537a198b..5f444745 100644 --- a/ui/web/src/components/buttons/ToggleButton.vue +++ b/ui/web/src/components/buttons/ToggleButton.vue @@ -23,7 +23,7 @@ const $emit = defineEmits(['clicked']) const id = props.shared === true ? `shared-toggle-button-${props.id}` : `toggle-button-${props.id}` const state = ref<{ status: boolean }>({ - status: getFromLocalStorage(id, props.status ?? false) + status: getFromLocalStorage(id, props.status ?? false), }) const click = (): void => { diff --git a/ui/web/src/components/charging-stations/CSConnector.vue b/ui/web/src/components/charging-stations/CSConnector.vue index 9bfeae6d..7619d43f 100644 --- a/ui/web/src/components/charging-stations/CSConnector.vue +++ b/ui/web/src/components/charging-stations/CSConnector.vue @@ -16,7 +16,7 @@ () => { $router.push({ name: 'start-transaction', - params: { hashId, chargingStationId, connectorId } + params: { hashId, chargingStationId, connectorId }, }) } " diff --git a/ui/web/src/components/charging-stations/CSData.vue b/ui/web/src/components/charging-stations/CSData.vue index 48edd609..32d4490f 100644 --- a/ui/web/src/components/charging-stations/CSData.vue +++ b/ui/web/src/components/charging-stations/CSData.vue @@ -31,8 +31,8 @@ name: 'set-supervision-url', params: { hashId: chargingStation.stationInfo.hashId, - chargingStationId: chargingStation.stationInfo.chargingStationId - } + chargingStationId: chargingStation.stationInfo.chargingStationId, + }, }) } " diff --git a/ui/web/src/composables/UIClient.ts b/ui/web/src/composables/UIClient.ts index 04587e2d..dd7bfb40 100644 --- a/ui/web/src/composables/UIClient.ts +++ b/ui/web/src/composables/UIClient.ts @@ -9,7 +9,7 @@ import { type RequestPayload, type ResponsePayload, ResponseStatus, - type UIServerConfigurationSection + type UIServerConfigurationSection, } from '@/types' import { randomUUID, validateUUID } from './Utils' @@ -100,44 +100,44 @@ export class UIClient { return this.sendRequest(ProcedureName.ADD_CHARGING_STATIONS, { template, numberOfStations, - options + options, }) } public async deleteChargingStation(hashId: string): Promise { return this.sendRequest(ProcedureName.DELETE_CHARGING_STATIONS, { - hashIds: [hashId] + hashIds: [hashId], }) } public async setSupervisionUrl(hashId: string, supervisionUrl: string): Promise { return this.sendRequest(ProcedureName.SET_SUPERVISION_URL, { hashIds: [hashId], - url: supervisionUrl + url: supervisionUrl, }) } public async startChargingStation(hashId: string): Promise { return this.sendRequest(ProcedureName.START_CHARGING_STATION, { - hashIds: [hashId] + hashIds: [hashId], }) } public async stopChargingStation(hashId: string): Promise { return this.sendRequest(ProcedureName.STOP_CHARGING_STATION, { - hashIds: [hashId] + hashIds: [hashId], }) } 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], }) } @@ -149,7 +149,7 @@ export class UIClient { return this.sendRequest(ProcedureName.START_TRANSACTION, { hashIds: [hashId], connectorId, - idTag + idTag, }) } @@ -159,7 +159,7 @@ export class UIClient { ): Promise { return this.sendRequest(ProcedureName.STOP_TRANSACTION, { hashIds: [hashId], - transactionId + transactionId, }) } @@ -169,7 +169,7 @@ export class UIClient { ): Promise { return this.sendRequest(ProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR, { hashIds: [hashId], - connectorIds: [connectorId] + connectorIds: [connectorId], }) } @@ -179,7 +179,7 @@ export class UIClient { ): Promise { return this.sendRequest(ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR, { hashIds: [hashId], - connectorIds: [connectorId] + connectorIds: [connectorId], }) } @@ -191,7 +191,7 @@ export class UIClient { `${this.uiServerConfiguration.protocol}${this.uiServerConfiguration.version}`, `authorization.basic.${btoa( `${this.uiServerConfiguration.authentication.username}:${this.uiServerConfiguration.authentication.password}` - ).replace(/={1,2}$/, '')}` + ).replace(/={1,2}$/, '')}`, ] : `${this.uiServerConfiguration.protocol}${this.uiServerConfiguration.version}` this.ws = new WebSocket( diff --git a/ui/web/src/composables/index.ts b/ui/web/src/composables/index.ts index 6810a971..f4a165a8 100644 --- a/ui/web/src/composables/index.ts +++ b/ui/web/src/composables/index.ts @@ -7,5 +7,5 @@ export { getLocalStorage, randomUUID, setToLocalStorage, - useUIClient + useUIClient, } from './Utils' diff --git a/ui/web/src/router/index.ts b/ui/web/src/router/index.ts index cee4f416..bbd61cbd 100644 --- a/ui/web/src/router/index.ts +++ b/ui/web/src/router/index.ts @@ -13,41 +13,41 @@ export const router = createRouter({ path: '/', name: 'charging-stations', components: { - default: ChargingStationsView - } + default: ChargingStationsView, + }, }, { path: '/add-charging-stations', name: 'add-charging-stations', components: { default: ChargingStationsView, - action: AddChargingStations - } + action: AddChargingStations, + }, }, { path: '/set-supervision-url/:hashId/:chargingStationId', name: 'set-supervision-url', components: { default: ChargingStationsView, - action: SetSupervisionUrl + action: SetSupervisionUrl, }, - props: { default: false, action: true } + props: { default: false, action: true }, }, { path: '/start-transaction/:hashId/:chargingStationId/:connectorId', name: 'start-transaction', components: { default: ChargingStationsView, - action: StartTransaction + action: StartTransaction, }, - props: { default: false, action: true } + props: { default: false, action: true }, }, { name: 'not-found', path: '/:pathMatch(.*)*', components: { - default: NotFoundView - } - } - ] + default: NotFoundView, + }, + }, + ], }) diff --git a/ui/web/src/types/ChargingStationType.ts b/ui/web/src/types/ChargingStationType.ts index 167e3a1a..3d9edcdc 100644 --- a/ui/web/src/types/ChargingStationType.ts +++ b/ui/web/src/types/ChargingStationType.ts @@ -3,7 +3,7 @@ import type { JsonObject } from './JsonType' export enum IdTagDistribution { RANDOM = 'random', ROUND_ROBIN = 'round-robin', - CONNECTOR_AFFINITY = 'connector-affinity' + CONNECTOR_AFFINITY = 'connector-affinity', } export interface AutomaticTransactionGeneratorConfiguration extends JsonObject { @@ -47,7 +47,7 @@ export enum OCPP16FirmwareStatus { Idle = 'Idle', InstallationFailed = 'InstallationFailed', Installing = 'Installing', - Installed = 'Installed' + Installed = 'Installed', } export interface FirmwareUpgrade extends JsonObject { @@ -60,7 +60,7 @@ export interface FirmwareUpgrade extends JsonObject { } export const FirmwareStatus = { - ...OCPP16FirmwareStatus + ...OCPP16FirmwareStatus, } as const export type FirmwareStatus = OCPP16FirmwareStatus @@ -164,11 +164,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 @@ -180,11 +180,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 @@ -193,7 +193,7 @@ export type BootNotificationResponse = OCPP16BootNotificationResponse export enum OCPP16RegistrationStatus { ACCEPTED = 'Accepted', PENDING = 'Pending', - REJECTED = 'Rejected' + REJECTED = 'Rejected', } export interface OCPP16BootNotificationResponse extends JsonObject { @@ -208,11 +208,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 @@ -224,30 +224,30 @@ interface CommandsSupport extends JsonObject { export enum OCPPVersion { VERSION_16 = '1.6', VERSION_20 = '2.0', - VERSION_201 = '2.0.1' + VERSION_201 = '2.0.1', } 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 interface ConnectorStatus extends JsonObject { @@ -273,7 +273,7 @@ export interface EvseStatus extends JsonObject { export enum OCPP16AvailabilityType { INOPERATIVE = 'Inoperative', - OPERATIVE = 'Operative' + OPERATIVE = 'Operative', } export type AvailabilityType = OCPP16AvailabilityType @@ -287,7 +287,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 8522aa11..5dbbed6c 100644 --- a/ui/web/src/types/UIProtocol.ts +++ b/ui/web/src/types/UIProtocol.ts @@ -1,30 +1,30 @@ import type { JsonObject } from './JsonType' export enum Protocol { - UI = 'ui' + UI = 'ui', } export enum ApplicationProtocol { WS = 'ws', - WSS = 'wss' + WSS = 'wss', } export enum ProtocolVersion { - '0.0.1' = '0.0.1' + '0.0.1' = '0.0.1', } export enum AuthenticationType { - PROTOCOL_BASIC_AUTH = 'protocol-basic-auth' + PROTOCOL_BASIC_AUTH = 'protocol-basic-auth', } export type ProtocolRequest = [ `${string}-${string}-${string}-${string}-${string}`, ProcedureName, - RequestPayload + RequestPayload, ] export type ProtocolResponse = [ `${string}-${string}-${string}-${string}-${string}`, - ResponsePayload + ResponsePayload, ] export type ProtocolRequestHandler = ( @@ -47,7 +47,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 { @@ -57,7 +57,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 d730f0d6..b9159b18 100644 --- a/ui/web/src/types/index.ts +++ b/ui/web/src/types/index.ts @@ -3,7 +3,7 @@ export type { ChargingStationInfo, ChargingStationOptions, ConnectorStatus, - Status + Status, } from './ChargingStationType' export type { ConfigurationData, UIServerConfigurationSection } from './ConfigurationType' export { @@ -16,5 +16,5 @@ export { type RequestPayload, type ResponsePayload, ResponseStatus, - type SimulatorState + type SimulatorState, } from './UIProtocol' diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index af6fbe99..dba6d246 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -126,13 +126,13 @@ import { getLocalStorage, randomUUID, setToLocalStorage, - useUIClient + useUIClient, } from '@/composables' import type { ChargingStationData, ResponsePayload, SimulatorState, - UIServerConfigurationSection + UIServerConfigurationSection, } from '@/types' const simulatorState = ref(undefined) @@ -162,7 +162,7 @@ const state = ref<{ gettingSimulatorState: false, gettingTemplates: false, gettingChargingStations: false, - uiServerIndex: getFromLocalStorage('uiServerConfigurationIndex', 0) + uiServerIndex: getFromLocalStorage('uiServerConfigurationIndex', 0), }) const clearToggleButtons = (): void => { @@ -296,7 +296,7 @@ const uiServerConfigurations: { .uiServer as UIServerConfigurationSection[] ).map((configuration: UIServerConfigurationSection, index: number) => ({ index, - configuration + configuration, })) const startSimulator = (): void => { diff --git a/ui/web/tests/unit/CSTable.spec.ts b/ui/web/tests/unit/CSTable.spec.ts index 8a417af8..34ceaa4c 100644 --- a/ui/web/tests/unit/CSTable.spec.ts +++ b/ui/web/tests/unit/CSTable.spec.ts @@ -7,7 +7,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('Name') expect(wrapper.text()).to.include('Started') diff --git a/ui/web/vite.config.ts b/ui/web/vite.config.ts index 6d5f08a3..f4004a8f 100644 --- a/ui/web/vite.config.ts +++ b/ui/web/vite.config.ts @@ -8,7 +8,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 c5276e5c..f0a2b12c 100644 --- a/ui/web/vitest.config.ts +++ b/ui/web/vitest.config.ts @@ -14,8 +14,8 @@ export default mergeConfig( root: fileURLToPath(new URL('./', import.meta.url)), coverage: { provider: 'v8', - reporter: ['text', 'lcov'] - } - } + reporter: ['text', 'lcov'], + }, + }, }) )