TWNTY-3794 - ESLint rule: only take explicit boolean predicates in if statements (#4354)
* ESLint rule: only take explicit boolean predicates in if statements Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Merge main Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Fix frontend linter errors Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Fix jest Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Refactor according to review Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Refactor according to review Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Fix lint on new code Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>
This commit is contained in:
committed by
GitHub
parent
40bea0d95e
commit
17511be0cf
@ -55,7 +55,7 @@ export const SettingsAccountsListCard = <
|
||||
const theme = useTheme();
|
||||
const navigate = useNavigate();
|
||||
|
||||
if (isLoading) return <SettingsAccountsListSkeletonCard />;
|
||||
if (isLoading === true) return <SettingsAccountsListSkeletonCard />;
|
||||
|
||||
if (!accounts.length) return <SettingsAccountsListEmptyStateCard />;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||
const updateBlockedEmailListJestFn = fn();
|
||||
|
||||
const ClearMocksDecorator: Decorator = (Story, context) => {
|
||||
if (context.parameters.clearMocks) {
|
||||
if (context.parameters.clearMocks === true) {
|
||||
updateBlockedEmailListJestFn.mockClear();
|
||||
}
|
||||
return <Story />;
|
||||
|
||||
@ -9,7 +9,7 @@ import { formatToHumanReadableDate } from '~/utils';
|
||||
const handleBlockedEmailRemoveJestFn = fn();
|
||||
|
||||
const ClearMocksDecorator: Decorator = (Story, context) => {
|
||||
if (context.parameters.clearMocks) {
|
||||
if (context.parameters.clearMocks === true) {
|
||||
handleBlockedEmailRemoveJestFn.mockClear();
|
||||
}
|
||||
return <Story />;
|
||||
|
||||
@ -9,7 +9,7 @@ import { formatToHumanReadableDate } from '~/utils';
|
||||
const onRemoveJestFn = fn();
|
||||
|
||||
const ClearMocksDecorator: Decorator = (Story, context) => {
|
||||
if (context.parameters.clearMocks) {
|
||||
if (context.parameters.clearMocks === true) {
|
||||
onRemoveJestFn.mockClear();
|
||||
}
|
||||
return <Story />;
|
||||
|
||||
@ -9,7 +9,7 @@ const handleActivateMockFunction = fn();
|
||||
const handleEraseMockFunction = fn();
|
||||
|
||||
const ClearMocksDecorator: Decorator = (Story, context) => {
|
||||
if (context.parameters.clearMocks) {
|
||||
if (context.parameters.clearMocks === true) {
|
||||
handleActivateMockFunction.mockClear();
|
||||
handleEraseMockFunction.mockClear();
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import { isLabelIdentifierField } from '@/object-metadata/utils/isLabelIdentifie
|
||||
import { SettingsObjectFieldSelectFormValues } from '@/settings/data-model/components/SettingsObjectFieldSelectForm';
|
||||
import { SETTINGS_FIELD_METADATA_TYPES } from '@/settings/data-model/constants/SettingsFieldMetadataTypes';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export const getFieldDefaultPreviewValue = ({
|
||||
fieldMetadataItem,
|
||||
@ -21,14 +22,17 @@ export const getFieldDefaultPreviewValue = ({
|
||||
selectOptions?: SettingsObjectFieldSelectFormValues;
|
||||
}) => {
|
||||
// Select field
|
||||
if (fieldMetadataItem.type === FieldMetadataType.Select && selectOptions) {
|
||||
if (
|
||||
fieldMetadataItem.type === FieldMetadataType.Select &&
|
||||
isNonNullable(selectOptions)
|
||||
) {
|
||||
return selectOptions.find(({ isDefault }) => isDefault) || selectOptions[0];
|
||||
}
|
||||
|
||||
// Relation field
|
||||
if (
|
||||
fieldMetadataItem.type === FieldMetadataType.Relation &&
|
||||
relationObjectMetadataItem
|
||||
isNonNullable(relationObjectMetadataItem)
|
||||
) {
|
||||
const relationLabelIdentifierFieldMetadataItem =
|
||||
getLabelIdentifierFieldMetadataItem(relationObjectMetadataItem);
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
import { ApiFieldItem } from '@/settings/developers/types/api-key/ApiFieldItem';
|
||||
import { ApiKey } from '@/settings/developers/types/api-key/ApiKey';
|
||||
import { beautifyDateDiff } from '~/utils/date-utils';
|
||||
@ -7,7 +9,7 @@ export const formatExpiration = (
|
||||
withExpiresMention: boolean = false,
|
||||
short: boolean = true,
|
||||
) => {
|
||||
if (expiresAt) {
|
||||
if (isNonEmptyString(expiresAt)) {
|
||||
const dateDiff = beautifyDateDiff(expiresAt, undefined, short);
|
||||
if (dateDiff.includes('-')) {
|
||||
return 'Expired';
|
||||
|
||||
@ -27,7 +27,7 @@ export const ChangePassword = () => {
|
||||
email: currentUser.email,
|
||||
},
|
||||
});
|
||||
if (data?.emailPasswordResetLink?.success) {
|
||||
if (data?.emailPasswordResetLink?.success === true) {
|
||||
enqueueSnackBar('Password reset link has been sent to the email', {
|
||||
variant: 'success',
|
||||
});
|
||||
|
||||
@ -47,12 +47,9 @@ export const NameFields = ({
|
||||
|
||||
// TODO: Enhance this with react-web-hook-form (https://www.react-hook-form.com)
|
||||
const debouncedUpdate = debounce(async () => {
|
||||
if (onFirstNameUpdate) {
|
||||
onFirstNameUpdate(firstName);
|
||||
}
|
||||
if (onLastNameUpdate) {
|
||||
onLastNameUpdate(lastName);
|
||||
}
|
||||
onFirstNameUpdate?.(firstName);
|
||||
onLastNameUpdate?.(lastName);
|
||||
|
||||
try {
|
||||
if (!currentWorkspaceMember?.id) {
|
||||
throw new Error('User is not logged in');
|
||||
|
||||
@ -7,6 +7,8 @@ import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||
import { ImageInput } from '@/ui/input/components/ImageInput';
|
||||
import { getImageAbsoluteURIOrBase64 } from '@/users/utils/getProfilePictureAbsoluteURI';
|
||||
import { useUploadProfilePictureMutation } from '~/generated/graphql';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isNullable } from '~/utils/isNullable';
|
||||
|
||||
export const ProfilePictureUploader = () => {
|
||||
const [uploadPicture, { loading: isUploading }] =
|
||||
@ -25,7 +27,7 @@ export const ProfilePictureUploader = () => {
|
||||
});
|
||||
|
||||
const handleUpload = async (file: File) => {
|
||||
if (!file) {
|
||||
if (isNullable(file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -72,7 +74,7 @@ export const ProfilePictureUploader = () => {
|
||||
};
|
||||
|
||||
const handleAbort = async () => {
|
||||
if (uploadController) {
|
||||
if (isNonNullable(uploadController)) {
|
||||
uploadController.abort();
|
||||
setUploadController(null);
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ import { useRecoilValue } from 'recoil';
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { TextInput } from '@/ui/input/components/TextInput';
|
||||
import { useUpdateWorkspaceMutation } from '~/generated/graphql';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isNullable } from '~/utils/isNullable';
|
||||
import { logError } from '~/utils/logError';
|
||||
|
||||
const StyledComboInputContainer = styled.div`
|
||||
@ -37,7 +39,7 @@ export const NameField = ({
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const debouncedUpdate = useCallback(
|
||||
debounce(async (name: string) => {
|
||||
if (onNameUpdate) {
|
||||
if (isNonNullable(onNameUpdate)) {
|
||||
onNameUpdate(displayName);
|
||||
}
|
||||
if (!autoSave || !name) {
|
||||
@ -52,7 +54,7 @@ export const NameField = ({
|
||||
},
|
||||
});
|
||||
|
||||
if (errors || !data?.updateWorkspace) {
|
||||
if (isNonNullable(errors) || isNullable(data?.updateWorkspace)) {
|
||||
throw errors;
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@ -7,6 +7,7 @@ import {
|
||||
useUpdateWorkspaceMutation,
|
||||
useUploadWorkspaceLogoMutation,
|
||||
} from '~/generated/graphql';
|
||||
import { isNullable } from '~/utils/isNullable';
|
||||
|
||||
export const WorkspaceLogoUploader = () => {
|
||||
const [uploadLogo] = useUploadWorkspaceLogoMutation();
|
||||
@ -16,7 +17,7 @@ export const WorkspaceLogoUploader = () => {
|
||||
);
|
||||
|
||||
const onUpload = async (file: File) => {
|
||||
if (!file) {
|
||||
if (isNullable(file)) {
|
||||
return;
|
||||
}
|
||||
if (!currentWorkspace?.id) {
|
||||
|
||||
Reference in New Issue
Block a user