diff --git a/eslint.config.js b/eslint.config.js index a2177834e..380974876 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -231,6 +231,7 @@ const configs = antfu( }], 'unicorn/explicit-length-check': 'error', 'unicorn/new-for-builtins': 'error', + 'unicorn/no-array-for-each': 'error', 'unicorn/no-array-reduce': 'error', 'unicorn/no-for-loop': 'error', 'unicorn/no-invalid-remove-event-listener': 'error', @@ -268,7 +269,6 @@ const configs = antfu( 'unicorn/require-number-to-fixed-digits-argument': 'error', // Might want to enable these - 'unicorn/no-array-for-each': 'off', 'unicorn/no-await-expression-member': 'off', 'unicorn/no-negated-condition': 'off', 'unicorn/no-object-as-default-parameter': 'off', diff --git a/src/identity/storage/ExpiringAdapterFactory.ts b/src/identity/storage/ExpiringAdapterFactory.ts index 4e612f11b..27c0204b5 100644 --- a/src/identity/storage/ExpiringAdapterFactory.ts +++ b/src/identity/storage/ExpiringAdapterFactory.ts @@ -89,9 +89,9 @@ export class ExpiringAdapter implements Adapter { return; } const deletePromises: Promise[] = []; - grants.forEach((grant): void => { + for (const grant of grants) { deletePromises.push(this.storage.delete(grant)); - }); + } deletePromises.push(this.storage.delete(grantKey)); await Promise.all(deletePromises); } diff --git a/src/util/HeaderUtil.ts b/src/util/HeaderUtil.ts index ea4d8c481..9e5a3a140 100644 --- a/src/util/HeaderUtil.ts +++ b/src/util/HeaderUtil.ts @@ -166,7 +166,7 @@ function parseAcceptPart(part: string, replacements: Record, str const extensionParams: Record = {}; let map = mediaTypeParams; const parsedParams = parseParameters(parameters, replacements); - parsedParams.forEach(({ name, value }): void => { + for (const { name, value } of parsedParams) { if (name === 'q') { // Extension parameters appear after the q value map = extensionParams; @@ -179,11 +179,11 @@ function parseAcceptPart(part: string, replacements: Record, str if (!value && map !== extensionParams) { handleInvalidValue(`Invalid Accept parameter ${name}: ` + `Accept parameter values are not optional when preceding the q value`, strict); - return; + continue; } map[name] = value || ''; } - }); + } return { range, diff --git a/test/integration/RedisLocker.test.ts b/test/integration/RedisLocker.test.ts index d25ebad27..e96a38e43 100644 --- a/test/integration/RedisLocker.test.ts +++ b/test/integration/RedisLocker.test.ts @@ -198,7 +198,9 @@ describeIf('docker')('A server with a RedisLocker', (): void => { countdown -= 1; // Start releasing locks after 3 inits of the promises below if (countdown === 0) { - [ 1, 0, 2 ].forEach((num): unknown => releaseSignal.emit(`release${num}`)); + for (const num of [ 1, 0, 2 ]) { + releaseSignal.emit(`release${num}`); + } } }); const promises = [ 0, 1, 2 ].map(async(num): Promise => diff --git a/test/unit/util/map/HashMap.test.ts b/test/unit/util/map/HashMap.test.ts index cebad5171..67cf48134 100644 --- a/test/unit/util/map/HashMap.test.ts +++ b/test/unit/util/map/HashMap.test.ts @@ -70,6 +70,7 @@ describe('A HashMap', (): void => { it('supports a forEach call.', async(): Promise => { const result: string[] = []; + // eslint-disable-next-line unicorn/no-array-for-each map.forEach((value): void => { result.push(value.field3); }); diff --git a/test/unit/util/map/WrappedSetMultiMap.test.ts b/test/unit/util/map/WrappedSetMultiMap.test.ts index 7945ad477..f09fe4f78 100644 --- a/test/unit/util/map/WrappedSetMultiMap.test.ts +++ b/test/unit/util/map/WrappedSetMultiMap.test.ts @@ -156,6 +156,7 @@ describe('A WrappedSetMultiMap', (): void => { it('supports a forEach call.', async(): Promise => { expect(map.set(key, new Set([ 123, 456 ]))).toBe(map); const result: number[] = []; + // eslint-disable-next-line unicorn/no-array-for-each map.forEach((value): void => { result.push(value); }); diff --git a/test/util/Util.ts b/test/util/Util.ts index 61782e02f..3c7c86f98 100644 --- a/test/util/Util.ts +++ b/test/util/Util.ts @@ -146,7 +146,7 @@ export function mockFileSystem(rootFilepath?: string, time?: Date): { data: any const name = parts.at(-1) as string; parts = parts.slice(0, -1); let folder = cache.data; - parts.forEach((part): any => { + for (const part of parts) { if (typeof folder === 'string') { throwSystemError('ENOTDIR'); } @@ -154,7 +154,7 @@ export function mockFileSystem(rootFilepath?: string, time?: Date): { data: any if (!folder) { throwSystemError('ENOENT'); } - }); + } return { folder, name }; }