Skip to content

Commit cbbec15

Browse files
committed
fix(eslint): auto-fix unicorn/no-array-for-each rule violations
1 parent aa1ea2a commit cbbec15

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

src/libs/SearchQueryUtils.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,20 @@ const createKeyToUserFriendlyMap = () => {
6464
const map = new Map<string, string>();
6565

6666
// Map SYNTAX_FILTER_KEYS values to their user-friendly names
67-
Object.entries(CONST.SEARCH.SYNTAX_FILTER_KEYS).forEach(([keyName, keyValue]) => {
67+
for (const [keyName, keyValue] of Object.entries(CONST.SEARCH.SYNTAX_FILTER_KEYS)) {
6868
if (!(keyName in CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS)) {
69-
return;
69+
continue;
7070
}
7171
map.set(keyValue, CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS[keyName as keyof typeof CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS]);
72-
});
72+
}
7373

7474
// Map SYNTAX_ROOT_KEYS values to their user-friendly names
75-
Object.entries(CONST.SEARCH.SYNTAX_ROOT_KEYS).forEach(([keyName, keyValue]) => {
75+
for (const [keyName, keyValue] of Object.entries(CONST.SEARCH.SYNTAX_ROOT_KEYS)) {
7676
if (!(keyName in CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS)) {
77-
return;
77+
continue;
7878
}
7979
map.set(keyValue, CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS[keyName as keyof typeof CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS]);
80-
});
80+
}
8181

8282
return map;
8383
};
@@ -190,7 +190,7 @@ function buildFilterValuesString(filterName: string, queryFilters: QueryFilter[]
190190
const allowedOps = new Set<string>([CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO, CONST.SEARCH.SYNTAX_OPERATORS.NOT_EQUAL_TO]);
191191

192192
let filterValueString = '';
193-
queryFilters.forEach((queryFilter, index) => {
193+
for (const [index, queryFilter] of queryFilters.entries()) {
194194
const previousValueHasSameOp = allowedOps.has(queryFilter.operator) && queryFilters?.at(index - 1)?.operator === queryFilter.operator;
195195
const nextValueHasSameOp = allowedOps.has(queryFilter.operator) && queryFilters?.at(index + 1)?.operator === queryFilter.operator;
196196

@@ -204,7 +204,7 @@ function buildFilterValuesString(filterName: string, queryFilters: QueryFilter[]
204204
} else {
205205
filterValueString += ` ${filterName}${operatorToCharMap[queryFilter.operator]}${sanitizeSearchValue(queryFilter.value.toString())}`;
206206
}
207-
});
207+
}
208208

209209
return filterValueString;
210210
}
@@ -248,12 +248,12 @@ function getFilters(queryJSON: SearchQueryJSON) {
248248
value: node.right as string | number,
249249
});
250250
} else {
251-
node.right.forEach((element) => {
251+
for (const element of node.right) {
252252
filterArray.push({
253253
operator: node.operator,
254254
value: element,
255255
});
256-
});
256+
}
257257
}
258258
filters.push({key: nodeKey, filters: filterArray});
259259
}
@@ -479,13 +479,13 @@ function buildQueryStringFromFilterFormValues(filterValues: Partial<SearchAdvanc
479479
// When switching types/setting the type, ensure we aren't polluting our query with filters that are
480480
// only available for the previous type. Remove all filters that are not allowed for the new type
481481
const providedFilterKeys = Object.keys(supportedFilterValues) as SearchAdvancedFiltersKey[];
482-
providedFilterKeys.forEach((filter) => {
482+
for (const filter of providedFilterKeys) {
483483
if (isFilterSupported(filter, supportedFilterValues.type ?? CONST.SEARCH.DATA_TYPES.EXPENSE)) {
484-
return;
484+
continue;
485485
}
486486

487487
supportedFilterValues[filter] = undefined;
488-
});
488+
}
489489

490490
// We separate type and status filters from other filters to maintain hashes consistency for saved searches
491491
const {type, status, groupBy, ...otherFilters} = supportedFilterValues;
@@ -624,15 +624,15 @@ function buildQueryStringFromFilterFormValues(filterValues: Partial<SearchAdvanc
624624

625625
filtersString.push(...mappedFilters);
626626

627-
DATE_FILTER_KEYS.forEach((dateKey) => {
627+
for (const dateKey of DATE_FILTER_KEYS) {
628628
const dateFilter = buildDateFilterQuery(supportedFilterValues, dateKey);
629629
filtersString.push(dateFilter);
630-
});
630+
}
631631

632-
AMOUNT_FILTER_KEYS.forEach((filterKey) => {
632+
for (const filterKey of AMOUNT_FILTER_KEYS) {
633633
const amountFilter = buildAmountFilterQuery(filterKey, supportedFilterValues);
634634
filtersString.push(amountFilter);
635-
});
635+
}
636636

637637
return filtersString.filter(Boolean).join(' ').trim();
638638
}

src/libs/actions/OnyxUpdateManager/index.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,24 +204,30 @@ function handleMissingOnyxUpdates(onyxUpdatesFromServer: OnyxEntry<OnyxUpdatesFr
204204
function updateAuthTokenIfNecessary(onyxUpdatesFromServer: OnyxEntry<OnyxUpdatesFromServer>): void {
205205
// Consolidate all of the given Onyx updates
206206
const onyxUpdates: OnyxUpdate[] = [];
207-
onyxUpdatesFromServer?.updates?.forEach((updateEvent) => onyxUpdates.push(...updateEvent.data));
207+
if (onyxUpdatesFromServer?.updates) {
208+
for (const updateEvent of onyxUpdatesFromServer.updates) {
209+
onyxUpdates.push(...updateEvent.data);
210+
}
211+
}
208212
onyxUpdates.push(...(onyxUpdatesFromServer?.response?.onyxData ?? []));
209213

210214
// Find any session updates
211215
const sessionUpdates = onyxUpdates?.filter((onyxUpdate) => onyxUpdate.key === ONYXKEYS.SESSION);
212216

213217
// If any of the updates changes the authToken, let's update it now
214-
sessionUpdates?.forEach((sessionUpdate) => {
215-
const session = (sessionUpdate.value ?? {}) as Session;
216-
const newAuthToken = session.authToken ?? '';
217-
if (!newAuthToken) {
218-
return;
219-
}
218+
if (sessionUpdates) {
219+
for (const sessionUpdate of sessionUpdates) {
220+
const session = (sessionUpdate.value ?? {}) as Session;
221+
const newAuthToken = session.authToken ?? '';
222+
if (!newAuthToken) {
223+
continue;
224+
}
220225

221-
Log.info('[OnyxUpdateManager] Found an authToken update while handling an Onyx update gap. Updating the authToken.');
222-
updateSessionAuthTokens(newAuthToken);
223-
setAuthToken(newAuthToken);
224-
});
226+
Log.info('[OnyxUpdateManager] Found an authToken update while handling an Onyx update gap. Updating the authToken.');
227+
updateSessionAuthTokens(newAuthToken);
228+
setAuthToken(newAuthToken);
229+
}
230+
}
225231
}
226232

227233
export default () => {

0 commit comments

Comments
 (0)