Skip to content

Commit

Permalink
Add curly option to ESLint config
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Sep 15, 2023
1 parent c36ac0c commit de521f3
Show file tree
Hide file tree
Showing 25 changed files with 106 additions and 36 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = {
touchables: ['PressableWithoutFeedback', 'PressableWithFeedback'],
},
],
curly: 'error',
},
},
{
Expand Down
4 changes: 3 additions & 1 deletion src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
});
Expand Down Expand Up @@ -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();
})
Expand Down
4 changes: 3 additions & 1 deletion src/components/Attachments/AttachmentCarousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
8 changes: 6 additions & 2 deletions src/components/Attachments/AttachmentCarousel/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Composer/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
4 changes: 3 additions & 1 deletion src/components/Composer/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
4 changes: 3 additions & 1 deletion src/components/EmojiPicker/EmojiPickerMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/components/ImageView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ function ImageView({isAuthTokenRequired, url, fileName}) {
};

const imageLoadingStart = () => {
if (!isLoading) return;
if (!isLoading) {
return;
}
setIsLoading(true);
setZoomScale(0);
setIsZoomed(false);
Expand Down
16 changes: 12 additions & 4 deletions src/components/Pressable/PressableWithFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))();
Expand Down
4 changes: 3 additions & 1 deletion src/components/QRShare/QRShareWithDownload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
});
Expand Down
4 changes: 3 additions & 1 deletion src/components/SignInButtons/AppleSignIn/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};
Expand Down
4 changes: 3 additions & 1 deletion src/components/SignInButtons/AppleSignIn/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};
Expand Down
8 changes: 6 additions & 2 deletions src/components/SignInButtons/AppleSignIn/index.website.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
};

Expand Down Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion src/components/TextInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/libs/BootSplash/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down
4 changes: 3 additions & 1 deletion src/libs/ComposerUtils/getDraftComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/libs/DateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/libs/fileDownload/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
4 changes: 3 additions & 1 deletion src/pages/settings/Wallet/WalletPage/BaseWalletPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion src/pages/tasks/TaskTitlePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
7 changes: 5 additions & 2 deletions src/styles/themes/useThemePreference.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit de521f3

Please sign in to comment.