Skip to content

Commit

Permalink
infra(unicorn): consistent-destructuring (#2462)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Oct 11, 2023
1 parent 5395074 commit 28d3bad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/filename-case': 'off',
Expand Down
18 changes: 8 additions & 10 deletions src/modules/helpers/unique.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand All @@ -141,7 +139,7 @@ export function exec<
return result;
}

// console.log('conflict', result);
// Conflict, try again.
options.currentIterations++;
return exec(method, args, {
...options,
Expand Down

0 comments on commit 28d3bad

Please sign in to comment.