-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(eslint): fix remaining unicorn/no-array-for-each violations #76791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
242eecf
314d652
809911b
f8bd886
50dcb0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import {useMemo} from 'react'; | |
| import type {OnyxCollection} from 'react-native-onyx'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {Transaction, TransactionViolations} from '@src/types/onyx'; | ||
| import type {Transaction, TransactionViolation, TransactionViolations} from '@src/types/onyx'; | ||
| import useOnyx from './useOnyx'; | ||
|
|
||
| /** | ||
|
|
@@ -21,30 +21,30 @@ function selectViolationsWithDuplicates(transactionIDs: string[], allTransaction | |
|
|
||
| for (const transactionID of transactionIDs) { | ||
| const key = `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`; | ||
| const transactionViolations = allTransactionsViolations[key]; | ||
| const transactionViolations: TransactionViolations | undefined = allTransactionsViolations[key]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added Type inference isn’t working for some reason, even though type OnyxCollection<TOnyxValue> = OnyxEntry<Record<string, TOnyxValue | undefined>>; |
||
|
|
||
| if (!transactionViolations) { | ||
| continue; | ||
| } | ||
|
|
||
| result[key] = transactionViolations; | ||
|
|
||
| transactionViolations | ||
| .filter((violations) => violations.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION) | ||
| .flatMap((violations) => violations?.data?.duplicates ?? []) | ||
| // eslint-disable-next-line unicorn/no-array-for-each | ||
| .forEach((duplicateID) => { | ||
| if (!duplicateID) { | ||
| return; | ||
| } | ||
| const duplicateTransactionIDs = transactionViolations | ||
| .filter((violation: TransactionViolation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added type to this callback |
||
| .flatMap((violation) => violation.data?.duplicates ?? []); | ||
|
|
||
| for (const duplicateID of duplicateTransactionIDs) { | ||
| if (!duplicateID) { | ||
| continue; | ||
| } | ||
|
|
||
| const duplicateKey = `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${duplicateID}`; | ||
| const duplicateViolations = allTransactionsViolations[duplicateKey]; | ||
| const duplicateKey = `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${duplicateID}`; | ||
| const duplicateViolations: TransactionViolations | undefined = allTransactionsViolations[duplicateKey]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added Type inference isn’t working for some reason, even though type OnyxCollection<TOnyxValue> = OnyxEntry<Record<string, TOnyxValue | undefined>>; |
||
|
|
||
| if (duplicateViolations) { | ||
| result[duplicateKey] = duplicateViolations; | ||
| } | ||
| }); | ||
| if (duplicateViolations) { | ||
| result[duplicateKey] = duplicateViolations; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.