Fix eslint and prettier configuration
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 4 Mar 2022 22:39:37 +0000 (23:39 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 4 Mar 2022 22:39:37 +0000 (23:39 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
.eslintrc
package-lock.json
package.json
src/charging-station/AutomaticTransactionGenerator.ts
src/charging-station/ocpp/OCPPIncomingRequestService.ts
src/charging-station/ocpp/OCPPRequestService.ts
src/charging-station/ocpp/OCPPResponseService.ts
src/performance/PerformanceStatistics.ts
src/utils/Configuration.ts
src/utils/Constants.ts

index 6d8714d77aad69508da20e66ad34406a37a87f57..e98414f074edaf5b4d49e579a0aa437fbb25e679 100644 (file)
--- 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": {
     }
   },
   "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",
     "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",
         "exceptAfterSingleLine": true
       }
     ],
-    "quotes": ["error", "single"]
+    "quotes": [
+      "error",
+      "single",
+      {
+        "avoidEscape": true,
+        "allowTemplateLiterals": false
+      }
+    ]
   },
   "overrides": [
     {
index eb81da6e3385a23487b1e78cf84622fc8474d44f..172acea2bd0a2fc3eeba95e68853856abb55113e 100644 (file)
@@ -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",
         "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",
       "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",
         "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",
         }
       }
     },
+    "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",
       "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",
       "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",
index d1589d37e4540e5073c124211dfcffdebb1cf344..5fd483ae4c4d9107e5f9e6aac932c167b00f74e5 100644 (file)
     "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",
index b9d3f1d0f24f8b0898551bb0bf8c68be378afb49..cf2f4277b862752becde11a3ab7ac283f142e9b7 100644 (file)
@@ -20,6 +20,7 @@ export default class AutomaticTransactionGenerator {
     string,
     AutomaticTransactionGenerator
   >();
+
   public started: boolean;
   private readonly chargingStation: ChargingStation;
   private readonly connectorsStatus: Map<number, Status>;
index 0d56ebe84e502cc717d44e2229ac3702f039e18d..431df9b9f1d901692f86fbe1845219a21ea8bd8d 100644 (file)
@@ -9,6 +9,7 @@ export default abstract class OCPPIncomingRequestService {
     string,
     OCPPIncomingRequestService
   >();
+
   protected chargingStation: ChargingStation;
 
   protected constructor(chargingStation: ChargingStation) {
index 04cd508aa8903d805d6bda28d882d12d0db62e8a..fc465b8c3e8ac784d025f44e7fa1cd146bc2995d 100644 (file)
@@ -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<BootNotificationResponse>;
+
   public abstract sendStatusNotification(
     connectorId: number,
     status: ChargePointStatus,
     errorCode?: ChargePointErrorCode
   ): Promise<void>;
+
   public abstract sendAuthorize(connectorId: number, idTag?: string): Promise<AuthorizeResponse>;
   public abstract sendStartTransaction(
     connectorId: number,
     idTag?: string
   ): Promise<StartTransactionResponse>;
+
   public abstract sendStopTransaction(
     transactionId: number,
     meterStop: number,
     idTag?: string,
     reason?: StopTransactionReason
   ): Promise<StopTransactionResponse>;
+
   public abstract sendMeterValues(
     connectorId: number,
     transactionId: number,
     interval: number
   ): Promise<void>;
+
   public abstract sendTransactionBeginMeterValues(
     connectorId: number,
     transactionId: number,
     beginMeterValue: MeterValue
   ): Promise<void>;
+
   public abstract sendTransactionEndMeterValues(
     connectorId: number,
     transactionId: number,
     endMeterValue: MeterValue
   ): Promise<void>;
+
   public abstract sendDiagnosticsStatusNotification(
     diagnosticsStatus: DiagnosticsStatus
   ): Promise<void>;
index 2fa0112c70c6d42fc29958da64007576824b6285..311d62e393034cb449b79910363abfb332a51af9 100644 (file)
@@ -7,6 +7,7 @@ export default abstract class OCPPResponseService {
     string,
     OCPPResponseService
   >();
+
   protected readonly chargingStation: ChargingStation;
 
   protected constructor(chargingStation: ChargingStation) {
index bec0f62e28099597ab5e4a46dc75c360cf4f408a..7338fa24cbfa8d3c1908b6c781ef2df7df4d1847 100644 (file)
@@ -18,6 +18,7 @@ export default class PerformanceStatistics {
     string,
     PerformanceStatistics
   >();
+
   private readonly objId: string;
   private readonly objName: string;
   private performanceObserver: PerformanceObserver;
index 5770d76e35ae546150ba2bf6cfe6951d5055aca1..57ee31df0c355f0ddc6dd736d35a402ae9e70cb6 100644 (file)
@@ -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<void>;
index 968de2d031ab1e20fbe1e5093291a21a6328905b..79e39009b851b33233c727530f07838662407898 100644 (file)
@@ -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,
   });