From 78493d9521640898398e0fc909095c991af42df6 Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Wed, 7 Jun 2023 22:47:47 +0100 Subject: [PATCH] Fix lint errors --- frontend/src/components/signup/UserInfoStep.tsx | 7 ++----- .../src/components/utilities/checks/checkPassword.ts | 2 +- frontend/src/pages/settings/personal/[id].tsx | 10 ++++------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/signup/UserInfoStep.tsx b/frontend/src/components/signup/UserInfoStep.tsx index 0ad9141b1..e4feb1137 100644 --- a/frontend/src/components/signup/UserInfoStep.tsx +++ b/frontend/src/components/signup/UserInfoStep.tsx @@ -8,6 +8,7 @@ import jsrp from 'jsrp'; import nacl from 'tweetnacl'; import { encodeBase64 } from 'tweetnacl-util'; +import { useGetCommonPasswords } from '@app/hooks/api'; import completeAccountInformationSignup from '@app/pages/api/auth/CompleteAccountInformationSignup'; import getOrganizations from '@app/pages/api/organization/getOrgs'; import ProjectService from '@app/services/ProjectService'; @@ -19,7 +20,6 @@ import { deriveArgonKey } from '../utilities/cryptography/crypto'; import { saveTokenToLocalStorage } from '../utilities/saveTokenToLocalStorage'; import SecurityClient from '../utilities/SecurityClient'; import { Button, Input } from '../v2'; -import { useGetCommonPasswords } from '@app/hooks/api'; // eslint-disable-next-line new-cap const client = new jsrp.client(); @@ -76,9 +76,6 @@ export default function UserInfoStep({ const { data: commonPasswords } = useGetCommonPasswords(); const [nameError, setNameError] = useState(false); const [organizationNameError, setOrganizationNameError] = useState(false); - const [passwordErrorLength, setPasswordErrorLength] = useState(false); - const [passwordErrorNumber, setPasswordErrorNumber] = useState(false); - const [passwordErrorLowerCase, setPasswordErrorLowerCase] = useState(false); const [errors, setErrors] = useState({}); @@ -269,7 +266,7 @@ export default function UserInfoStep({ type="password" value={password} isRequired - error={passwordErrorLength && passwordErrorNumber && passwordErrorLowerCase} + error={Object.keys(errors).length > 0} autoComplete="new-password" id="new-password" /> diff --git a/frontend/src/components/utilities/checks/checkPassword.ts b/frontend/src/components/utilities/checks/checkPassword.ts index 9ec999cfc..69dba2397 100644 --- a/frontend/src/components/utilities/checks/checkPassword.ts +++ b/frontend/src/components/utilities/checks/checkPassword.ts @@ -35,7 +35,7 @@ const checkPassword = ({ commonPasswords, setErrors }: CheckPasswordParams): boolean => { - let errors: Errors = {}; + const errors: Errors = {}; if (password.length < 8) { errors.length = "8 characters"; diff --git a/frontend/src/pages/settings/personal/[id].tsx b/frontend/src/pages/settings/personal/[id].tsx index 93afcccdf..dabd90863 100644 --- a/frontend/src/pages/settings/personal/[id].tsx +++ b/frontend/src/pages/settings/personal/[id].tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import Head from 'next/head'; import { useRouter } from 'next/router'; -import { faCheck, faPlus, faXmark, faBan } from '@fortawesome/free-solid-svg-icons'; +import { faBan,faCheck, faPlus, faXmark } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import Button from '@app/components/basic/buttons/Button'; @@ -13,15 +13,14 @@ import NavHeader from '@app/components/navigation/NavHeader'; import checkPassword from '@app/components/utilities/checks/checkPassword'; import changePassword from '@app/components/utilities/cryptography/changePassword'; import issueBackupKey from '@app/components/utilities/cryptography/issueBackupKey'; +import { + useGetCommonPasswords, + useRevokeAllSessions} from '@app/hooks/api'; import { SecuritySection } from '@app/views/Settings/PersonalSettingsPage/SecuritySection/SecuritySection'; import AddApiKeyDialog from '../../../components/basic/dialog/AddApiKeyDialog'; import getAPIKeys from '../../api/apiKey/getAPIKeys'; import getUser from '../../api/user/getUser'; -import { - useRevokeAllSessions, - useGetCommonPasswords -} from '@app/hooks/api'; type Errors = { length?: string, @@ -229,7 +228,6 @@ export default function PersonalSettings() { }} color="mineshaft" size="md" - active={true} textDisabled={t('section.password.change') as string} />