From fba235a726637e810ae3a68b4cc79076eaba27dc Mon Sep 17 00:00:00 2001 From: TaduJR Date: Mon, 20 Oct 2025 11:59:54 +0300 Subject: [PATCH 1/4] fix: Create no object keys includes lint rule --- eslint.config.js | 1 + src/components/Form/FormWrapper.tsx | 2 +- src/components/Icon/BankIcons/index.native.ts | 2 +- src/components/Icon/BankIcons/index.ts | 2 +- src/components/MoneyRequestConfirmationList.tsx | 2 +- src/components/OptionListContextProvider.tsx | 2 +- src/components/Search/index.tsx | 4 ++-- src/components/StateSelector.tsx | 2 +- src/hooks/useAdvancedSearchFilters.ts | 2 +- src/libs/CardFeedUtils.ts | 2 +- src/libs/actions/IOU.ts | 4 ++-- src/pages/settings/Wallet/ReportCardLostPage.tsx | 2 +- 12 files changed, 14 insertions(+), 13 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 456b3cbd5908..c21a69359b5d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -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', }, }, diff --git a/src/components/Form/FormWrapper.tsx b/src/components/Form/FormWrapper.tsx index 1a98662db569..52112033c70d 100644 --- a/src/components/Form/FormWrapper.tsx +++ b/src/components/Form/FormWrapper.tsx @@ -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; diff --git a/src/components/Icon/BankIcons/index.native.ts b/src/components/Icon/BankIcons/index.native.ts index aaf8456b2771..38c23d578404 100644 --- a/src/components/Icon/BankIcons/index.native.ts +++ b/src/components/Icon/BankIcons/index.native.ts @@ -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); } } diff --git a/src/components/Icon/BankIcons/index.ts b/src/components/Icon/BankIcons/index.ts index 7fdc3ed2b95a..4589f1f145e5 100644 --- a/src/components/Icon/BankIcons/index.ts +++ b/src/components/Icon/BankIcons/index.ts @@ -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; } } diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 526464b893d4..1ddb9a383660 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -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; } diff --git a/src/components/OptionListContextProvider.tsx b/src/components/OptionListContextProvider.tsx index cbfff5416bc3..f7d638d074bd 100644 --- a/src/components/OptionListContextProvider.tsx +++ b/src/components/OptionListContextProvider.tsx @@ -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; diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 9079f8fa0cd4..153e14cafccc 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -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] = { @@ -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] = { diff --git a/src/components/StateSelector.tsx b/src/components/StateSelector.tsx index e2be9281d0bb..85ab6396e1ba 100644 --- a/src/components/StateSelector.tsx +++ b/src/components/StateSelector.tsx @@ -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 ( diff --git a/src/hooks/useAdvancedSearchFilters.ts b/src/hooks/useAdvancedSearchFilters.ts index d4bcd759768d..c0434cda2453 100644 --- a/src/hooks/useAdvancedSearchFilters.ts +++ b/src/hooks/useAdvancedSearchFilters.ts @@ -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; } diff --git a/src/libs/CardFeedUtils.ts b/src/libs/CardFeedUtils.ts index 0e8d24b59175..9d73ff28b11a 100644 --- a/src/libs/CardFeedUtils.ts +++ b/src/libs/CardFeedUtils.ts @@ -227,7 +227,7 @@ function filterOutDomainCards(workspaceCardFeeds: Record { 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); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 0e755df46844..7d7f81a3ba3d 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4253,7 +4253,7 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U transactionDetails.waypoints = JSON.stringify(transactionDetails.waypoints); } - const dataToIncludeInParams: Partial = Object.fromEntries(Object.entries(transactionDetails ?? {}).filter(([key]) => Object.keys(transactionChanges).includes(key))); + const dataToIncludeInParams: Partial = Object.fromEntries(Object.entries(transactionDetails ?? {}).filter(([key]) => key in transactionChanges)); const apiParams: UpdateMoneyRequestParams = { ...dataToIncludeInParams, @@ -4711,7 +4711,7 @@ function getUpdateTrackExpenseParams( transactionDetails.waypoints = JSON.stringify(transactionDetails.waypoints); } - const dataToIncludeInParams: Partial = Object.fromEntries(Object.entries(transactionDetails ?? {}).filter(([key]) => Object.keys(transactionChanges).includes(key))); + const dataToIncludeInParams: Partial = Object.fromEntries(Object.entries(transactionDetails ?? {}).filter(([key]) => key in transactionChanges)); const apiParams: UpdateMoneyRequestParams = { ...dataToIncludeInParams, diff --git a/src/pages/settings/Wallet/ReportCardLostPage.tsx b/src/pages/settings/Wallet/ReportCardLostPage.tsx index 67d7809096b7..1217a1f965d9 100644 --- a/src/pages/settings/Wallet/ReportCardLostPage.tsx +++ b/src/pages/settings/Wallet/ReportCardLostPage.tsx @@ -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; } From 5377da058156fe4150039efc50470ea149c74188 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Mon, 20 Oct 2025 12:36:22 +0300 Subject: [PATCH 2/4] sync --- src/components/OptionListContextProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/OptionListContextProvider.tsx b/src/components/OptionListContextProvider.tsx index f7d638d074bd..32838211868f 100644 --- a/src/components/OptionListContextProvider.tsx +++ b/src/components/OptionListContextProvider.tsx @@ -205,7 +205,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { } Object.values(reports ?? {}) - .filter((report) => !!(accountID in report?.participants ?? {}) ?? (isSelfDM(report) && report?.ownerAccountID === Number(accountID))) + .filter((report) => (accountID in (report?.participants ?? {})) || (isSelfDM(report) && report?.ownerAccountID === Number(accountID))) .forEach((report) => { if (!report) { return; From 489c06c1ec36df5d7e04065ed6256c6314de3641 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Tue, 21 Oct 2025 11:21:59 +0300 Subject: [PATCH 3/4] sync --- src/components/Icon/BankIcons/index.native.ts | 2 +- src/components/Icon/BankIcons/index.ts | 2 +- src/components/MoneyRequestConfirmationList.tsx | 2 +- src/components/OptionListContextProvider.tsx | 2 +- src/components/StateSelector.tsx | 2 +- src/pages/settings/Wallet/ReportCardLostPage.tsx | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/Icon/BankIcons/index.native.ts b/src/components/Icon/BankIcons/index.native.ts index 38c23d578404..5ad3b0220186 100644 --- a/src/components/Icon/BankIcons/index.native.ts +++ b/src/components/Icon/BankIcons/index.native.ts @@ -16,7 +16,7 @@ export default function getBankIcon({styles, bankName, isCard = false}: BankIcon if (bankName) { const bankNameKey = getBankNameKey(bankName.toLowerCase()); - if (bankNameKey && (bankNameKey in CONST.BANK_NAMES)) { + if (bankNameKey && bankNameKey in CONST.BANK_NAMES) { bankIcon.icon = getBankIconAsset(bankNameKey, isCard); } } diff --git a/src/components/Icon/BankIcons/index.ts b/src/components/Icon/BankIcons/index.ts index 4589f1f145e5..9e06b7696bfa 100644 --- a/src/components/Icon/BankIcons/index.ts +++ b/src/components/Icon/BankIcons/index.ts @@ -24,7 +24,7 @@ export default function getBankIcon({styles, bankName, isCard = false}: BankIcon if (bankName) { const bankNameKey = getBankNameKey(bankName.toLowerCase()); - if (bankNameKey && (bankNameKey in CONST.BANK_NAMES)) { + if (bankNameKey && bankNameKey in CONST.BANK_NAMES) { bankIcon.icon = (getBankIconAsset(bankNameKey, isCard) as BankIconAsset).default; } } diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 1ddb9a383660..8928b0efb739 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -438,7 +438,7 @@ function MoneyRequestConfirmationList({ const policyRates = DistanceRequestUtils.getMileageRates(policy); // If the selected rate belongs to the policy, clear the error - if (customUnitRateID && (customUnitRateID in policyRates)) { + if (customUnitRateID && customUnitRateID in policyRates) { clearFormErrors([errorKey]); return; } diff --git a/src/components/OptionListContextProvider.tsx b/src/components/OptionListContextProvider.tsx index 32838211868f..0b42aabfffc0 100644 --- a/src/components/OptionListContextProvider.tsx +++ b/src/components/OptionListContextProvider.tsx @@ -205,7 +205,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { } Object.values(reports ?? {}) - .filter((report) => (accountID in (report?.participants ?? {})) || (isSelfDM(report) && report?.ownerAccountID === Number(accountID))) + .filter((report) => accountID in (report?.participants ?? {}) || (isSelfDM(report) && report?.ownerAccountID === Number(accountID))) .forEach((report) => { if (!report) { return; diff --git a/src/components/StateSelector.tsx b/src/components/StateSelector.tsx index 85ab6396e1ba..4b12dbf7c6b7 100644 --- a/src/components/StateSelector.tsx +++ b/src/components/StateSelector.tsx @@ -74,7 +74,7 @@ function StateSelector( // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, [stateFromUrl, onBlur, isFocused]); - const title = stateCode && (stateCode in COMMON_CONST.STATES) ? 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 ( diff --git a/src/pages/settings/Wallet/ReportCardLostPage.tsx b/src/pages/settings/Wallet/ReportCardLostPage.tsx index 1217a1f965d9..a1327cf6c16e 100644 --- a/src/pages/settings/Wallet/ReportCardLostPage.tsx +++ b/src/pages/settings/Wallet/ReportCardLostPage.tsx @@ -87,7 +87,7 @@ function ReportCardLostPage({ useBeforeRemove(() => setIsValidateCodeActionModalVisible(false)); useEffect(() => { - const newID = Object.keys(cardList ?? {}).find((cardKey) => cardList?.[cardKey]?.cardID && !(cardKey in previousCardList ?? {})); + const newID = Object.keys(cardList ?? {}).find((cardKey) => cardList?.[cardKey]?.cardID && !(cardKey in (previousCardList ?? {}))); if (!newID || physicalCard?.cardID) { return; } From eb9d724fe3d772be9ad209f646485514afbd98b2 Mon Sep 17 00:00:00 2001 From: TaduJR Date: Tue, 21 Oct 2025 12:18:22 +0300 Subject: [PATCH 4/4] Trigger workflow