Skip to content

Commit 9232f04

Browse files
authored
Merge pull request Expensify#76789 from gelocraft/fix-no-array-for-each-1764898524
[NO QA] fix(eslint): auto-fix unicorn/no-array-for-each rule violatons
2 parents 4a20127 + 0e99624 commit 9232f04

5 files changed

Lines changed: 18 additions & 22 deletions

File tree

src/pages/home/report/ReportActionCompose/SuggestionMention.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ function SuggestionMention({
264264

265265
const getUserMentionOptions = useCallback(
266266
(personalDetailsParam: PersonalDetailsList | SuggestionPersonalDetailsList | undefined, searchValue = ''): Mention[] => {
267-
const suggestions = [];
267+
const suggestions: Mention[] = [];
268268

269269
if (CONST.AUTO_COMPLETE_SUGGESTER.HERE_TEXT.includes(searchValue.toLowerCase())) {
270270
suggestions.push({
@@ -315,10 +315,9 @@ function SuggestionMention({
315315
// At this point we are sure that the details are not null, since empty user details have been filtered in the previous step
316316
const sortedPersonalDetails = getSortedPersonalDetails(filteredPersonalDetails, localeCompare);
317317

318-
// eslint-disable-next-line unicorn/no-array-for-each
319-
sortedPersonalDetails.slice(0, CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS - suggestions.length).forEach((detail) => {
318+
for (const detail of sortedPersonalDetails.slice(0, CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS - suggestions.length)) {
320319
suggestions.push({
321-
text: formatLoginPrivateDomain(getDisplayNameOrDefault(detail), detail?.login),
320+
text: `${formatLoginPrivateDomain(getDisplayNameOrDefault(detail), detail?.login)}`,
322321
alternateText: `@${formatLoginPrivateDomain(detail?.login, detail?.login)}`,
323322
handle: detail?.login,
324323
icons: [
@@ -331,7 +330,7 @@ function SuggestionMention({
331330
},
332331
],
333332
});
334-
});
333+
}
335334

336335
return suggestions;
337336
},
@@ -341,10 +340,9 @@ function SuggestionMention({
341340
const getRoomMentionOptions = useCallback(
342341
(searchTerm: string, reportBatch: OnyxCollection<Report>): Mention[] => {
343342
const filteredRoomMentions: Mention[] = [];
344-
// eslint-disable-next-line unicorn/no-array-for-each
345-
Object.values(reportBatch ?? {}).forEach((report) => {
343+
for (const report of Object.values(reportBatch ?? {})) {
346344
if (!canReportBeMentionedWithinPolicy(report, policyID)) {
347-
return;
345+
continue;
348346
}
349347
if (report?.reportName?.toLowerCase().includes(searchTerm.toLowerCase())) {
350348
filteredRoomMentions.push({
@@ -353,7 +351,7 @@ function SuggestionMention({
353351
alternateText: report.reportName,
354352
});
355353
}
356-
});
354+
}
357355

358356
return lodashSortBy(filteredRoomMentions, 'handle').slice(0, CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS);
359357
},

src/pages/iou/request/step/IOURequestStepScan/index.native.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ function IOURequestStepScan({
310310
billable?: boolean,
311311
reimbursable = true,
312312
) => {
313-
// eslint-disable-next-line unicorn/no-array-for-each
314-
files.forEach((receiptFile: ReceiptFile, index) => {
313+
for (const [index, receiptFile] of files.entries()) {
315314
const transaction = transactions.find((item) => item.transactionID === receiptFile.transactionID);
316315
const receipt: Receipt = receiptFile.file ?? {};
317316
receipt.source = receiptFile.source;
@@ -366,7 +365,7 @@ function IOURequestStepScan({
366365
transactionViolations,
367366
});
368367
}
369-
});
368+
}
370369
},
371370
[
372371
transactions,

src/pages/iou/request/step/IOURequestStepScan/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,7 @@ function IOURequestStepScan({
369369
billable?: boolean,
370370
reimbursable = true,
371371
) => {
372-
// eslint-disable-next-line unicorn/no-array-for-each
373-
files.forEach((receiptFile: ReceiptFile, index) => {
372+
for (const [index, receiptFile] of files.entries()) {
374373
const transaction = transactions.find((item) => item.transactionID === receiptFile.transactionID);
375374
const receipt: Receipt = receiptFile.file ?? {};
376375
receipt.source = receiptFile.source;
@@ -426,7 +425,7 @@ function IOURequestStepScan({
426425
transactionViolations,
427426
});
428427
}
429-
});
428+
}
430429
},
431430
[
432431
backToReport,

src/pages/workspace/accounting/intacct/SageIntacctEntityPage.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ function SageIntacctEntityPage({policy}: WithPolicyProps) {
2727
isSelected: entityID === '',
2828
},
2929
];
30-
// eslint-disable-next-line unicorn/no-array-for-each
31-
policy?.connections?.intacct?.data?.entities.forEach((entity) => {
30+
for (const entity of policy?.connections?.intacct?.data?.entities ?? []) {
3231
sections.push({
3332
text: entity.name,
3433
value: entity.name,
3534
keyForList: entity.id,
3635
isSelected: entity.id === entityID,
3736
});
38-
});
37+
}
3938

4039
const saveSelection = ({keyForList}: ListItem) => {
4140
updateSageIntacctEntity(policyID, keyForList ?? '', entityID);

src/pages/workspace/workflows/approvals/ApprovalWorkflowEditor.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ function ApprovalWorkflowEditor({approvalWorkflow, removeApprovalWorkflow, polic
5353
(index: number) => {
5454
let pendingAction: PendingAction | undefined;
5555
if (index === 0) {
56-
// eslint-disable-next-line unicorn/no-array-for-each
57-
approvalWorkflow?.members?.forEach((member) => {
58-
pendingAction = pendingAction ?? member.pendingFields?.submitsTo;
59-
});
56+
if (approvalWorkflow?.members) {
57+
for (const member of approvalWorkflow.members) {
58+
pendingAction = pendingAction ?? member.pendingFields?.submitsTo;
59+
}
60+
}
6061
return pendingAction;
6162
}
6263
const previousApprover = approvalWorkflow?.approvers.at(index - 1);

0 commit comments

Comments
 (0)