From 100680888f3b49453ddb4081988a480ee3030d07 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 4 Mar 2022 23:39:37 +0100 Subject: [PATCH] Fix eslint and prettier configuration MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .eslintrc | 41 ++++-------- package-lock.json | 64 +++++++++++++++++++ package.json | 1 + .../AutomaticTransactionGenerator.ts | 1 + .../ocpp/OCPPIncomingRequestService.ts | 1 + .../ocpp/OCPPRequestService.ts | 8 +++ .../ocpp/OCPPResponseService.ts | 1 + src/performance/PerformanceStatistics.ts | 1 + src/utils/Configuration.ts | 1 + src/utils/Constants.ts | 16 +++++ 10 files changed, 106 insertions(+), 29 deletions(-) diff --git a/.eslintrc b/.eslintrc index 6d8714d7..e98414f0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -12,7 +12,7 @@ "plugin:import/warnings", "plugin:import/typescript", "plugin:jsdoc/recommended", - "prettier" + "plugin:prettier/recommended" ], "plugins": ["import", "jsdoc", "@typescript-eslint"], "settings": { @@ -21,25 +21,6 @@ } }, "rules": { - "indent": "off", - "@typescript-eslint/indent": [ - "error", - 2, - { - "SwitchCase": 1, - "CallExpression": { - "arguments": 1 - }, - "FunctionDeclaration": { - "parameters": 2, - "body": 1 - }, - "FunctionExpression": { - "parameters": 2, - "body": 1 - } - } - ], "@typescript-eslint/array-type": "off", "semi": "off", "@typescript-eslint/semi": ["error", "always"], @@ -55,7 +36,7 @@ "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/promise-function-async": "error", "@typescript-eslint/no-misused-promises": "error", - "curly": "error", + "curly": ["error", "all"], "brace-style": "error", "eqeqeq": ["error", "always"], "no-else-return": "error", @@ -108,13 +89,8 @@ "max-len": [ "warn", { - "code": 180, - "ignoreComments": true, - "ignoreUrls": true, - "ignoreStrings": true, - "ignoreTemplateLiterals": true, - "ignoreRegExpLiterals": true, - "ignorePattern": "(^(import|export)|(public|private))\\s.+;" + "code": 80, + "ignoreUrls": true } ], "no-lonely-if": "error", @@ -156,7 +132,14 @@ "exceptAfterSingleLine": true } ], - "quotes": ["error", "single"] + "quotes": [ + "error", + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": false + } + ] }, "overrides": [ { diff --git a/package-lock.json b/package-lock.json index eb81da6e..172acea2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,6 +47,7 @@ "eslint-plugin-import": "^2.25.4", "eslint-plugin-jsdoc": "^37.9.6", "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^4.0.0", "expect": "^27.5.1", "mocha": "^9.2.1", "mochawesome": "^7.1.1", @@ -6111,6 +6112,27 @@ "semver": "bin/semver.js" } }, + "node_modules/eslint-plugin-prettier": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz", + "integrity": "sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==", + "dev": true, + "dependencies": { + "prettier-linter-helpers": "^1.0.0" + }, + "engines": { + "node": ">=6.0.0" + }, + "peerDependencies": { + "eslint": ">=7.28.0", + "prettier": ">=2.0.0" + }, + "peerDependenciesMeta": { + "eslint-config-prettier": { + "optional": true + } + } + }, "node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -6658,6 +6680,12 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "devOptional": true }, + "node_modules/fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, "node_modules/fast-glob": { "version": "3.2.11", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", @@ -13871,6 +13899,18 @@ "node": ">=10.13.0" } }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", @@ -23996,6 +24036,15 @@ } } }, + "eslint-plugin-prettier": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz", + "integrity": "sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -24396,6 +24445,12 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "devOptional": true }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, "fast-glob": { "version": "3.2.11", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", @@ -30075,6 +30130,15 @@ "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==", "dev": true }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", diff --git a/package.json b/package.json index d1589d37..5fd483ae 100644 --- a/package.json +++ b/package.json @@ -110,6 +110,7 @@ "eslint-plugin-import": "^2.25.4", "eslint-plugin-jsdoc": "^37.9.6", "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^4.0.0", "expect": "^27.5.1", "mocha": "^9.2.1", "mochawesome": "^7.1.1", diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index b9d3f1d0..cf2f4277 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -20,6 +20,7 @@ export default class AutomaticTransactionGenerator { string, AutomaticTransactionGenerator >(); + public started: boolean; private readonly chargingStation: ChargingStation; private readonly connectorsStatus: Map; diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index 0d56ebe8..431df9b9 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -9,6 +9,7 @@ export default abstract class OCPPIncomingRequestService { string, OCPPIncomingRequestService >(); + protected chargingStation: ChargingStation; protected constructor(chargingStation: ChargingStation) { diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 04cd508a..fc465b8c 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -34,6 +34,7 @@ export default abstract class OCPPRequestService { string, OCPPRequestService >(); + protected readonly chargingStation: ChargingStation; private readonly ocppResponseService: OCPPResponseService; @@ -338,37 +339,44 @@ export default abstract class OCPPRequestService { meterType?: string, params?: SendParams ): Promise; + public abstract sendStatusNotification( connectorId: number, status: ChargePointStatus, errorCode?: ChargePointErrorCode ): Promise; + public abstract sendAuthorize(connectorId: number, idTag?: string): Promise; public abstract sendStartTransaction( connectorId: number, idTag?: string ): Promise; + public abstract sendStopTransaction( transactionId: number, meterStop: number, idTag?: string, reason?: StopTransactionReason ): Promise; + public abstract sendMeterValues( connectorId: number, transactionId: number, interval: number ): Promise; + public abstract sendTransactionBeginMeterValues( connectorId: number, transactionId: number, beginMeterValue: MeterValue ): Promise; + public abstract sendTransactionEndMeterValues( connectorId: number, transactionId: number, endMeterValue: MeterValue ): Promise; + public abstract sendDiagnosticsStatusNotification( diagnosticsStatus: DiagnosticsStatus ): Promise; diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index 2fa0112c..311d62e3 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -7,6 +7,7 @@ export default abstract class OCPPResponseService { string, OCPPResponseService >(); + protected readonly chargingStation: ChargingStation; protected constructor(chargingStation: ChargingStation) { diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index bec0f62e..7338fa24 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -18,6 +18,7 @@ export default class PerformanceStatistics { string, PerformanceStatistics >(); + private readonly objId: string; private readonly objName: string; private performanceObserver: PerformanceObserver; diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 5770d76e..57ee31df 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -22,6 +22,7 @@ export default class Configuration { 'assets', 'config.json' ); + private static configurationFileWatcher: fs.FSWatcher; private static configuration: ConfigurationData | null = null; private static configurationChangeCallback: () => Promise; diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index 968de2d0..79e39009 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -17,52 +17,68 @@ export default class Constants { static readonly OCPP_CONFIGURATION_RESPONSE_ACCEPTED = Object.freeze({ status: ConfigurationStatus.ACCEPTED, }); + static readonly OCPP_CONFIGURATION_RESPONSE_REJECTED = Object.freeze({ status: ConfigurationStatus.REJECTED, }); + static readonly OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED = Object.freeze({ status: ConfigurationStatus.REBOOT_REQUIRED, }); + static readonly OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED = Object.freeze({ status: ConfigurationStatus.NOT_SUPPORTED, }); + static readonly OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED = Object.freeze({ status: ChargingProfileStatus.ACCEPTED, }); + static readonly OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED = Object.freeze({ status: ChargingProfileStatus.REJECTED, }); + static readonly OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED = Object.freeze({ status: ChargingProfileStatus.NOT_SUPPORTED, }); + static readonly OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED = Object.freeze({ status: ClearChargingProfileStatus.ACCEPTED, }); + static readonly OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN = Object.freeze({ status: ClearChargingProfileStatus.UNKNOWN, }); + static readonly OCPP_RESPONSE_UNLOCKED = Object.freeze({ status: UnlockStatus.UNLOCKED }); static readonly OCPP_RESPONSE_UNLOCK_FAILED = Object.freeze({ status: UnlockStatus.UNLOCK_FAILED, }); + static readonly OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED = Object.freeze({ status: UnlockStatus.NOT_SUPPORTED, }); + static readonly OCPP_AVAILABILITY_RESPONSE_ACCEPTED = Object.freeze({ status: AvailabilityStatus.ACCEPTED, }); + static readonly OCPP_AVAILABILITY_RESPONSE_REJECTED = Object.freeze({ status: AvailabilityStatus.REJECTED, }); + static readonly OCPP_AVAILABILITY_RESPONSE_SCHEDULED = Object.freeze({ status: AvailabilityStatus.SCHEDULED, }); + static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED = Object.freeze({ status: TriggerMessageStatus.ACCEPTED, }); + static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED = Object.freeze({ status: TriggerMessageStatus.REJECTED, }); + static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED = Object.freeze({ status: TriggerMessageStatus.NOT_IMPLEMENTED, }); -- 2.34.1