From b5c8ed9ee54cdaff855cca80e04643d6242bd463 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Tue, 10 Oct 2023 10:49:25 +0200 Subject: [PATCH] infra(unicorn): consistent-destructuring --- .eslintrc.js | 1 - src/modules/helpers/unique.ts | 18 ++++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5625ba35fcb..e5ef52a2f94 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -49,7 +49,6 @@ module.exports = defineConfig({ // Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently. 'unicorn/better-regex': 'off', 'unicorn/catch-error-name': 'off', - 'unicorn/consistent-destructuring': 'off', 'unicorn/consistent-function-scoping': 'off', 'unicorn/escape-case': 'off', 'unicorn/explicit-length-check': 'off', diff --git a/src/modules/helpers/unique.ts b/src/modules/helpers/unique.ts index 860404455f5..3b2aba4e82e 100644 --- a/src/modules/helpers/unique.ts +++ b/src/modules/helpers/unique.ts @@ -95,39 +95,37 @@ export function exec< startTime = Date.now(), maxTime = 50, maxRetries = 50, + currentIterations = 0, compare = defaultCompare, store, } = options; let { exclude } = options; - options.currentIterations = options.currentIterations ?? 0; + options.currentIterations = currentIterations; // Support single exclude argument as string if (!Array.isArray(exclude)) { exclude = [exclude]; } - // if (options.currentIterations > 0) { - // console.log('iterating', options.currentIterations) - // } - - // console.log(now - startTime) + // If out of time -> throw error. if (now - startTime >= maxTime) { return errorMessage( startTime, now, `Exceeded maxTime: ${maxTime}`, store, - options.currentIterations + currentIterations ); } - if (options.currentIterations >= maxRetries) { + // If out of retries -> throw error. + if (currentIterations >= maxRetries) { return errorMessage( startTime, now, `Exceeded maxRetries: ${maxRetries}`, store, - options.currentIterations + currentIterations ); } @@ -141,7 +139,7 @@ export function exec< return result; } - // console.log('conflict', result); + // Conflict, try again. options.currentIterations++; return exec(method, args, { ...options,