Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ const config = defineConfig([
files: ['src/**/*.ts', 'src/**/*.tsx'],
rules: {
'rulesdir/prefer-locale-compare-from-context': 'error',
'rulesdir/no-object-keys-includes': 'error',
},
},

Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/FormWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function FormWrapper({

const onFixTheErrorsLinkPressed = useCallback(() => {
const errorFields = !isEmptyObject(errors) ? errors : (formState?.errorFields ?? {});
const focusKey = Object.keys(inputRefs.current ?? {}).find((key) => Object.keys(errorFields).includes(key));
const focusKey = Object.keys(inputRefs.current ?? {}).find((key) => key in errorFields);

if (!focusKey) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/BankIcons/index.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function getBankIcon({styles, bankName, isCard = false}: BankIcon
if (bankName) {
const bankNameKey = getBankNameKey(bankName.toLowerCase());

if (bankNameKey && Object.keys(CONST.BANK_NAMES).includes(bankNameKey)) {
if (bankNameKey && bankNameKey in CONST.BANK_NAMES) {
bankIcon.icon = getBankIconAsset(bankNameKey, isCard);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/BankIcons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function getBankIcon({styles, bankName, isCard = false}: BankIcon
if (bankName) {
const bankNameKey = getBankNameKey(bankName.toLowerCase());

if (bankNameKey && Object.keys(CONST.BANK_NAMES).includes(bankNameKey)) {
if (bankNameKey && bankNameKey in CONST.BANK_NAMES) {
bankIcon.icon = (getBankIconAsset(bankNameKey, isCard) as BankIconAsset).default;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ function MoneyRequestConfirmationList({
const policyRates = DistanceRequestUtils.getMileageRates(policy);

// If the selected rate belongs to the policy, clear the error
if (customUnitRateID && Object.keys(policyRates).includes(customUnitRateID)) {
if (customUnitRateID && customUnitRateID in policyRates) {
clearFormErrors([errorKey]);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/OptionListContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
}

Object.values(reports ?? {})
.filter((report) => !!Object.keys(report?.participants ?? {}).includes(accountID) || (isSelfDM(report) && report?.ownerAccountID === Number(accountID)))
.filter((report) => accountID in (report?.participants ?? {}) || (isSelfDM(report) && report?.ownerAccountID === Number(accountID)))
.forEach((report) => {
if (!report) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
return;
}
transactionGroup.transactions.forEach((transaction) => {
if (!Object.keys(selectedTransactions).includes(transaction.transactionID) && !areAllMatchingItemsSelected) {
if (!(transaction.transactionID in selectedTransactions) && !areAllMatchingItemsSelected) {
return;
}
newTransactionList[transaction.transactionID] = {
Expand Down Expand Up @@ -464,7 +464,7 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
if (!Object.hasOwn(transaction, 'transactionID') || !('transactionID' in transaction)) {
return;
}
if (!Object.keys(selectedTransactions).includes(transaction.transactionID) && !areAllMatchingItemsSelected) {
if (!(transaction.transactionID in selectedTransactions) && !areAllMatchingItemsSelected) {
return;
}
newTransactionList[transaction.transactionID] = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/StateSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function StateSelector(
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [stateFromUrl, onBlur, isFocused]);

const title = stateCode && Object.keys(COMMON_CONST.STATES).includes(stateCode) ? translate(`allStates.${stateCode}.stateName`) : '';
const title = stateCode && stateCode in COMMON_CONST.STATES ? translate(`allStates.${stateCode}.stateName`) : '';
const descStyle = title.length === 0 ? styles.textNormal : null;

return (
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useAdvancedSearchFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function useAdvancedSearchFilters() {

let currentType = searchAdvancedFilters?.type ?? CONST.SEARCH.DATA_TYPES.EXPENSE;

if (!Object.keys(typeFiltersKeys).includes(currentType)) {
if (!(currentType in typeFiltersKeys)) {
currentType = CONST.SEARCH.DATA_TYPES.EXPENSE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/CardFeedUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function filterOutDomainCards(workspaceCardFeeds: Record<string, WorkspaceCardsL
const domainFeedData = getDomainFeedData(workspaceCardFeeds);
return Object.entries(workspaceCardFeeds ?? {}).filter(([, workspaceFeed]) => {
const domainFeed = Object.values(workspaceFeed ?? {}).at(0) ?? {};
if (Object.keys(domainFeedData).includes(`${domainFeed.fundID}_${domainFeed.bank}`)) {
if (`${domainFeed.fundID}_${domainFeed.bank}` in domainFeedData) {
return false;
}
return !isEmptyObject(workspaceFeed);
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@
},
},
{
onyxMethod: Onyx.METHOD.MERGE,

Check failure on line 1483 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`translateLocal` is deprecated. This function uses imperative Onyx data access patterns, similar to `Onyx.connect`. Use `useLocalize` hook instead for reactive data access in React components
key: `${ONYXKEYS.COLLECTION.REPORT}${testDriveIOUParams.iouOptimisticParams.report.reportID}`,
value: {
...{lastActionType: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED},
Expand Down Expand Up @@ -4241,7 +4241,7 @@
? getUpdatedTransaction({
transaction,
transactionChanges,
isFromExpenseReport,

Check failure on line 4244 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`translateLocal` is deprecated. This function uses imperative Onyx data access patterns, similar to `Onyx.connect`. Use `useLocalize` hook instead for reactive data access in React components
policy,
})
: undefined;
Expand All @@ -4253,7 +4253,7 @@
transactionDetails.waypoints = JSON.stringify(transactionDetails.waypoints);
}

const dataToIncludeInParams: Partial<TransactionDetails> = Object.fromEntries(Object.entries(transactionDetails ?? {}).filter(([key]) => Object.keys(transactionChanges).includes(key)));
const dataToIncludeInParams: Partial<TransactionDetails> = Object.fromEntries(Object.entries(transactionDetails ?? {}).filter(([key]) => key in transactionChanges));

const apiParams: UpdateMoneyRequestParams = {
...dataToIncludeInParams,
Expand Down Expand Up @@ -4703,7 +4703,7 @@
isFromExpenseReport: false,
policy,
})
: null;

Check failure on line 4706 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`translateLocal` is deprecated. This function uses imperative Onyx data access patterns, similar to `Onyx.connect`. Use `useLocalize` hook instead for reactive data access in React components
const transactionDetails = getTransactionDetails(updatedTransaction);

if (transactionDetails?.waypoints) {
Expand All @@ -4711,7 +4711,7 @@
transactionDetails.waypoints = JSON.stringify(transactionDetails.waypoints);
}

const dataToIncludeInParams: Partial<TransactionDetails> = Object.fromEntries(Object.entries(transactionDetails ?? {}).filter(([key]) => Object.keys(transactionChanges).includes(key)));
const dataToIncludeInParams: Partial<TransactionDetails> = Object.fromEntries(Object.entries(transactionDetails ?? {}).filter(([key]) => key in transactionChanges));

const apiParams: UpdateMoneyRequestParams = {
...dataToIncludeInParams,
Expand Down Expand Up @@ -6628,7 +6628,7 @@

// Important data is set on the draft distance transaction, such as the iouRequestType marking it as a distance request, so merge it into the optimistic split transaction
if (isDistanceRequest) {
splitTransaction = fastMerge(existingTransaction, splitTransaction, false);

Check failure on line 6631 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`translateLocal` is deprecated. This function uses imperative Onyx data access patterns, similar to `Onyx.connect`. Use `useLocalize` hook instead for reactive data access in React components
}

// Note: The created action must be optimistically generated before the IOU action so there's no chance that the created action appears after the IOU action in the chat
Expand Down Expand Up @@ -6912,7 +6912,7 @@
oneOnOneTransaction = fastMerge(existingTransaction, oneOnOneTransaction, false);
}

// STEP 4: Build optimistic reportActions. We need:

Check failure on line 6915 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`translateLocal` is deprecated. This function uses imperative Onyx data access patterns, similar to `Onyx.connect`. Use `useLocalize` hook instead for reactive data access in React components
// 1. CREATED action for the chatReport
// 2. CREATED action for the iouReport
// 3. IOU action for the iouReport
Expand Down Expand Up @@ -8306,7 +8306,7 @@
message.html = messageText;
message.deleted = shouldDeleteIOUReport ? DateUtils.getDBTime() : '';
}
} else if (!Array.isArray(updatedReportPreviewAction.message) && updatedReportPreviewAction.message) {

Check failure on line 8309 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`translateLocal` is deprecated. This function uses imperative Onyx data access patterns, similar to `Onyx.connect`. Use `useLocalize` hook instead for reactive data access in React components
updatedReportPreviewAction.message.text = messageText;
updatedReportPreviewAction.message.deleted = shouldDeleteIOUReport ? DateUtils.getDBTime() : '';
}
Expand Down Expand Up @@ -8817,7 +8817,7 @@
errors: {
[errorKey]: Localize.translateLocal('iou.error.genericDeleteFailureMessage'),
},
},

Check failure on line 8820 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`translateLocal` is deprecated. This function uses imperative Onyx data access patterns, similar to `Onyx.connect`. Use `useLocalize` hook instead for reactive data access in React components
},
});
}
Expand All @@ -8844,7 +8844,7 @@
transactionID,
reportActionID: reportAction.reportActionID,
};

Check failure on line 8847 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`translateLocal` is deprecated. This function uses imperative Onyx data access patterns, similar to `Onyx.connect`. Use `useLocalize` hook instead for reactive data access in React components
// STEP 3: Make the API request
API.write(WRITE_COMMANDS.DELETE_MONEY_REQUEST, parameters, {optimisticData, successData, failureData});
clearPdfByOnyxKey(transactionID);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Wallet/ReportCardLostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function ReportCardLostPage({
useBeforeRemove(() => setIsValidateCodeActionModalVisible(false));

useEffect(() => {
const newID = Object.keys(cardList ?? {}).find((cardKey) => cardList?.[cardKey]?.cardID && !Object.keys(previousCardList ?? {}).includes(cardKey));
const newID = Object.keys(cardList ?? {}).find((cardKey) => cardList?.[cardKey]?.cardID && !(cardKey in (previousCardList ?? {})));
if (!newID || physicalCard?.cardID) {
return;
}
Expand Down
Loading