From: Jérôme Benoit Date: Sun, 17 Oct 2021 22:50:28 +0000 (+0200) Subject: Silence some linter errors X-Git-Tag: v1.1.31~15 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=881840227e53e3b8061a4025ff37aa056370e080;p=e-mobility-charging-stations-simulator.git Silence some linter errors Signed-off-by: Jérôme Benoit --- diff --git a/package-lock.json b/package-lock.json index 1b4ca438..84344d6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10109,16 +10109,16 @@ } }, "expect": { - "version": "27.2.5", - "resolved": "https://registry.npmjs.org/expect/-/expect-27.2.5.tgz", - "integrity": "sha512-ZrO0w7bo8BgGoP/bLz+HDCI+0Hfei9jUSZs5yI/Wyn9VkG9w8oJ7rHRgYj+MA7yqqFa0IwHA3flJzZtYugShJA==", + "version": "27.3.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-27.3.0.tgz", + "integrity": "sha512-JBRU82EBkZUBqLBAoF3ovzNGEBm14QQnePK4PmZdm6de6q/UzPnmIuWP3dRCw/FE8wRQhf/1eKzy1p1q8d6EvQ==", "dev": true, "requires": { "@jest/types": "^27.2.5", "ansi-styles": "^5.0.0", "jest-get-type": "^27.0.6", - "jest-matcher-utils": "^27.2.5", - "jest-message-util": "^27.2.5", + "jest-matcher-utils": "^27.3.0", + "jest-message-util": "^27.3.0", "jest-regex-util": "^27.0.6" }, "dependencies": { @@ -12517,15 +12517,15 @@ } }, "jest-diff": { - "version": "27.2.5", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-27.2.5.tgz", - "integrity": "sha512-7gfwwyYkeslOOVQY4tVq5TaQa92mWfC9COsVYMNVYyJTOYAqbIkoD3twi5A+h+tAPtAelRxkqY6/xu+jwTr0dA==", + "version": "27.3.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-27.3.0.tgz", + "integrity": "sha512-Nl2rE58B2ye+RvPcU4hN+6wBCHxX7aWz6RMTMFxe9jAg8ZueMj5QQ+T/nmHRutbBc5BEjrbbEWOrRzp9rUEsYA==", "dev": true, "requires": { "chalk": "^4.0.0", "diff-sequences": "^27.0.6", "jest-get-type": "^27.0.6", - "pretty-format": "^27.2.5" + "pretty-format": "^27.3.0" } }, "jest-get-type": { @@ -12535,21 +12535,21 @@ "dev": true }, "jest-matcher-utils": { - "version": "27.2.5", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-27.2.5.tgz", - "integrity": "sha512-qNR/kh6bz0Dyv3m68Ck2g1fLW5KlSOUNcFQh87VXHZwWc/gY6XwnKofx76Qytz3x5LDWT09/2+yXndTkaG4aWg==", + "version": "27.3.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-27.3.0.tgz", + "integrity": "sha512-AK2ds5J29PJcZhfJ/5J8ycbjCXTHnwc6lQeOV1a1GahU1MCpSvyHG1iIevyvp6PXPy6r0q9ywGdCObWHmkK16g==", "dev": true, "requires": { "chalk": "^4.0.0", - "jest-diff": "^27.2.5", + "jest-diff": "^27.3.0", "jest-get-type": "^27.0.6", - "pretty-format": "^27.2.5" + "pretty-format": "^27.3.0" } }, "jest-message-util": { - "version": "27.2.5", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-27.2.5.tgz", - "integrity": "sha512-ggXSLoPfIYcbmZ8glgEJZ8b+e0Msw/iddRmgkoO7lDAr9SmI65IIfv7VnvTnV4FGnIIUIjzM+fHRHO5RBvyAbQ==", + "version": "27.3.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-27.3.0.tgz", + "integrity": "sha512-0c79aomiyE3mlta4NCWsICydvv2W0HlM/eVx46YEO+vdDuwUvNuQn8LqOtcHC1hSd25i03RrPvscrWgHBJQpRQ==", "dev": true, "requires": { "@babel/code-frame": "^7.12.13", @@ -12558,7 +12558,7 @@ "chalk": "^4.0.0", "graceful-fs": "^4.2.4", "micromatch": "^4.0.4", - "pretty-format": "^27.2.5", + "pretty-format": "^27.3.0", "slash": "^3.0.0", "stack-utils": "^2.0.3" }, @@ -13523,9 +13523,9 @@ "dev": true }, "mocha": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.2.tgz", - "integrity": "sha512-ta3LtJ+63RIBP03VBjMGtSqbe6cWXRejF9SyM9Zyli1CKZJZ+vfCTj3oW24V7wAphMJdpOFLoMI3hjJ1LWbs0w==", + "version": "9.1.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz", + "integrity": "sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", @@ -16017,9 +16017,9 @@ "dev": true }, "pretty-format": { - "version": "27.2.5", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.2.5.tgz", - "integrity": "sha512-+nYn2z9GgicO9JiqmY25Xtq8SYfZ/5VCpEU3pppHHNAhd1y+ZXxmNPd1evmNcAd6Hz4iBV2kf0UpGth5A/VJ7g==", + "version": "27.3.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.3.0.tgz", + "integrity": "sha512-Nkdd0xmxZdjCe6GoJomHnrLcCYGYzZKI/fRnUX0sCwDai2mmCHJfC9Ecx33lYgaxAFS/pJCAqhfxmWlm1wNVag==", "dev": true, "requires": { "@jest/types": "^27.2.5", diff --git a/package.json b/package.json index 44a56170..eca63f40 100644 --- a/package.json +++ b/package.json @@ -108,8 +108,8 @@ "eslint-plugin-import": "^2.25.2", "eslint-plugin-jsdoc": "^36.1.1", "eslint-plugin-node": "^11.1.0", - "expect": "^27.2.5", - "mocha": "^9.1.2", + "expect": "^27.3.0", + "mocha": "^9.1.3", "mochawesome": "^6.3.1", "npm-check": "^5.9.2", "nyc": "^15.1.0", diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index b0ca0117..92e4a912 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -443,7 +443,7 @@ export default class ChargingStation { stationTemplateFromFile = JSON.parse(fs.readFileSync(fileDescriptor, 'utf8')) as ChargingStationTemplate; fs.closeSync(fileDescriptor); } catch (error) { - FileUtils.handleFileException(this.logPrefix(), 'Template', this.stationTemplateFile, error); + FileUtils.handleFileException(this.logPrefix(), 'Template', this.stationTemplateFile, error as NodeJS.ErrnoException); } const stationInfo: ChargingStationInfo = stationTemplateFromFile ?? {} as ChargingStationInfo; stationInfo.wsOptions = stationTemplateFromFile?.wsOptions ?? {}; @@ -710,7 +710,7 @@ export default class ChargingStation { // Log logger.error('%s Incoming OCPP message %j matching cached request %j processing error %j', this.logPrefix(), data.toString(), this.requests.get(messageId), error); // Send error - messageType === MessageType.CALL_MESSAGE && await this.ocppRequestService.sendError(messageId, error, commandName); + messageType === MessageType.CALL_MESSAGE && await this.ocppRequestService.sendError(messageId, error as OCPPError, commandName); } } @@ -749,7 +749,7 @@ export default class ChargingStation { authorizedTags = JSON.parse(fs.readFileSync(fileDescriptor, 'utf8')) as string[]; fs.closeSync(fileDescriptor); } catch (error) { - FileUtils.handleFileException(this.logPrefix(), 'Authorization', authorizationFile, error); + FileUtils.handleFileException(this.logPrefix(), 'Authorization', authorizationFile, error as NodeJS.ErrnoException); } } else { logger.info(this.logPrefix() + ' No authorization file given in template file ' + this.stationTemplateFile); @@ -952,7 +952,7 @@ export default class ChargingStation { if (this.isWebSocketConnectionOpened() && forceCloseOpened) { this.wsConnection.close(); } - let protocol; + let protocol: string; switch (this.getOCPPVersion()) { case OCPPVersion.VERSION_16: protocol = 'ocpp' + OCPPVersion.VERSION_16; @@ -987,7 +987,7 @@ export default class ChargingStation { } }); } catch (error) { - FileUtils.handleFileException(this.logPrefix(), 'Authorization', authorizationFile, error); + FileUtils.handleFileException(this.logPrefix(), 'Authorization', authorizationFile, error as NodeJS.ErrnoException); } } else { logger.info(this.logPrefix() + ' No authorization file given in template file ' + this.stationTemplateFile + '. Not monitoring changes'); @@ -1020,7 +1020,7 @@ export default class ChargingStation { } }); } catch (error) { - FileUtils.handleFileException(this.logPrefix(), 'Template', this.stationTemplateFile, error); + FileUtils.handleFileException(this.logPrefix(), 'Template', this.stationTemplateFile, error as NodeJS.ErrnoException); } } diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 1aa5a9bb..eb0bdb80 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -409,7 +409,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer if (ftpClient) { ftpClient.close(); } - return this.handleIncomingRequestError(OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, error, Constants.OCPP_RESPONSE_EMPTY); + return this.handleIncomingRequestError(OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, error as Error, Constants.OCPP_RESPONSE_EMPTY); } } else { logger.error(`${this.chargingStation.logPrefix()} Unsupported protocol ${uri.protocol} to transfer the diagnostic logs archive`); @@ -437,7 +437,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED; } } catch (error) { - return this.handleIncomingRequestError(OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, error, Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED); + return this.handleIncomingRequestError(OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, error as Error, Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED); } } } diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 4daf9628..4acaaac1 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -27,7 +27,7 @@ export default class OCPP16RequestService extends OCPPRequestService { const payload: HeartbeatRequest = {}; await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.HEARTBEAT); } catch (error) { - this.handleRequestError(OCPP16RequestCommand.HEARTBEAT, error); + this.handleRequestError(OCPP16RequestCommand.HEARTBEAT, error as Error); } } @@ -47,7 +47,7 @@ export default class OCPP16RequestService extends OCPPRequestService { }; return await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.BOOT_NOTIFICATION, true) as OCPP16BootNotificationResponse; } catch (error) { - this.handleRequestError(OCPP16RequestCommand.BOOT_NOTIFICATION, error); + this.handleRequestError(OCPP16RequestCommand.BOOT_NOTIFICATION, error as Error); } } @@ -61,7 +61,7 @@ export default class OCPP16RequestService extends OCPPRequestService { }; await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.STATUS_NOTIFICATION); } catch (error) { - this.handleRequestError(OCPP16RequestCommand.STATUS_NOTIFICATION, error); + this.handleRequestError(OCPP16RequestCommand.STATUS_NOTIFICATION, error as Error); } } @@ -73,7 +73,7 @@ export default class OCPP16RequestService extends OCPPRequestService { this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag = idTag; return await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.AUTHORIZE) as OCPP16AuthorizeResponse; } catch (error) { - this.handleRequestError(OCPP16RequestCommand.AUTHORIZE, error); + this.handleRequestError(OCPP16RequestCommand.AUTHORIZE, error as Error); } } @@ -87,7 +87,7 @@ export default class OCPP16RequestService extends OCPPRequestService { }; return await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.START_TRANSACTION) as OCPP16StartTransactionResponse; } catch (error) { - this.handleRequestError(OCPP16RequestCommand.START_TRANSACTION, error); + this.handleRequestError(OCPP16RequestCommand.START_TRANSACTION, error as Error); } } @@ -115,7 +115,7 @@ export default class OCPP16RequestService extends OCPPRequestService { }; return await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.STOP_TRANSACTION) as OCPP16StartTransactionResponse; } catch (error) { - this.handleRequestError(OCPP16RequestCommand.STOP_TRANSACTION, error); + this.handleRequestError(OCPP16RequestCommand.STOP_TRANSACTION, error as Error); } } @@ -337,7 +337,7 @@ export default class OCPP16RequestService extends OCPPRequestService { }; await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.METER_VALUES); } catch (error) { - this.handleRequestError(OCPP16RequestCommand.METER_VALUES, error); + this.handleRequestError(OCPP16RequestCommand.METER_VALUES, error as Error); } } @@ -350,7 +350,7 @@ export default class OCPP16RequestService extends OCPPRequestService { }; await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.METER_VALUES); } catch (error) { - this.handleRequestError(OCPP16RequestCommand.METER_VALUES, error); + this.handleRequestError(OCPP16RequestCommand.METER_VALUES, error as Error); } } @@ -363,7 +363,7 @@ export default class OCPP16RequestService extends OCPPRequestService { }; await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.METER_VALUES); } catch (error) { - this.handleRequestError(OCPP16RequestCommand.METER_VALUES, error); + this.handleRequestError(OCPP16RequestCommand.METER_VALUES, error as Error); } } @@ -374,7 +374,7 @@ export default class OCPP16RequestService extends OCPPRequestService { }; await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION); } catch (error) { - this.handleRequestError(OCPP16RequestCommand.METER_VALUES, error); + this.handleRequestError(OCPP16RequestCommand.METER_VALUES, error as Error); } } @@ -383,7 +383,7 @@ export default class OCPP16RequestService extends OCPPRequestService { // Send error return await this.sendMessage(messageId, error, MessageType.CALL_ERROR_MESSAGE, commandName); } catch (err) { - this.handleRequestError(commandName as OCPP16RequestCommand, err); + this.handleRequestError(commandName as OCPP16RequestCommand, err as Error); } } }