From: Jérôme Benoit Date: Mon, 11 Dec 2023 22:54:55 +0000 (+0100) Subject: build: cleanup eslint configuration X-Git-Tag: v1.2.30~22 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a78c196b969380d9d968c94fab567b0be6828f69;p=e-mobility-charging-stations-simulator.git build: cleanup eslint configuration Signed-off-by: Jérôme Benoit --- diff --git a/.eslintrc.json b/.eslintrc.json index ddb47174..408af99e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,9 +23,7 @@ "space-before-blocks": ["error", "always"], "curly": ["error", "all"], "brace-style": "error", - "eqeqeq": ["error", "always"], "no-else-return": "error", - "no-eq-null": "error", "no-extra-bind": "error", "no-lone-blocks": "error", "no-multi-spaces": "error", @@ -41,14 +39,6 @@ } ], "block-spacing": "error", - // "capitalized-comments": [ - // "error", - // "always", - // { - // "ignoreConsecutiveComments": true, - // "ignorePattern": "pragma|ignored" - // } - // ], "eol-last": ["error", "always"], "consistent-this": ["error", "self"], "func-call-spacing": ["error", "never"], diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index d3bee6c6..d99dcc3a 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -75,7 +75,9 @@ export const isValidTime = (date: unknown): boolean => { return false; }; -export const convertToDate = (value: Date | string | number | undefined): Date | undefined => { +export const convertToDate = ( + value: Date | string | number | null | undefined, +): Date | null | undefined => { if (isNullOrUndefined(value)) { return value as undefined; } @@ -127,7 +129,7 @@ export const convertToFloat = (value: unknown): number => { export const convertToBoolean = (value: unknown): boolean => { let result = false; - if (value) { + if (value != null) { // Check the type if (typeof value === 'boolean') { return value; @@ -290,7 +292,6 @@ export const isUndefined = (value: unknown): boolean => { }; export const isNullOrUndefined = (value: unknown): boolean => { - // eslint-disable-next-line eqeqeq, no-eq-null return value == null; }; diff --git a/src/worker/WorkerAbstract.ts b/src/worker/WorkerAbstract.ts index 912f5256..5e5e6fdb 100644 --- a/src/worker/WorkerAbstract.ts +++ b/src/worker/WorkerAbstract.ts @@ -21,7 +21,7 @@ export abstract class WorkerAbstract { * @param workerOptions - */ constructor(workerScript: string, workerOptions: WorkerOptions) { - if (workerScript === null || workerScript === undefined) { + if (workerScript == null) { throw new Error('Worker script is not defined'); } if (typeof workerScript === 'string' && workerScript.trim().length === 0) { diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index 62ddf807..17b5b6dd 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -105,7 +105,7 @@ export class WorkerSet extends WorkerAbstract { if (!this.started) { throw new Error('Cannot add a WorkerSet element: not started'); } - if (!this.workerSet) { + if (this.workerSet == null) { throw new Error("Cannot add a WorkerSet element: 'workerSet' property does not exist"); } const workerSetElement = await this.getWorkerSetElement(); diff --git a/tests/utils/Utils.test.ts b/tests/utils/Utils.test.ts index 82964803..615f76fa 100644 --- a/tests/utils/Utils.test.ts +++ b/tests/utils/Utils.test.ts @@ -91,6 +91,7 @@ await describe('Utils test suite', async () => { await it('Verify convertToDate()', () => { expect(convertToDate(undefined)).toBe(undefined); + expect(convertToDate(null)).toBe(null); expect(() => convertToDate('')).toThrow(new Error("Cannot convert to date: ''")); expect(() => convertToDate('00:70:61')).toThrow( new Error("Cannot convert to date: '00:70:61'"),