Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Add curly option to ESLint config #27505

Merged
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 .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 @@ -99,7 +99,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 @@ -67,7 +67,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
}, [reportActions, compareImage]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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
}, [reportActions, compareImage]);
Expand Down Expand Up @@ -148,7 +150,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;
}
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/Hoverable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class Hoverable extends Component {
/**
* If the isScrollingRef is true, then the user is scrolling and we should not update the hover state.
*/
if (this.isScrollingRef && this.props.shouldHandleScroll && !this.state.isHovered) return;
if (this.isScrollingRef && this.props.shouldHandleScroll && !this.state.isHovered) {
return;
}

if (isHovered !== this.state.isHovered) {
this.setState({isHovered}, isHovered ? this.props.onHoverIn : this.props.onHoverOut);
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
8 changes: 6 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ function getChatType(report) {
* @returns {Object}
*/
function getPolicy(policyID) {
if (!allPolicies || !policyID) return {};
if (!allPolicies || !policyID) {
return {};
}
return allPolicies[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] || {};
}

Expand Down Expand Up @@ -272,7 +274,9 @@ function sortReportsByLastRead(reports) {
* @returns {Boolean}
*/
function isSettled(reportID) {
if (!allReports) return false;
if (!allReports) {
return false;
}
const report = allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] || {};
if ((typeof report === 'object' && Object.keys(report).length === 0) || report.isWaitingOnBankAccount) {
return false;
Expand Down
4 changes: 3 additions & 1 deletion src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ function getOnyxDataForOpenOrReconnect(isOpenApp = false) {
},
],
};
if (!isOpenApp) return defaultData;
if (!isOpenApp) {
return defaultData;
}
return {
optimisticData: [
...defaultData.optimisticData,
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
Loading
Loading