From 57bcd970883ebfa54952a0893bbaaa1c29c3c0d0 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Sat, 7 Oct 2023 10:14:57 +0200 Subject: [PATCH] infra(unicorn): prefer-date-now (#2419) Co-authored-by: ST-DDT --- .eslintrc.js | 1 - src/modules/helpers/index.ts | 2 +- src/modules/helpers/unique.ts | 4 ++-- test/modules/helpers.spec.ts | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 4e8dda505fa..1c8d5096c94 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -76,7 +76,6 @@ module.exports = defineConfig({ 'unicorn/prefer-array-flat-map': 'off', 'unicorn/prefer-array-some': 'off', 'unicorn/prefer-code-point': 'off', - 'unicorn/prefer-date-now': 'off', 'unicorn/prefer-export-from': 'off', 'unicorn/prefer-includes': 'off', 'unicorn/prefer-module': 'off', diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts index f5e7e1771a8..7ace1e913f8 100644 --- a/src/modules/helpers/index.ts +++ b/src/modules/helpers/index.ts @@ -1181,7 +1181,7 @@ export class SimpleHelpersModule { } = options; return uniqueExec.exec(method, args, { ...options, - startTime: new Date().getTime(), + startTime: Date.now(), maxTime, maxRetries, currentIterations: 0, diff --git a/src/modules/helpers/unique.ts b/src/modules/helpers/unique.ts index c096854a6eb..860404455f5 100644 --- a/src/modules/helpers/unique.ts +++ b/src/modules/helpers/unique.ts @@ -89,10 +89,10 @@ export function exec< store?: Record; } = {} ): ReturnType { - const now = new Date().getTime(); + const now = Date.now(); const { - startTime = new Date().getTime(), + startTime = Date.now(), maxTime = 50, maxRetries = 50, compare = defaultCompare, diff --git a/test/modules/helpers.spec.ts b/test/modules/helpers.spec.ts index 7b709373f24..df8f00e7c09 100644 --- a/test/modules/helpers.spec.ts +++ b/test/modules/helpers.spec.ts @@ -1292,7 +1292,7 @@ Try adjusting maxTime or maxRetries parameters for faker.helpers.unique().`) it('should not mutate most of the input option properties', () => { const method = () => 'options-mutate-test'; - const startTime = new Date().getTime(); + const startTime = Date.now(); const maxTime = 49; const maxRetries = 49; const currentIterations = 0;