From ab40264dff9a6c21372617c8744b1013c22dd2d2 Mon Sep 17 00:00:00 2001
From: Rayane Djouah <77965000+rayane-djouah@users.noreply.github.com>
Date: Wed, 30 Oct 2024 15:56:45 +0100
Subject: [PATCH] Add boolean-conditional-rendering rule
---
.eslintrc.js | 1 +
src/components/AccountSwitcher.tsx | 4 ++--
.../AttachmentCarousel/CarouselItem.tsx | 2 +-
.../AttachmentView/DefaultAttachmentView/index.tsx | 2 +-
src/components/AvatarWithDisplayName.tsx | 2 +-
src/components/AvatarWithImagePicker.tsx | 2 +-
src/components/Badge.tsx | 2 +-
src/components/Banner.tsx | 2 +-
src/components/BlockingViews/BlockingView.tsx | 6 +++---
src/components/Button/index.tsx | 2 +-
src/components/ButtonWithDropdownMenu/index.tsx | 2 +-
src/components/CheckboxWithLabel.tsx | 4 ++--
src/components/CollapsibleSection/index.tsx | 2 +-
src/components/ConfirmContent.tsx | 2 +-
src/components/ConnectionLayout.tsx | 2 +-
src/components/DecisionModal.tsx | 2 +-
src/components/EReceiptThumbnail.tsx | 2 +-
src/components/FeatureList.tsx | 2 +-
src/components/HeaderWithBackButton/index.tsx | 4 ++--
src/components/InteractiveStepWrapper.tsx | 2 +-
src/components/LHNOptionsList/OptionRowLHN.tsx | 4 ++--
src/components/MagicCodeInput.tsx | 2 +-
src/components/MapView/Direction.website.tsx | 2 +-
src/components/MapView/MapView.tsx | 2 +-
src/components/MapView/MapViewImpl.website.tsx | 2 +-
src/components/MentionSuggestions.tsx | 2 +-
src/components/MenuItem.tsx | 14 +++++++-------
src/components/MoneyReportHeader.tsx | 8 ++++----
src/components/MoneyRequestConfirmationList.tsx | 2 +-
src/components/MoneyRequestHeader.tsx | 2 +-
src/components/OptionsList/BaseOptionsList.tsx | 2 +-
src/components/Picker/BasePicker.tsx | 2 +-
.../Pressable/PressableWithDelayToggle.tsx | 2 +-
.../ReportActionItem/MoneyRequestView.tsx | 8 ++++----
src/components/ReportActionItem/ReportPreview.tsx | 4 ++--
.../ReportActionItem/TripDetailsView.tsx | 4 ++--
src/components/Search/SearchPageHeader.tsx | 2 +-
.../Search/SearchRouter/SearchRouterInput.tsx | 2 +-
src/components/SelectionList/BaseListItem.tsx | 4 ++--
src/components/SelectionList/CardListItem.tsx | 4 ++--
.../SelectionList/InviteMemberListItem.tsx | 2 +-
.../Search/ExpenseItemHeaderNarrow.tsx | 6 +++---
.../SelectionList/Search/ReportListItem.tsx | 2 +-
.../SelectionList/Search/SearchQueryListItem.tsx | 4 ++--
.../Search/TransactionListItemRow.tsx | 4 ++--
.../SelectionList/SelectableListItem.tsx | 2 +-
src/components/SelectionList/TableListItem.tsx | 4 ++--
src/components/SelectionList/UserListItem.tsx | 4 ++--
src/components/SubStepForms/AddressStep.tsx | 4 ++--
src/components/SubStepForms/ConfirmationStep.tsx | 2 +-
src/components/SubStepForms/SingleFieldStep.tsx | 2 +-
src/components/SubscriptAvatar.tsx | 4 ++--
src/components/TabSelector/TabIcon.tsx | 2 +-
.../TextInput/BaseTextInput/index.native.tsx | 10 +++++-----
src/components/TextInput/BaseTextInput/index.tsx | 6 +++---
src/components/ThumbnailImage.tsx | 2 +-
.../ValidateCodeForm/BaseValidateCodeForm.tsx | 2 +-
.../VideoPlayerPreview/VideoPlayerThumbnail.tsx | 2 +-
.../BottomTabBar.tsx | 4 ++--
.../DebugTabView.tsx | 2 +-
.../BottomTabBar.tsx | 2 +-
.../createCustomStackNavigator/index.tsx | 2 +-
.../index.native.tsx | 2 +-
.../index.tsx | 2 +-
src/pages/Debug/Report/DebugReportPage.tsx | 4 ++--
.../AddBankAccount/substeps/ConfirmationStep.tsx | 2 +-
src/pages/ProfilePage.tsx | 6 +++---
.../substeps/CompanyOwnersListUBO.tsx | 2 +-
.../ContinueBankAccountSetup.tsx | 2 +-
src/pages/ReportDetailsPage.tsx | 2 +-
src/pages/Search/AdvancedSearchFilters.tsx | 2 +-
src/pages/Search/EmptySearchView.tsx | 2 +-
src/pages/Search/SearchPage.tsx | 2 +-
src/pages/Search/SearchSelectionModeHeader.tsx | 2 +-
src/pages/Search/SearchTypeMenu.tsx | 2 +-
src/pages/ValidateLoginPage/index.website.tsx | 4 ++--
src/pages/home/ReportScreen.tsx | 4 ++--
src/pages/home/report/LinkPreviewer.tsx | 10 +++++-----
src/pages/home/report/ReportActionItemSingle.tsx | 2 +-
src/pages/home/report/ReportFooter.tsx | 4 ++--
.../home/report/comment/TextCommentFragment.tsx | 2 +-
src/pages/home/sidebar/SidebarLinks.tsx | 2 +-
.../request/step/IOURequestStepConfirmation.tsx | 2 +-
.../request/step/IOURequestStepParticipants.tsx | 2 +-
.../step/IOURequestStepScan/index.native.tsx | 4 ++--
.../iou/request/step/IOURequestStepScan/index.tsx | 2 +-
src/pages/iou/request/step/IOURequestStepTag.tsx | 2 +-
.../settings/Security/SecuritySettingsPage.tsx | 2 +-
.../Security/TwoFactorAuth/Steps/CodesStep.tsx | 2 +-
.../Subscription/CardSection/CardSection.tsx | 2 +-
.../Subscription/SubscriptionDetails/index.tsx | 2 +-
src/pages/settings/Wallet/ExpensifyCardPage.tsx | 2 +-
src/pages/signin/SignUpWelcomeForm.tsx | 2 +-
src/pages/tasks/NewTaskPage.tsx | 2 +-
src/pages/workspace/WorkspaceProfilePage.tsx | 4 ++--
src/pages/workspace/WorkspacesListRow.tsx | 2 +-
.../workspace/accounting/AccountingContext.tsx | 2 +-
.../workspace/accounting/PolicyAccountingPage.tsx | 2 +-
.../import/NetSuiteImportCustomFieldEdit.tsx | 4 ++--
.../import/NetSuiteImportCustomFieldView.tsx | 2 +-
.../reconciliation/CardReconciliationPage.tsx | 2 +-
.../xero/XeroTrackingCategoryConfigurationPage.tsx | 2 +-
.../accounting/xero/advanced/XeroAdvancedPage.tsx | 2 +-
.../workspace/categories/CategorySettingsPage.tsx | 8 ++++----
.../categories/WorkspaceCategoriesSettingsPage.tsx | 4 ++--
.../WorkspaceCompanyCardAccountSelectCardPage.tsx | 4 ++--
.../WorkspaceCompanyCardDetailsPage.tsx | 2 +-
.../addNew/BankConnection/index.native.tsx | 2 +-
.../PolicyDistanceRatesSettingsPage.tsx | 4 ++--
.../expensifyCard/WorkspaceExpensifyCardPage.tsx | 2 +-
.../WorkspaceSettlementAccountPage.tsx | 4 ++--
.../workspace/invoices/WorkspaceInvoicesPage.tsx | 6 +++---
.../members/WorkspaceOwnerChangeWrapperPage.tsx | 2 +-
src/pages/workspace/tags/TagSettingsPage.tsx | 2 +-
.../workspace/tags/WorkspaceTagsSettingsPage.tsx | 2 +-
src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx | 2 +-
.../workflows/approvals/ApprovalWorkflowEditor.tsx | 2 +-
.../WorkspaceWorkflowsApprovalsCreatePage.tsx | 2 +-
.../WorkspaceWorkflowsApprovalsEditPage.tsx | 2 +-
119 files changed, 178 insertions(+), 177 deletions(-)
diff --git a/.eslintrc.js b/.eslintrc.js
index cfbfdcc8fe91..fefad92ce29d 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -294,6 +294,7 @@ module.exports = {
files: ['*.ts', '*.tsx'],
rules: {
'rulesdir/prefer-at': 'error',
+ 'rulesdir/boolean-conditional-rendering': 'error',
},
},
],
diff --git a/src/components/AccountSwitcher.tsx b/src/components/AccountSwitcher.tsx
index 8ccab44a2cb9..ad58294c0cc8 100644
--- a/src/components/AccountSwitcher.tsx
+++ b/src/components/AccountSwitcher.tsx
@@ -152,7 +152,7 @@ function AccountSwitcher() {
>
{currentUserPersonalDetails?.displayName}
- {canSwitchAccounts && (
+ {!!canSwitchAccounts && (
- {canSwitchAccounts && (
+ {!!canSwitchAccounts && (
{
diff --git a/src/components/Attachments/AttachmentCarousel/CarouselItem.tsx b/src/components/Attachments/AttachmentCarousel/CarouselItem.tsx
index 103abb2df1bb..4de43a763231 100644
--- a/src/components/Attachments/AttachmentCarousel/CarouselItem.tsx
+++ b/src/components/Attachments/AttachmentCarousel/CarouselItem.tsx
@@ -86,7 +86,7 @@ function CarouselItem({item, onPress, isFocused, isModalHovered}: CarouselItemPr
/>
- {item.hasBeenFlagged && (
+ {!!item.hasBeenFlagged && (
{({safeAreaPaddingBottomStyle}) => {renderButton([styles.m4, styles.alignSelfCenter])}}
diff --git a/src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx b/src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx
index 23e13833df64..8f149182d9a6 100644
--- a/src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx
+++ b/src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx
@@ -47,7 +47,7 @@ function DefaultAttachmentView({fileName = '', shouldShowLoadingSpinnerIcon = fa
{fileName}
- {!shouldShowLoadingSpinnerIcon && shouldShowDownloadIcon && (
+ {!shouldShowLoadingSpinnerIcon && !!shouldShowDownloadIcon && (
- {report && !!title && (
+ {!!report && !!title && (
- {errorData.validationError && (
+ {!!errorData.validationError && (
- {icon && (
+ {!!icon && (
- {shouldShowIcon && icon && (
+ {shouldShowIcon && !!icon && (
(
<>
- {subtitle && (
+ {!!subtitle && (
- {animation && (
+ {!!animation && (
)}
- {icon && (
+ {!!icon && (
- {icon && (
+ {!!icon && (
({
enterKeyEventListenerPriority={enterKeyEventListenerPriority}
/>
)}
- {(shouldAlwaysShowDropdownMenu || options.length > 1) && popoverAnchorPosition && (
+ {(shouldAlwaysShowDropdownMenu || options.length > 1) && !!popoverAnchorPosition && (
{
diff --git a/src/components/CheckboxWithLabel.tsx b/src/components/CheckboxWithLabel.tsx
index db62aa9e1441..0647b495bd33 100644
--- a/src/components/CheckboxWithLabel.tsx
+++ b/src/components/CheckboxWithLabel.tsx
@@ -95,8 +95,8 @@ function CheckboxWithLabel(
style={[styles.flexRow, styles.alignItemsCenter, styles.noSelect, styles.w100]}
wrapperStyle={[styles.ml3, styles.pr2, styles.w100, styles.flexWrap, styles.flexShrink1]}
>
- {label && {label}}
- {LabelComponent && }
+ {!!label && {label}}
+ {!!LabelComponent && }
diff --git a/src/components/CollapsibleSection/index.tsx b/src/components/CollapsibleSection/index.tsx
index d339f005e3d3..3776dfa2cf9b 100644
--- a/src/components/CollapsibleSection/index.tsx
+++ b/src/components/CollapsibleSection/index.tsx
@@ -63,7 +63,7 @@ function CollapsibleSection({title, children, titleStyle, textStyle, wrapperStyl
src={src}
/>
- {shouldShowSectionBorder && }
+ {!!shouldShowSectionBorder && }
{children}
diff --git a/src/components/ConfirmContent.tsx b/src/components/ConfirmContent.tsx
index bda78b9b320d..cb0fc6e8e8cb 100644
--- a/src/components/ConfirmContent.tsx
+++ b/src/components/ConfirmContent.tsx
@@ -168,7 +168,7 @@ function ConfirmContent({
)}
- {iconSource && (
+ {!!iconSource && (
- {title && {titleAlreadyTranslated ?? translate(title)}}
+ {!!title && {titleAlreadyTranslated ?? translate(title)}}
{children}
>
);
diff --git a/src/components/DecisionModal.tsx b/src/components/DecisionModal.tsx
index a9bd0b204d79..927ba1ecab11 100644
--- a/src/components/DecisionModal.tsx
+++ b/src/components/DecisionModal.tsx
@@ -55,7 +55,7 @@ function DecisionModal({title, prompt = '', firstOptionText, secondOptionText, o
{prompt}
- {firstOptionText && (
+ {!!firstOptionText && (
- {isReceiptThumbnail && fileExtension && (
+ {isReceiptThumbnail && !!fileExtension && (
)}
- {ctaErrorMessage && (
+ {!!ctaErrorMessage && (
)}
- {icon && (
+ {!!icon && (
)}
- {policyAvatar && (
+ {!!policyAvatar && (
- {stepNames && (
+ {!!stepNames && (
{}, opti
/>
)}
- {hasDraftComment && optionItem.isAllowedToComment && (
+ {hasDraftComment && !!optionItem.isAllowedToComment && (
{}, opti
/>
)}
- {!shouldShowGreenDotIndicator && !hasBrickError && optionItem.isPinned && (
+ {!shouldShowGreenDotIndicator && !hasBrickError && !!optionItem.isPinned && (
))}
- {errorText && (
+ {!!errorText && (
- {coordinates && (
+ {!!coordinates && (
)}
- {otherIntegrationsItems && (
+ {!!otherIntegrationsItems && (
- customField && (
+ !!customField && (
- customField && (
+ !!customField && (
{
updateRecord({
diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldView.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldView.tsx
index d4c831d6155e..cb6513e785c1 100644
--- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldView.tsx
+++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldView.tsx
@@ -96,7 +96,7 @@ function NetSuiteImportCustomFieldView({
shouldBeBlocked={!customField}
onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOM_FIELD_MAPPING.getRoute(policyID, importCustomField))}
>
- {customField && (
+ {!!customField && (
)}
- {!!paymentBankAccountID && isContinuousReconciliationOn && (
+ {!!paymentBankAccountID && !!isContinuousReconciliationOn && (
Policy.clearXeroErrorField(policyID, CONST.XERO_CONFIG.IMPORT_TRACKING_CATEGORIES)}
/>
- {xeroConfig?.importTrackingCategories && (
+ {!!xeroConfig?.importTrackingCategories && (
{menuItems.map((menuItem) => (
Policy.clearXeroErrorField(policyID, CONST.XERO_CONFIG.SYNC_REIMBURSED_REPORTS)}
/>
- {sync?.syncReimbursedReports && (
+ {!!sync?.syncReimbursedReports && (
<>
- {policy?.areRulesEnabled && (
+ {!!policy?.areRulesEnabled && (
<>
{translate('workspace.rules.categoryRules.title')}
@@ -250,7 +250,7 @@ function CategorySettingsPage({
- {policyCategory?.areCommentsRequired && (
+ {!!policyCategory?.areCommentsRequired && (
)}
- {canUseCategoryAndTagApprovers && (
+ {!!canUseCategoryAndTagApprovers && (
<>
)}
- {policy?.tax?.trackingEnabled && (
+ {!!policy?.tax?.trackingEnabled && (
- {canUseWorkspaceRules && !!currentPolicy && (sections.at(0)?.data?.length ?? 0) > 0 && (
+ {!!canUseWorkspaceRules && !!currentPolicy && (sections.at(0)?.data?.length ?? 0) > 0 && (
@@ -140,7 +140,7 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet
}}
/>
)}
- {canUseWorkspaceRules && categoryID && groupID && (
+ {!!canUseWorkspaceRules && !!categoryID && !!groupID && (
- {exportMenuItem?.description && (
+ {!!exportMenuItem?.description && (
{translate('workspace.moreFeatures.companyCards.integrationExportTitleFirstPart', {integration: exportMenuItem.description})}{' '}
- {exportMenuItem && (
+ {!!exportMenuItem && (
Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_NAME.getRoute(policyID, cardID, bank))}
/>
- {exportMenuItem && (
+ {!!exportMenuItem && (
- {url && (
+ {!!url && (
- {defaultUnit && (
+ {!!defaultUnit && (
)}
- {policy?.areCategoriesEnabled && OptionsListUtils.hasEnabledOptions(policyCategories ?? {}) && (
+ {!!policy?.areCategoriesEnabled && OptionsListUtils.hasEnabledOptions(policyCategories ?? {}) && (
- {isLoading && (
+ {!!isLoading && (
{translate('workspace.expensifyCard.settlementAccountDescription')}
- {isUsedContinuousReconciliation && (
+ {!!isUsedContinuousReconciliation && (
{translate('workspace.expensifyCard.settlementAccountInfoPt1')}{' '}
Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_RECONCILIATION_ACCOUNT_SETTINGS.getRoute(policyID, connectionParam))}>
diff --git a/src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx b/src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx
index 4f14950ec93d..0697ac0750cd 100644
--- a/src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx
+++ b/src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx
@@ -37,9 +37,9 @@ function WorkspaceInvoicesPage({route}: WorkspaceInvoicesPageProps) {
>
{(_hasVBA?: boolean, policyID?: string) => (
- {policyID && }
- {policyID && }
- {policyID && }
+ {!!policyID && }
+ {!!policyID && }
+ {!!policyID && }
)}
diff --git a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx
index 325e1112ab4b..c6a37c668c1a 100644
--- a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx
+++ b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx
@@ -75,7 +75,7 @@ function WorkspaceOwnerChangeWrapperPage({route, policy}: WorkspaceOwnerChangeWr
}}
/>
- {policy?.isLoading && }
+ {!!policy?.isLoading && }
{shouldShowPaymentCardForm && }
{!policy?.isLoading && !shouldShowPaymentCardForm && (
- {policy?.areRulesEnabled && canUseCategoryAndTagApprovers && !isMultiLevelTags && (
+ {!!policy?.areRulesEnabled && !!canUseCategoryAndTagApprovers && !isMultiLevelTags && (
<>
{translate('workspace.tags.tagRules')}
diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx
index 3fadba088648..eb9b89ee5679 100644
--- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx
+++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx
@@ -106,7 +106,7 @@ function WorkspaceTagsSettingsPage({route}: WorkspaceTagsSettingsPageProps) {
/>
- {canUseWorkspaceRules && policy?.areRulesEnabled && (
+ {!!canUseWorkspaceRules && !!policy?.areRulesEnabled && (
{translate('workspace.tags.trackBillable')}
diff --git a/src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx b/src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx
index 0f50ed8fe0b8..f10e0fba84a2 100644
--- a/src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx
+++ b/src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx
@@ -158,7 +158,7 @@ function WorkspaceEditTaxPage({
}}
/>
- {shouldShowDeleteMenuItem && (
+ {!!shouldShowDeleteMenuItem && (
- {removeApprovalWorkflow && !approvalWorkflow.isDefault && (
+ {!!removeApprovalWorkflow && !approvalWorkflow.isDefault && (