diff --git a/.eslintrc.js b/.eslintrc.js index ac4546567833..3c144064eb62 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -46,6 +46,7 @@ module.exports = { touchables: ['PressableWithoutFeedback', 'PressableWithFeedback'], }, ], + curly: 'error', }, }, { diff --git a/src/Expensify.js b/src/Expensify.js index 1086bd32cff9..ca1011e919cc 100644 --- a/src/Expensify.js +++ b/src/Expensify.js @@ -100,7 +100,9 @@ function Expensify(props) { const [hasAttemptedToOpenPublicRoom, setAttemptedToOpenPublicRoom] = useState(false); useEffect(() => { - if (props.isCheckingPublicRoom) return; + if (props.isCheckingPublicRoom) { + return; + } setAttemptedToOpenPublicRoom(true); }, [props.isCheckingPublicRoom]); diff --git a/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js b/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js index b1a844e4172d..adee75cb4fa9 100644 --- a/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js +++ b/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js @@ -41,8 +41,11 @@ function AttachmentCarouselPage({source, isAuthTokenRequired, isActive: initialI // to prevent the image transformer from flashing while still rendering // Instead, we show the fallback image while the image transformer is loading the image useEffect(() => { - if (initialIsActive) setTimeout(() => setIsActive(true), 1); - else setIsActive(false); + if (initialIsActive) { + setTimeout(() => setIsActive(true), 1); + } else { + setIsActive(false); + } }, [initialIsActive]); const [initialActivePageLoad, setInitialActivePageLoad] = useState(isActive); @@ -51,8 +54,11 @@ function AttachmentCarouselPage({source, isAuthTokenRequired, isActive: initialI // We delay hiding the fallback image while image transformer is still rendering useEffect(() => { - if (isImageLoading) setShowFallback(true); - else setTimeout(() => setShowFallback(false), 100); + if (isImageLoading) { + setShowFallback(true); + } else { + setTimeout(() => setShowFallback(false), 100); + } }, [isImageLoading]); return ( @@ -127,7 +133,9 @@ function AttachmentCarouselPage({source, isAuthTokenRequired, isActive: initialI const scaledImageHeight = imageHeight * minImageScale; // Don't update the dimensions if they are already set - if (dimensions?.scaledImageWidth === scaledImageWidth && dimensions?.scaledImageHeight === scaledImageHeight) return; + if (dimensions?.scaledImageWidth === scaledImageWidth && dimensions?.scaledImageHeight === scaledImageHeight) { + return; + } cachedDimensions.set(source, { ...dimensions, diff --git a/src/components/Attachments/AttachmentCarousel/Pager/ImageTransformer.js b/src/components/Attachments/AttachmentCarousel/Pager/ImageTransformer.js index 4475df168df2..b1c2864a05f6 100644 --- a/src/components/Attachments/AttachmentCarousel/Pager/ImageTransformer.js +++ b/src/components/Attachments/AttachmentCarousel/Pager/ImageTransformer.js @@ -306,7 +306,9 @@ function ImageTransformer({imageWidth, imageHeight, imageScaleX, imageScaleY, sc stopAnimation(); }) .onFinalize((evt, success) => { - if (!success || !onTap) return; + if (!success || !onTap) { + return; + } runOnJS(onTap)(); }); @@ -432,7 +434,9 @@ function ImageTransformer({imageWidth, imageHeight, imageScaleX, imageScaleY, sc const pinchGesture = Gesture.Pinch() .onTouchesDown((evt, state) => { // we don't want to activate pinch gesture when we are scrolling pager - if (!isScrolling.value) return; + if (!isScrolling.value) { + return; + } state.fail(); }) diff --git a/src/components/Attachments/AttachmentCarousel/index.js b/src/components/Attachments/AttachmentCarousel/index.js index 5c731a0ccfee..ecdfaf4a3438 100644 --- a/src/components/Attachments/AttachmentCarousel/index.js +++ b/src/components/Attachments/AttachmentCarousel/index.js @@ -54,7 +54,9 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, setDownl setDownloadButtonVisibility(initialPage !== -1); // Update the parent modal's state with the source and name from the mapped attachments - if (!_.isUndefined(attachmentsFromReport[initialPage])) onNavigate(attachmentsFromReport[initialPage]); + if (!_.isUndefined(attachmentsFromReport[initialPage])) { + onNavigate(attachmentsFromReport[initialPage]); + } } // eslint-disable-next-line react-hooks/exhaustive-deps }, [report, reportActions, source]); diff --git a/src/components/Attachments/AttachmentCarousel/index.native.js b/src/components/Attachments/AttachmentCarousel/index.native.js index 95cda7c2f5c9..c4f0fd113c26 100644 --- a/src/components/Attachments/AttachmentCarousel/index.native.js +++ b/src/components/Attachments/AttachmentCarousel/index.native.js @@ -43,7 +43,9 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, onClose, setDownloadButtonVisibility(initialPage !== -1); // Update the parent modal's state with the source and name from the mapped attachments - if (!_.isUndefined(attachmentsFromReport[initialPage])) onNavigate(attachmentsFromReport[initialPage]); + if (!_.isUndefined(attachmentsFromReport[initialPage])) { + onNavigate(attachmentsFromReport[initialPage]); + } } // eslint-disable-next-line react-hooks/exhaustive-deps }, [report, reportActions, source]); @@ -135,7 +137,9 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, onClose, onPageSelected={({nativeEvent: {position: newPage}}) => updatePage(newPage)} onPinchGestureChange={(newIsPinchGestureRunning) => { setIsPinchGestureRunning(newIsPinchGestureRunning); - if (!newIsPinchGestureRunning && !shouldShowArrows) setShouldShowArrows(true); + if (!newIsPinchGestureRunning && !shouldShowArrows) { + setShouldShowArrows(true); + } }} onSwipeDown={onClose} containerWidth={containerDimensions.width} diff --git a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js index 0767b2b68985..fdf151c4d5d0 100644 --- a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js +++ b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js @@ -25,7 +25,9 @@ function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, isUsedInCarouse attachmentCarouselPagerContext.onPinchGestureChange(!shouldPagerScroll); - if (attachmentCarouselPagerContext.shouldPagerScroll.value === shouldPagerScroll) return; + if (attachmentCarouselPagerContext.shouldPagerScroll.value === shouldPagerScroll) { + return; + } attachmentCarouselPagerContext.shouldPagerScroll.value = shouldPagerScroll; } diff --git a/src/components/Composer/index.android.js b/src/components/Composer/index.android.js index d0805cbcc7c3..1132efa9e50e 100644 --- a/src/components/Composer/index.android.js +++ b/src/components/Composer/index.android.js @@ -97,7 +97,9 @@ function Composer({shouldClear, onClear, isDisabled, maxLines, forwardedRef, isC * @return {Number} */ const maxNumberOfLines = useMemo(() => { - if (isComposerFullSize) return 1000000; + if (isComposerFullSize) { + return 1000000; + } return maxLines; }, [isComposerFullSize, maxLines]); diff --git a/src/components/Composer/index.ios.js b/src/components/Composer/index.ios.js index c0a3859e6d01..69b441f9fed1 100644 --- a/src/components/Composer/index.ios.js +++ b/src/components/Composer/index.ios.js @@ -97,7 +97,9 @@ function Composer({shouldClear, onClear, isDisabled, maxLines, forwardedRef, isC * @return {Number} */ const maxNumberOfLines = useMemo(() => { - if (isComposerFullSize) return undefined; + if (isComposerFullSize) { + return undefined; + } return maxLines; }, [isComposerFullSize, maxLines]); diff --git a/src/components/EmojiPicker/EmojiPickerMenu/index.js b/src/components/EmojiPicker/EmojiPickerMenu/index.js index d3268ebc54b0..27fd199a3895 100755 --- a/src/components/EmojiPicker/EmojiPickerMenu/index.js +++ b/src/components/EmojiPicker/EmojiPickerMenu/index.js @@ -104,7 +104,9 @@ class EmojiPickerMenu extends Component { } componentDidUpdate(prevProps) { - if (prevProps.frequentlyUsedEmojis === this.props.frequentlyUsedEmojis) return; + if (prevProps.frequentlyUsedEmojis === this.props.frequentlyUsedEmojis) { + return; + } const {filteredEmojis, headerEmojis, headerRowIndices} = this.getEmojisAndHeaderRowIndices(); this.emojis = filteredEmojis; diff --git a/src/components/ImageView/index.js b/src/components/ImageView/index.js index c92bd7738253..9303f078e823 100644 --- a/src/components/ImageView/index.js +++ b/src/components/ImageView/index.js @@ -87,7 +87,9 @@ function ImageView({isAuthTokenRequired, url, fileName}) { }; const imageLoadingStart = () => { - if (!isLoading) return; + if (!isLoading) { + return; + } setIsLoading(true); setZoomScale(0); setIsZoomed(false); diff --git a/src/components/Pressable/PressableWithFeedback.js b/src/components/Pressable/PressableWithFeedback.js index 7eb0ee7286c9..40be99823ceb 100644 --- a/src/components/Pressable/PressableWithFeedback.js +++ b/src/components/Pressable/PressableWithFeedback.js @@ -58,19 +58,27 @@ const PressableWithFeedback = forwardRef((props, ref) => { isExecuting={isExecuting} onHoverIn={() => { setIsHovered(true); - if (props.onHoverIn) props.onHoverIn(); + if (props.onHoverIn) { + props.onHoverIn(); + } }} onHoverOut={() => { setIsHovered(false); - if (props.onHoverOut) props.onHoverOut(); + if (props.onHoverOut) { + props.onHoverOut(); + } }} onPressIn={() => { setIsPressed(true); - if (props.onPressIn) props.onPressIn(); + if (props.onPressIn) { + props.onPressIn(); + } }} onPressOut={() => { setIsPressed(false); - if (props.onPressOut) props.onPressOut(); + if (props.onPressOut) { + props.onPressOut(); + } }} onPress={(e) => { singleExecution(() => props.onPress(e))(); diff --git a/src/components/QRShare/QRShareWithDownload/index.js b/src/components/QRShare/QRShareWithDownload/index.js index 310122b96d40..665115823357 100644 --- a/src/components/QRShare/QRShareWithDownload/index.js +++ b/src/components/QRShare/QRShareWithDownload/index.js @@ -17,7 +17,9 @@ class QRShareWithDownload extends Component { return new Promise((resolve, reject) => { // eslint-disable-next-line es/no-optional-chaining const svg = this.qrShareRef.current?.getSvg(); - if (svg == null) return reject(); + if (svg == null) { + return reject(); + } svg.toDataURL((dataURL) => resolve(fileDownload(dataURL, getQrCodeFileName(this.props.title)))); }); diff --git a/src/components/SignInButtons/AppleSignIn/index.android.js b/src/components/SignInButtons/AppleSignIn/index.android.js index 83a99683b178..48d2bf3cc861 100644 --- a/src/components/SignInButtons/AppleSignIn/index.android.js +++ b/src/components/SignInButtons/AppleSignIn/index.android.js @@ -39,7 +39,9 @@ function AppleSignIn() { appleSignInRequest() .then((token) => Session.beginAppleSignIn(token)) .catch((e) => { - if (e.message === appleAuthAndroid.Error.SIGNIN_CANCELLED) return null; + if (e.message === appleAuthAndroid.Error.SIGNIN_CANCELLED) { + return null; + } Log.alert('[Apple Sign In] Apple authentication failed', e); }); }; diff --git a/src/components/SignInButtons/AppleSignIn/index.ios.js b/src/components/SignInButtons/AppleSignIn/index.ios.js index 681eebb298c5..0c9a8c9e8211 100644 --- a/src/components/SignInButtons/AppleSignIn/index.ios.js +++ b/src/components/SignInButtons/AppleSignIn/index.ios.js @@ -37,7 +37,9 @@ function AppleSignIn() { appleSignInRequest() .then((token) => Session.beginAppleSignIn(token)) .catch((e) => { - if (e.code === appleAuth.Error.CANCELED) return null; + if (e.code === appleAuth.Error.CANCELED) { + return null; + } Log.alert('[Apple Sign In] Apple authentication failed', e); }); }; diff --git a/src/components/SignInButtons/AppleSignIn/index.website.js b/src/components/SignInButtons/AppleSignIn/index.website.js index 41c8f2afd4d5..7046de5068b1 100644 --- a/src/components/SignInButtons/AppleSignIn/index.website.js +++ b/src/components/SignInButtons/AppleSignIn/index.website.js @@ -55,7 +55,9 @@ const successListener = (event) => { }; const failureListener = (event) => { - if (!event.detail || event.detail.error === 'popup_closed_by_user') return null; + if (!event.detail || event.detail.error === 'popup_closed_by_user') { + return null; + } Log.warn(`Apple sign-in failed: ${event.detail}`); }; @@ -126,7 +128,9 @@ const SingletonAppleSignInButtonWithFocus = withNavigationFocus(SingletonAppleSi function AppleSignIn({isDesktopFlow}) { const [scriptLoaded, setScriptLoaded] = useState(false); useEffect(() => { - if (window.appleAuthScriptLoaded) return; + if (window.appleAuthScriptLoaded) { + return; + } const localeCode = getUserLanguage(); const script = document.createElement('script'); diff --git a/src/components/TextInput/index.js b/src/components/TextInput/index.js index 48a92f081200..6cefe04e71a1 100644 --- a/src/components/TextInput/index.js +++ b/src/components/TextInput/index.js @@ -30,7 +30,9 @@ function TextInput(props) { }); return () => { - if (!removeVisibilityListenerRef.current) return; + if (!removeVisibilityListenerRef.current) { + return; + } removeVisibilityListenerRef.current(); }; // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/libs/BootSplash/index.js b/src/libs/BootSplash/index.js index ff7ab5562b1f..c169f380a8eb 100644 --- a/src/libs/BootSplash/index.js +++ b/src/libs/BootSplash/index.js @@ -9,10 +9,14 @@ function hide() { return document.fonts.ready.then(() => { const splash = document.getElementById('splash'); - if (splash) splash.style.opacity = 0; + if (splash) { + splash.style.opacity = 0; + } return resolveAfter(250).then(() => { - if (!splash || !splash.parentNode) return; + if (!splash || !splash.parentNode) { + return; + } splash.parentNode.removeChild(splash); }); }); diff --git a/src/libs/ComposerUtils/getDraftComment.js b/src/libs/ComposerUtils/getDraftComment.js index ddcb966bb2a7..854df1ac65ee 100644 --- a/src/libs/ComposerUtils/getDraftComment.js +++ b/src/libs/ComposerUtils/getDraftComment.js @@ -5,7 +5,9 @@ const draftCommentMap = {}; Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, callback: (value, key) => { - if (!key) return; + if (!key) { + return; + } const reportID = key.replace(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, ''); draftCommentMap[reportID] = value; diff --git a/src/libs/DateUtils.js b/src/libs/DateUtils.js index b33a1b1b2a73..70c4277bdb5e 100644 --- a/src/libs/DateUtils.js +++ b/src/libs/DateUtils.js @@ -298,7 +298,9 @@ function getDateStringFromISOTimestamp(isoTimestamp) { * @returns {String} */ function getStatusUntilDate(inputDate) { - if (!inputDate) return ''; + if (!inputDate) { + return ''; + } const {translateLocal} = Localize; const input = new Date(inputDate); diff --git a/src/libs/fileDownload/index.android.js b/src/libs/fileDownload/index.android.js index c19301cbde49..c3528b579f67 100644 --- a/src/libs/fileDownload/index.android.js +++ b/src/libs/fileDownload/index.android.js @@ -68,7 +68,9 @@ function handleDownload(url, fileName) { return Promise.reject(); } - if (!isLocalFile) attachmentPath = attachment.path(); + if (!isLocalFile) { + attachmentPath = attachment.path(); + } return RNFetchBlob.MediaCollection.copyToMediaStore( { diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js index 3f4a5fe3ac4c..6382af6a898e 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js @@ -49,7 +49,9 @@ function BaseReportActionContextMenu(props) { const wrapperStyle = getReportActionContextMenuStyles(props.isMini, props.isSmallScreenWidth); const reportAction = useMemo(() => { - if (_.isEmpty(props.reportActions) || props.reportActionID === '0') return {}; + if (_.isEmpty(props.reportActions) || props.reportActionID === '0') { + return {}; + } return props.reportActions[props.reportActionID] || {}; }, [props.reportActions, props.reportActionID]); diff --git a/src/pages/settings/Wallet/WalletPage/BaseWalletPage.js b/src/pages/settings/Wallet/WalletPage/BaseWalletPage.js index 1393892b6ef0..dcaf1de6ab4f 100644 --- a/src/pages/settings/Wallet/WalletPage/BaseWalletPage.js +++ b/src/pages/settings/Wallet/WalletPage/BaseWalletPage.js @@ -74,7 +74,9 @@ function BaseWalletPage(props) { * @param {Object} position */ const setMenuPosition = useCallback(() => { - if (!paymentMethodButtonRef.current) return; + if (!paymentMethodButtonRef.current) { + return; + } const position = getClickedTargetLocation(paymentMethodButtonRef.current); diff --git a/src/pages/tasks/TaskTitlePage.js b/src/pages/tasks/TaskTitlePage.js index 9a7a36a1e119..be0884e971ae 100644 --- a/src/pages/tasks/TaskTitlePage.js +++ b/src/pages/tasks/TaskTitlePage.js @@ -100,7 +100,9 @@ function TaskTitlePage(props) { accessibilityLabel={props.translate('task.title')} defaultValue={(props.report && props.report.reportName) || ''} ref={(el) => { - if (!el) return; + if (!el) { + return; + } if (!inputRef.current && didScreenTransitionEnd) { el.focus(); } diff --git a/src/styles/themes/useThemePreference.js b/src/styles/themes/useThemePreference.js index fbb557423f10..579e9dc97c69 100644 --- a/src/styles/themes/useThemePreference.js +++ b/src/styles/themes/useThemePreference.js @@ -18,8 +18,11 @@ function useThemePreference() { const theme = preferredThemeContext || CONST.THEME.DEFAULT; // If the user chooses to use the device theme settings, we need to set the theme preference to the system theme - if (theme === CONST.THEME.SYSTEM) setThemePreference(systemTheme); - else setThemePreference(theme); + if (theme === CONST.THEME.SYSTEM) { + setThemePreference(systemTheme); + } else { + setThemePreference(theme); + } }, [preferredThemeContext, systemTheme]); return themePreference;