{
"root": true,
- "parser": "@typescript-eslint/parser",
- "parserOptions": {
- "project": "./tsconfig.json"
- },
"extends": [
"eslint:recommended",
- "plugin:@typescript-eslint/recommended",
- "plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/errors",
"plugin:import/warnings",
- "plugin:import/typescript",
"plugin:jsdoc/recommended",
"plugin:prettier/recommended"
],
- "plugins": ["import", "jsdoc", "@typescript-eslint"],
+ "plugins": ["import", "jsdoc"],
"settings": {
"jsdoc": {
"mode": "typescript"
}
},
"rules": {
- "@typescript-eslint/array-type": "off",
- "semi": "off",
- "@typescript-eslint/semi": ["error", "always"],
"space-before-blocks": ["error", "always"],
- "@typescript-eslint/no-empty-function": [
- "warn",
- {
- "allow": ["arrowFunctions", "methods"]
- }
- ],
- "@typescript-eslint/member-ordering": "error",
- "@typescript-eslint/await-thenable": "error",
- "@typescript-eslint/no-floating-promises": "error",
- "@typescript-eslint/promise-function-async": "error",
- "@typescript-eslint/no-misused-promises": "error",
"curly": ["error", "all"],
"brace-style": "error",
"eqeqeq": ["error", "always"],
"no-return-assign": ["error", "always"],
"no-useless-catch": "error",
"no-useless-return": "error",
- "no-shadow": "off", // This one is generating false positive no-shadow errors on exported/const enums
- "@typescript-eslint/no-shadow": "error",
"no-multiple-empty-lines": [
"error",
{
"no-lonely-if": "error",
"no-trailing-spaces": "error",
"no-whitespace-before-property": "error",
- "space-before-function-paren": [
- "error",
- {
- "anonymous": "never",
- "named": "never",
- "asyncArrow": "always"
- }
- ],
"space-in-parens": ["error", "never"],
"space-infix-ops": "error",
"space-unary-ops": "error",
},
"overrides": [
{
- "files": ["*.js"],
+ "files": ["**/*.ts"],
+ "parser": "@typescript-eslint/parser",
+ "parserOptions": {
+ "project": "./tsconfig.json"
+ },
+ "extends": [
+ "plugin:@typescript-eslint/recommended",
+ "plugin:@typescript-eslint/recommended-requiring-type-checking",
+ "plugin:import/typescript"
+ ],
+ "plugins": ["@typescript-eslint"],
+ "rules": {
+ "@typescript-eslint/array-type": "off",
+ "semi": "off",
+ "@typescript-eslint/semi": ["error", "always"],
+ "@typescript-eslint/no-empty-function": "warn",
+ "@typescript-eslint/member-ordering": "error",
+ "@typescript-eslint/await-thenable": "error",
+ "@typescript-eslint/no-floating-promises": "error",
+ "@typescript-eslint/promise-function-async": "error",
+ "@typescript-eslint/no-misused-promises": "error",
+ "no-shadow": "off", // This one is generating false positive no-shadow errors on exported/const enums
+ "@typescript-eslint/no-shadow": "error"
+ }
+ },
+ {
+ "files": ["**/*.js"],
"extends": "plugin:node/recommended",
"rules": {
- "node/shebang": "off",
- "@typescript-eslint/no-unused-vars": "off",
- "@typescript-eslint/no-var-requires": "off"
+ "node/shebang": "off"
}
}
]
} from '../types/ocpp/Configuration';
import { MeterValueMeasurand, MeterValuePhase } from '../types/ocpp/MeterValues';
import { WSError, WebSocketCloseEventStatusCode } from '../types/WebSocket';
-import WebSocket, { ClientOptions, Data, OPEN } from 'ws';
+import WebSocket, { ClientOptions, Data, OPEN, RawData } from 'ws';
import AutomaticTransactionGenerator from './AutomaticTransactionGenerator';
import { ChargePointStatus } from '../types/ocpp/ChargePointStatus';
if (interval > 0) {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
this.getConnectorStatus(connectorId).transactionSetInterval = setInterval(
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
async (): Promise<void> => {
await this.ocppRequestService.sendMeterValues(
connectorId,
// Monitor station template file
this.startStationTemplateFileMonitoring();
// Handle WebSocket message
- this.wsConnection.on('message', this.onMessage.bind(this));
+ this.wsConnection.on(
+ 'message',
+ this.onMessage.bind(this) as (this: WebSocket, data: RawData, isBinary: boolean) => void
+ );
// Handle WebSocket error
- this.wsConnection.on('error', this.onError.bind(this));
+ this.wsConnection.on(
+ 'error',
+ this.onError.bind(this) as (this: WebSocket, error: Error) => void
+ );
// Handle WebSocket close
- this.wsConnection.on('close', this.onClose.bind(this));
+ this.wsConnection.on(
+ 'close',
+ this.onClose.bind(this) as (this: WebSocket, code: number, reason: Buffer) => void
+ );
// Handle WebSocket open
- this.wsConnection.on('open', this.onOpen.bind(this));
+ this.wsConnection.on('open', this.onOpen.bind(this) as (this: WebSocket) => void);
// Handle WebSocket ping
- this.wsConnection.on('ping', this.onPing.bind(this));
+ this.wsConnection.on('ping', this.onPing.bind(this) as (this: WebSocket, data: Buffer) => void);
// Handle WebSocket pong
- this.wsConnection.on('pong', this.onPong.bind(this));
+ this.wsConnection.on('pong', this.onPong.bind(this) as (this: WebSocket, data: Buffer) => void);
parentPort.postMessage({
id: ChargingStationWorkerMessageEvents.STARTED,
data: { id: this.stationInfo.chargingStationId },
break;
// Error
default:
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
errMsg = `${this.logPrefix()} Wrong message type ${messageType}`;
logger.error(errMsg);
throw new OCPPError(ErrorType.PROTOCOL_ERROR, errMsg);
logger.debug(this.logPrefix() + ' Received a WS pong (rfc6455) from the server');
}
- private async onError(error: WSError): Promise<void> {
+ private onError(error: WSError): void {
logger.error(this.logPrefix() + ' WebSocket error: %j', error);
- // switch (error.code) {
- // case 'ECONNREFUSED':
- // await this.reconnect(error);
- // break;
- // }
}
private getTemplateChargingStationConfiguration(): ChargingStationConfiguration {