diff --git a/.eslintrc.json b/.eslintrc.json index 638d319307..a7e987556a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -44,6 +44,53 @@ "extensions": [".tsx"] } ], + "@typescript-eslint/ban-types": "error", + "@typescript-eslint/no-duplicate-enum-values": "error", + "@typescript-eslint/array-type": "error", + "@typescript-eslint/consistent-type-assertions": "error", + "@typescript-eslint/consistent-type-imports": "error", + "@typescript-eslint/explicit-function-return-type": "error", + "@typescript-eslint/naming-convention": [ + "error", + // Interfaces must begin with Interface or TestInterface followed by a PascalCase name + { + "selector": "interface", + "format": ["PascalCase"], + "prefix": ["Interface", "TestInterface"] + }, + // Type Aliases must be in PascalCase + { + "selector": ["typeAlias", "typeLike", "enum"], + "format": ["PascalCase"] + }, + { + "selector": "typeParameter", + "format": ["PascalCase"], + "prefix": ["T"] + }, + { + "selector": "variable", + "format": ["camelCase", "UPPER_CASE"], + "leadingUnderscore": "allow" + }, + { + "selector": "parameter", + "format": ["camelCase"], + "leadingUnderscore": "allow" + }, + { + "selector": "function", + "format": ["camelCase"] + }, + { + "selector": "memberLike", + "modifiers": ["private"], + "format": ["camelCase"], + "leadingUnderscore": "require" + }, + + { "selector": "variable", "modifiers": ["exported"], "format": null } + ], // Ensures that components are always written in PascalCase "react/jsx-pascal-case": [ "error", diff --git a/src/App.test.tsx b/src/App.test.tsx index 2a629db12e..1b88c4e2d7 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -35,7 +35,7 @@ const MOCKS = [ const link = new StaticMockLink(MOCKS, true); const link2 = new StaticMockLink([], true); -async function wait(ms = 100) { +async function wait(ms = 100): Promise { await act(() => { return new Promise((resolve) => { setTimeout(resolve, ms); diff --git a/src/App.tsx b/src/App.tsx index 21583fc2d6..981aa19e03 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,7 +22,7 @@ import Requests from 'screens/Requests/Requests'; import BlockUser from 'screens/BlockUser/BlockUser'; import MemberDetail from 'screens/MemberDetail/MemberDetail'; -function App(): JSX.Element { +function app(): JSX.Element { /*const { updatePluginLinks, updateInstalled } = bindActionCreators( actionCreators, dispatch @@ -52,12 +52,12 @@ function App(): JSX.Element { const extraRoutes = Object.entries(installedPlugins).map( (plugin: any, index) => { - const ExtraComponent = plugin[1]; + const extraComponent = plugin[1]; return ( ); } @@ -104,4 +104,4 @@ function App(): JSX.Element { ); } -export default App; +export default app; diff --git a/src/components/AddOn/AddOn.tsx b/src/components/AddOn/AddOn.tsx index bf4a79bf7d..7ac6466979 100644 --- a/src/components/AddOn/AddOn.tsx +++ b/src/components/AddOn/AddOn.tsx @@ -2,21 +2,21 @@ import React from 'react'; import PropTypes from 'prop-types'; import AdminNavbar from 'components/AdminNavbar/AdminNavbar'; import { useSelector } from 'react-redux'; -import { RootState } from 'state/reducers'; +import type { RootState } from 'state/reducers'; -interface AddOnProps { +interface InterfaceAddOnProps { extras: any; name: string; children: any; } // Validate Extras -function AddOn({ children }: AddOnProps): JSX.Element { +function addOn({ children }: InterfaceAddOnProps): JSX.Element { const appRoutes = useSelector((state: RootState) => state.appRoutes); const { targets, configUrl } = appRoutes; return ( <> - +
{children}
@@ -24,13 +24,13 @@ function AddOn({ children }: AddOnProps): JSX.Element { ); } -AddOn.defaultProps = { +addOn.defaultProps = { extras: {}, name: '', children: null, }; -AddOn.propTypes = { +addOn.propTypes = { extras: PropTypes.shape({ components: PropTypes.shape({}), actions: PropTypes.shape({}), @@ -39,4 +39,4 @@ AddOn.propTypes = { children: PropTypes.any, }; -export default AddOn; +export default addOn; diff --git a/src/components/AddOn/core/AddOnEntry/AddOnEntry.test.tsx b/src/components/AddOn/core/AddOnEntry/AddOnEntry.test.tsx index faf635d7d3..1716323755 100644 --- a/src/components/AddOn/core/AddOnEntry/AddOnEntry.test.tsx +++ b/src/components/AddOn/core/AddOnEntry/AddOnEntry.test.tsx @@ -4,12 +4,13 @@ import { BrowserRouter } from 'react-router-dom'; import AddOnEntry from './AddOnEntry'; import { ApolloClient, - NormalizedCacheObject, ApolloProvider, InMemoryCache, ApolloLink, HttpLink, } from '@apollo/client'; + +import type { NormalizedCacheObject } from '@apollo/client'; import { Provider } from 'react-redux'; import { store } from 'state/store'; import { BACKEND_URL } from 'Constant/constant'; @@ -40,7 +41,7 @@ describe('Testing AddOnEntry', () => { configurable: true, modified: true, isInstalled: true, - getInstalledPlugins: () => { + getInstalledPlugins: (): { sample: string } => { return { sample: 'sample' }; }, }; diff --git a/src/components/AddOn/core/AddOnEntry/AddOnEntry.tsx b/src/components/AddOn/core/AddOnEntry/AddOnEntry.tsx index ccb281357b..9288c30af9 100644 --- a/src/components/AddOn/core/AddOnEntry/AddOnEntry.tsx +++ b/src/components/AddOn/core/AddOnEntry/AddOnEntry.tsx @@ -9,7 +9,7 @@ import { import { useMutation } from '@apollo/client'; import { useTranslation } from 'react-i18next'; -interface AddOnEntryProps { +interface InterfaceAddOnEntryProps { id: string; enabled: boolean; title: string; @@ -23,7 +23,7 @@ interface AddOnEntryProps { getInstalledPlugins: () => any; } -function AddOnEntry({ +function addOnEntry({ id, enabled, title, @@ -32,7 +32,7 @@ function AddOnEntry({ installed, isInstalled, getInstalledPlugins, -}: AddOnEntryProps): JSX.Element { +}: InterfaceAddOnEntryProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'addOnEntry' }); const [buttonLoading, setButtonLoading] = useState(false); @@ -46,17 +46,16 @@ function AddOnEntry({ const currentOrg = window.location.href.split('=')[1]; - const updateOrgList = async () => { + const updateOrgList = async (): Promise => { await updateOrgStatus({ variables: { id: id.toString(), orgId: currentOrg.toString(), }, }); - // console.log('orgs pushed', data); }; - const updateInstallStatusFunc = async () => { + const updateInstallStatusFunc = async (): Promise => { setButtonLoading(true); await updateInstallStatus({ variables: { @@ -66,8 +65,6 @@ function AddOnEntry({ }); setIsInstalledLocal(!isInstalledLocal); - // console.log('AddOnEntry Data IS =>', data); - setButtonLoading(false); }; @@ -150,7 +147,7 @@ function AddOnEntry({ label={t('enable')} className={styles.entrytoggle} // eslint-disable-next-line @typescript-eslint/no-empty-function - onChange={() => {}} + onChange={(): void => {}} disabled={switchInProgress} checked={enabled} /> @@ -166,7 +163,7 @@ function AddOnEntry({ variant="primary" // disabled={buttonLoading || !configurable} disabled={buttonLoading} - onClick={() => { + onClick={(): void => { updateOrgList(); updateInstallStatusFunc(); getInstalledPlugins(); @@ -190,7 +187,7 @@ function AddOnEntry({ ); } -AddOnEntry.defaultProps = { +addOnEntry.defaultProps = { enabled: false, configurable: true, title: '', @@ -198,7 +195,7 @@ AddOnEntry.defaultProps = { isInstalled: false, }; -AddOnEntry.propTypes = { +addOnEntry.propTypes = { enabled: PropTypes.bool, configurable: PropTypes.bool, title: PropTypes.string, @@ -206,4 +203,4 @@ AddOnEntry.propTypes = { isInstalled: PropTypes.bool, }; -export default AddOnEntry; +export default addOnEntry; diff --git a/src/components/AddOn/core/AddOnRegister/AddOnRegister.test.tsx b/src/components/AddOn/core/AddOnRegister/AddOnRegister.test.tsx index f5f79a9e40..7caa1f9e3e 100644 --- a/src/components/AddOn/core/AddOnRegister/AddOnRegister.test.tsx +++ b/src/components/AddOn/core/AddOnRegister/AddOnRegister.test.tsx @@ -4,12 +4,12 @@ import userEvent from '@testing-library/user-event'; import AddOnRegister from './AddOnRegister'; import { ApolloClient, - NormalizedCacheObject, ApolloProvider, InMemoryCache, ApolloLink, HttpLink, } from '@apollo/client'; +import type { NormalizedCacheObject } from '@apollo/client'; import { Provider } from 'react-redux'; import { store } from 'state/store'; import { BrowserRouter } from 'react-router-dom'; @@ -24,7 +24,7 @@ const httpLink = new HttpLink({ }, }); -async function wait(ms = 500) { +async function wait(ms = 500): Promise { await act(() => { return new Promise((resolve) => { setTimeout(resolve, ms); diff --git a/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx b/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx index a04cae6304..4f720b4fad 100644 --- a/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx +++ b/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx @@ -7,11 +7,11 @@ import { ADD_PLUGIN_MUTATION } from 'GraphQl/Mutations/mutations'; import { useTranslation } from 'react-i18next'; import { toast } from 'react-toastify'; -interface AddOnRegisterProps { +interface InterfaceAddOnRegisterProps { id?: string; // OrgId createdBy?: string; // User } -interface formStateTypes { +interface InterfaceFormStateTypes { pluginName: string; pluginCreatedBy: string; pluginDesc: string; @@ -21,16 +21,19 @@ interface formStateTypes { const currentUrl = window.location.href.split('=')[1]; // eslint-disable-next-line @typescript-eslint/no-unused-vars -function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element { +function addOnRegister({ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + createdBy, +}: InterfaceAddOnRegisterProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'addOnRegister' }); const [show, setShow] = useState(false); - const handleClose = () => setShow(false); - const handleShow = () => setShow(true); + const handleClose = (): void => setShow(false); + const handleShow = (): void => setShow(true); const [create] = useMutation(ADD_PLUGIN_MUTATION); - const [formState, setFormState] = useState({ + const [formState, setFormState] = useState({ pluginName: '', pluginCreatedBy: '', pluginDesc: '', @@ -38,7 +41,7 @@ function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element { installedOrgs: [currentUrl], }); - const handleRegister = async () => { + const handleRegister = async (): Promise => { const { data } = await create({ variables: { $pluginName: formState.pluginName, @@ -81,7 +84,7 @@ function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element { autoComplete="off" required value={formState.pluginName} - onChange={(e) => { + onChange={(e): void => { setFormState({ ...formState, pluginName: e.target.value, @@ -97,7 +100,7 @@ function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element { autoComplete="off" required value={formState.pluginCreatedBy} - onChange={(e) => { + onChange={(e): void => { setFormState({ ...formState, pluginCreatedBy: e.target.value, @@ -114,7 +117,7 @@ function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element { placeholder={t('pDesc')} required value={formState.pluginDesc} - onChange={(e) => { + onChange={(e): void => { setFormState({ ...formState, pluginDesc: e.target.value, @@ -145,12 +148,12 @@ function AddOnRegister({ createdBy }: AddOnRegisterProps): JSX.Element { ); } -AddOnRegister.defaultProps = { +addOnRegister.defaultProps = { createdBy: 'Admin', }; -AddOnRegister.propTypes = { +addOnRegister.propTypes = { createdBy: PropTypes.string, }; -export default AddOnRegister; +export default addOnRegister; diff --git a/src/components/AddOn/core/AddOnStore/AddOnStore.test.tsx b/src/components/AddOn/core/AddOnStore/AddOnStore.test.tsx index 758d6c96cb..2fc5e61e92 100644 --- a/src/components/AddOn/core/AddOnStore/AddOnStore.test.tsx +++ b/src/components/AddOn/core/AddOnStore/AddOnStore.test.tsx @@ -8,12 +8,13 @@ import { render } from '@testing-library/react'; // import { store } from 'state/store'; import { ApolloClient, - NormalizedCacheObject, ApolloProvider, InMemoryCache, ApolloLink, HttpLink, } from '@apollo/client'; + +import type { NormalizedCacheObject } from '@apollo/client'; import { BrowserRouter } from 'react-router-dom'; import AddOnStore from './AddOnStore'; import { Provider } from 'react-redux'; diff --git a/src/components/AddOn/core/AddOnStore/AddOnStore.tsx b/src/components/AddOn/core/AddOnStore/AddOnStore.tsx index df85f88245..b3283497da 100644 --- a/src/components/AddOn/core/AddOnStore/AddOnStore.tsx +++ b/src/components/AddOn/core/AddOnStore/AddOnStore.tsx @@ -15,14 +15,14 @@ import { USER_LIST, } from 'GraphQl/Queries/Queries'; // PLUGIN_LIST import { useSelector } from 'react-redux'; -import { RootState } from '../../../../state/reducers'; +import type { RootState } from '../../../../state/reducers'; import { Form, Tab, Tabs } from 'react-bootstrap'; import AddOnRegister from '../AddOnRegister/AddOnRegister'; import PluginHelper from 'components/AddOn/support/services/Plugin.helper'; import { store } from './../../../../state/store'; import { useTranslation } from 'react-i18next'; -function AddOnStore(): JSX.Element { +function addOnStore(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'addOnStore' }); const [isStore, setIsStore] = useState(true); @@ -39,6 +39,7 @@ function AddOnStore(): JSX.Element { // type plugData = { pluginName: String, plug }; const { data, loading, error } = useQuery(PLUGIN_GET); /* istanbul ignore next */ + // eslint-disable-next-line @typescript-eslint/explicit-function-return-type const getStorePlugins = async () => { let plugins = await new PluginHelper().fetchStore(); const installIds = (await new PluginHelper().fetchInstalled()).map( @@ -69,12 +70,11 @@ function AddOnStore(): JSX.Element { }; /* istanbul ignore next */ - const updateLinks = async (links: any[]) => { + const updateLinks = async (links: any[]): Promise => { store.dispatch({ type: 'UPDATE_P_TARGETS', payload: links }); }; - // /* istanbul ignore next */ - const pluginModified = () => { + const pluginModified = (): void => { return getInstalledPlugins(); // .then((installedPlugins) => { // getStorePlugins(); @@ -86,12 +86,12 @@ function AddOnStore(): JSX.Element { // pluginModified(); // }, []); - const updateSelectedTab = (tab: any) => { + const updateSelectedTab = (tab: any): void => { setIsStore(tab === 'available'); isStore ? getStorePlugins() : getInstalledPlugins(); }; - const filterChange = (ev: any) => { + const filterChange = (ev: any): void => { setShowEnabled(ev.target.value === 'enabled'); }; @@ -103,16 +103,10 @@ function AddOnStore(): JSX.Element { ); } - // console.log( - // 'Filtered Data is ', - // data.getPlugins.filter((plugin: any) => plugin.pluginInstallStatus == true) - // ); - // TODO: Update routes for other pages - // TODO: Implement Search return ( <>
- +
@@ -124,7 +118,7 @@ function AddOnStore(): JSX.Element { placeholder={t('searchName')} autoComplete="off" required - onChange={(e) => setSearchText(e.target.value)} + onChange={(e): void => setSearchText(e.target.value)} /> {!isStore && ( @@ -260,7 +254,7 @@ function AddOnStore(): JSX.Element { isInstalled={plug.pluginInstallStatus} configurable={plug.pluginInstallStatus} component={'Special Component'} - modified={() => { + modified={(): void => { console.log('Plugin is modified'); }} getInstalledPlugins={getInstalledPlugins} @@ -337,7 +331,7 @@ function AddOnStore(): JSX.Element { isInstalled={plug.pluginInstallStatus} configurable={plug.pluginInstallStatus} component={'Special Component'} - modified={() => { + modified={(): void => { console.log('Plugin is modified'); }} getInstalledPlugins={getInstalledPlugins} @@ -354,11 +348,11 @@ function AddOnStore(): JSX.Element { ); } -AddOnStore.defaultProps = {}; +addOnStore.defaultProps = {}; -AddOnStore.propTypes = {}; +addOnStore.propTypes = {}; -export default AddOnStore; +export default addOnStore; // {addonStore.map((plugin: any, index: number) => { // return ( diff --git a/src/components/AddOn/support/components/Action/Action.tsx b/src/components/AddOn/support/components/Action/Action.tsx index e1484df8aa..50b6b10797 100644 --- a/src/components/AddOn/support/components/Action/Action.tsx +++ b/src/components/AddOn/support/components/Action/Action.tsx @@ -1,19 +1,15 @@ -import React, { useEffect, useRef } from 'react'; +import React, { useRef } from 'react'; // TODO: UI logic for embedded actions (hide label) -interface ActionProps { +interface InterfaceActionProps { children: any; label: string; } // TODO: props => Validate child element type, register functions from children for global use?, -function Action(props: ActionProps): JSX.Element { +function action(props: InterfaceActionProps): JSX.Element { const actionRef = useRef(null); - useEffect(() => { - // console.log('Props', props.children); // Validate Type - // console.log('Ref', actionRef); // Fetch Events - }); return (
{props.label}
@@ -22,4 +18,4 @@ function Action(props: ActionProps): JSX.Element { ); } -export default Action; +export default action; diff --git a/src/components/AddOn/support/components/MainContent/MainContent.tsx b/src/components/AddOn/support/components/MainContent/MainContent.tsx index f8d5178f06..7ca4dfc8c4 100644 --- a/src/components/AddOn/support/components/MainContent/MainContent.tsx +++ b/src/components/AddOn/support/components/MainContent/MainContent.tsx @@ -1,13 +1,13 @@ import React from 'react'; import styles from './MainContent.module.css'; -interface MainContentProps { +interface InterfaceMainContentProps { children: any; } // TODO: Implement extras plugins // TODO: Implement additional styles // id - [plugin/component-name]-main-content if is in plugin -function MainContent({ children }: MainContentProps): JSX.Element { +function mainContent({ children }: InterfaceMainContentProps): JSX.Element { return (
{children} @@ -15,4 +15,4 @@ function MainContent({ children }: MainContentProps): JSX.Element { ); } -export default MainContent; +export default mainContent; diff --git a/src/components/AddOn/support/components/SidePanel/SidePanel.test.tsx b/src/components/AddOn/support/components/SidePanel/SidePanel.test.tsx index 170b91e226..5590fa1786 100644 --- a/src/components/AddOn/support/components/SidePanel/SidePanel.test.tsx +++ b/src/components/AddOn/support/components/SidePanel/SidePanel.test.tsx @@ -1,12 +1,8 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import SidePanel from './SidePanel'; -import { - ApolloClient, - NormalizedCacheObject, - ApolloProvider, - InMemoryCache, -} from '@apollo/client'; +import type { NormalizedCacheObject } from '@apollo/client'; +import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client'; import { BACKEND_URL } from 'Constant/constant'; const client: ApolloClient = new ApolloClient({ diff --git a/src/components/AddOn/support/components/SidePanel/SidePanel.tsx b/src/components/AddOn/support/components/SidePanel/SidePanel.tsx index cba3ece0c2..2eda5e7225 100644 --- a/src/components/AddOn/support/components/SidePanel/SidePanel.tsx +++ b/src/components/AddOn/support/components/SidePanel/SidePanel.tsx @@ -1,13 +1,16 @@ import React from 'react'; import styles from './SidePanel.module.css'; -interface SidePanelProps { +interface InterfaceSidePanelProps { collapse?: boolean; children: any; } // TODO: Implement Extras Plugin // id - [plugin-name]-side-panel -function SidePanel({ collapse, children }: SidePanelProps): JSX.Element { +function sidePanel({ + collapse, + children, +}: InterfaceSidePanelProps): JSX.Element { return (
{ + fetchStore = async (): Promise => { const result = await fetch(`http://localhost:3005/store`); return await result.json(); }; - fetchInstalled = async () => { + fetchInstalled = async (): Promise => { const result = await fetch(`http://localhost:3005/installed`); return await result.json(); }; - generateLinks = (plugins: any[]) => { + generateLinks = (plugins: any[]): { name: string; url: string }[] => { return plugins .filter((plugin: any) => plugin.enabled) .map((installedPlugin: any) => { diff --git a/src/components/AdminDashListCard/AdminDashListCard.tsx b/src/components/AdminDashListCard/AdminDashListCard.tsx index ebd90076c5..5f66a10ef2 100644 --- a/src/components/AdminDashListCard/AdminDashListCard.tsx +++ b/src/components/AdminDashListCard/AdminDashListCard.tsx @@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'; import styles from './AdminDashListCard.module.css'; import defaultImg from 'assets/third_image.png'; -interface AdminDashListCardProps { +interface InterfaceAdminDashListCardProps { key: string; id: string; orgName: string; @@ -18,10 +18,12 @@ interface AdminDashListCardProps { members: any; } -function AdminDashListCard(props: AdminDashListCardProps): JSX.Element { +function adminDashListCard( + props: InterfaceAdminDashListCardProps +): JSX.Element { const userId = localStorage.getItem('id'); - function Click() { + function click(): void { const url = '/orgdash/id=' + props.id; window.location.replace(url); } @@ -58,7 +60,7 @@ function AdminDashListCard(props: AdminDashListCardProps): JSX.Element {
@@ -370,7 +373,9 @@ function EventListCard(props: EventListCardProps): JSX.Element { type="checkbox" data-testid="updateRecurring" checked={recurringchecked} - onChange={() => setRecurringChecked(!recurringchecked)} + onChange={(): void => + setRecurringChecked(!recurringchecked) + } />
@@ -382,7 +387,7 @@ function EventListCard(props: EventListCardProps): JSX.Element { type="checkbox" data-testid="updateIsPublic" checked={publicchecked} - onChange={() => setPublicChecked(!publicchecked)} + onChange={(): void => setPublicChecked(!publicchecked)} />
@@ -392,7 +397,7 @@ function EventListCard(props: EventListCardProps): JSX.Element { type="checkbox" data-testid="updateRegistrable" checked={registrablechecked} - onChange={() => + onChange={(): void => setRegistrableChecked(!registrablechecked) } /> @@ -423,4 +428,4 @@ function EventListCard(props: EventListCardProps): JSX.Element { ); } export {}; -export default EventListCard; +export default eventListCard; diff --git a/src/components/LandingPage/LandingPage.test.tsx b/src/components/LandingPage/LandingPage.test.tsx index 7cf4f16407..b4e798bab7 100644 --- a/src/components/LandingPage/LandingPage.test.tsx +++ b/src/components/LandingPage/LandingPage.test.tsx @@ -3,12 +3,8 @@ import { render, waitFor } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import LandingPage from './LandingPage'; -import { - ApolloClient, - NormalizedCacheObject, - ApolloProvider, - InMemoryCache, -} from '@apollo/client'; +import type { NormalizedCacheObject } from '@apollo/client'; +import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client'; import i18n from 'utils/i18n'; import { BACKEND_URL } from 'Constant/constant'; diff --git a/src/components/LandingPage/LandingPage.tsx b/src/components/LandingPage/LandingPage.tsx index 68ff087179..fadb028dc9 100644 --- a/src/components/LandingPage/LandingPage.tsx +++ b/src/components/LandingPage/LandingPage.tsx @@ -3,7 +3,7 @@ import styles from './LandingPage.module.css'; import slide1 from 'assets/images/palisadoes_logo.png'; import { useTranslation } from 'react-i18next'; -function LandingPage(): JSX.Element { +function landingPage(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'loginPage' }); return ( @@ -20,4 +20,4 @@ function LandingPage(): JSX.Element { ); } export {}; -export default LandingPage; +export default landingPage; diff --git a/src/components/ListNavbar/ListNavbar.test.tsx b/src/components/ListNavbar/ListNavbar.test.tsx index 0097d5d619..40612db985 100644 --- a/src/components/ListNavbar/ListNavbar.test.tsx +++ b/src/components/ListNavbar/ListNavbar.test.tsx @@ -8,7 +8,7 @@ import 'jest-localstorage-mock'; import ListNavbar from './ListNavbar'; import i18nForTest from 'utils/i18nForTest'; -async function wait(ms = 100) { +async function wait(ms = 100): Promise { await act(() => { return new Promise((resolve) => { setTimeout(resolve, ms); diff --git a/src/components/ListNavbar/ListNavbar.tsx b/src/components/ListNavbar/ListNavbar.tsx index 6e5acca609..e4f6af111a 100644 --- a/src/components/ListNavbar/ListNavbar.tsx +++ b/src/components/ListNavbar/ListNavbar.tsx @@ -10,6 +10,7 @@ import styles from './ListNavbar.module.css'; import Logo from 'assets/talawa-logo-200x200.png'; import { languages } from 'utils/languages'; +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type const ListNavbar = () => { const { t } = useTranslation('translation', { keyPrefix: 'listNavbar' }); @@ -17,7 +18,7 @@ const ListNavbar = () => { const currentLanguageCode = Cookies.get('i18next') || 'en'; - const logout = () => { + const logout = (): void => { localStorage.clear(); window.location.replace('/'); }; @@ -77,7 +78,9 @@ const ListNavbar = () => { i18next.changeLanguage(language.code)} + onClick={async (): Promise => { + await i18next.changeLanguage(language.code); + }} disabled={currentLanguageCode === language.code} data-testid={`changeLanguageBtn${index}`} > diff --git a/src/components/MemberRequestCard/MemberRequestCard.test.tsx b/src/components/MemberRequestCard/MemberRequestCard.test.tsx index bec84b5a39..94efce5f09 100644 --- a/src/components/MemberRequestCard/MemberRequestCard.test.tsx +++ b/src/components/MemberRequestCard/MemberRequestCard.test.tsx @@ -45,7 +45,7 @@ const MOCKS = [ }, ]; const link = new StaticMockLink(MOCKS, true); -async function wait(ms = 100) { +async function wait(ms = 100): Promise { await act(() => { return new Promise((resolve) => { setTimeout(resolve, ms); @@ -67,7 +67,7 @@ describe('Testing Member Request Card', () => { global.alert = jest.fn(); it('should render props and text elements test for the page component', async () => { - global.confirm = () => true; + global.confirm = (): boolean => true; render( @@ -90,7 +90,7 @@ describe('Testing Member Request Card', () => { }); it('Should render text elements when props value is not passed', async () => { - global.confirm = () => false; + global.confirm = (): boolean => false; render( diff --git a/src/components/MemberRequestCard/MemberRequestCard.tsx b/src/components/MemberRequestCard/MemberRequestCard.tsx index 53a3fd98d1..f107bcf6f7 100644 --- a/src/components/MemberRequestCard/MemberRequestCard.tsx +++ b/src/components/MemberRequestCard/MemberRequestCard.tsx @@ -13,7 +13,7 @@ import { toast } from 'react-toastify'; import defaultImg from 'assets/third_image.png'; import { errorHandler } from 'utils/errorHandler'; -interface MemberRequestCardProps { +interface InterfaceMemberRequestCardProps { key: string; id: string; memberName: string; @@ -23,7 +23,9 @@ interface MemberRequestCardProps { email: string; } -function MemberRequestCard(props: MemberRequestCardProps): JSX.Element { +function memberRequestCard( + props: InterfaceMemberRequestCardProps +): JSX.Element { const [acceptMutation] = useMutation(ACCEPT_ORGANIZATION_REQUEST_MUTATION); const [rejectMutation] = useMutation(REJECT_ORGANIZATION_REQUEST_MUTATION); @@ -31,7 +33,7 @@ function MemberRequestCard(props: MemberRequestCardProps): JSX.Element { keyPrefix: 'membershipRequest', }); - const AddMember = async () => { + const addMember = async (): Promise => { try { await acceptMutation({ variables: { @@ -51,7 +53,7 @@ function MemberRequestCard(props: MemberRequestCardProps): JSX.Element { } }; - const RejectMember = async () => { + const rejectMember = async (): Promise => { const sure = window.confirm('Are you sure you want to Reject Request ?'); if (sure) { try { @@ -101,13 +103,13 @@ function MemberRequestCard(props: MemberRequestCardProps): JSX.Element {

@@ -120,4 +122,4 @@ function MemberRequestCard(props: MemberRequestCardProps): JSX.Element { ); } export {}; -export default MemberRequestCard; +export default memberRequestCard; diff --git a/src/components/NotFound/NotFound.tsx b/src/components/NotFound/NotFound.tsx index 5b732d6d85..6e2853cf82 100644 --- a/src/components/NotFound/NotFound.tsx +++ b/src/components/NotFound/NotFound.tsx @@ -3,12 +3,12 @@ import { useTranslation } from 'react-i18next'; import styles from './NotFound.module.css'; -interface NotFoundProps { +interface InterfaceNotFoundProps { title: string; keyPrefix: string; } -function NotFound(props: NotFoundProps): JSX.Element { +function notFound(props: InterfaceNotFoundProps): JSX.Element { const key = props.keyPrefix.toString(); const { t } = useTranslation('translation', { keyPrefix: key, @@ -22,4 +22,4 @@ function NotFound(props: NotFoundProps): JSX.Element { ); } -export default NotFound; +export default notFound; diff --git a/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx b/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx index 09fb634a3c..db499cd0b1 100644 --- a/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx +++ b/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx @@ -28,7 +28,7 @@ const MOCKS = [ }, ]; const link = new StaticMockLink(MOCKS, true); -async function wait(ms = 100) { +async function wait(ms = 100): Promise { await act(() => { return new Promise((resolve) => { setTimeout(resolve, ms); diff --git a/src/components/OrgAdminListCard/OrgAdminListCard.tsx b/src/components/OrgAdminListCard/OrgAdminListCard.tsx index ca90a6cdf9..ee1a562eb2 100644 --- a/src/components/OrgAdminListCard/OrgAdminListCard.tsx +++ b/src/components/OrgAdminListCard/OrgAdminListCard.tsx @@ -5,7 +5,6 @@ import Button from 'react-bootstrap/Button'; import Modal from 'react-bootstrap/Modal'; import { useMutation } from '@apollo/client'; import { toast } from 'react-toastify'; -// import { ApolloProvider } from '@apollo/react-hooks'; import styles from './OrgAdminListCard.module.css'; import { REMOVE_ADMIN_MUTATION } from 'GraphQl/Mutations/mutations'; @@ -14,7 +13,7 @@ import { Link } from 'react-router-dom'; import defaultImg from 'assets/third_image.png'; import { errorHandler } from 'utils/errorHandler'; -interface OrgPeopleListCardProps { +interface InterfaceOrgPeopleListCardProps { key: string; id: string; memberName: string; @@ -24,7 +23,7 @@ interface OrgPeopleListCardProps { } const currentUrl = window.location.href.split('=')[1]; -function OrgAdminListCard(props: OrgPeopleListCardProps): JSX.Element { +function orgAdminListCard(props: InterfaceOrgPeopleListCardProps): JSX.Element { const [remove] = useMutation(REMOVE_ADMIN_MUTATION); const [showRemoveAdminModal, setShowRemoveAdminModal] = React.useState(false); @@ -32,10 +31,10 @@ function OrgAdminListCard(props: OrgPeopleListCardProps): JSX.Element { keyPrefix: 'orgAdminListCard', }); - const toggleRemoveAdminModal = () => + const toggleRemoveAdminModal = (): void => setShowRemoveAdminModal(!showRemoveAdminModal); - const RemoveAdmin = async () => { + const removeAdmin = async (): Promise => { try { const { data } = await remove({ variables: { @@ -108,7 +107,7 @@ function OrgAdminListCard(props: OrgPeopleListCardProps): JSX.Element {
); } -export {}; -export default OrgAdminListCard; +export default orgAdminListCard; diff --git a/src/components/OrgContriCards/OrgContriCards.test.tsx b/src/components/OrgContriCards/OrgContriCards.test.tsx index 9de29e1d1f..95de529d98 100644 --- a/src/components/OrgContriCards/OrgContriCards.test.tsx +++ b/src/components/OrgContriCards/OrgContriCards.test.tsx @@ -1,11 +1,7 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; -import { - ApolloClient, - NormalizedCacheObject, - ApolloProvider, - InMemoryCache, -} from '@apollo/client'; +import type { NormalizedCacheObject } from '@apollo/client'; +import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client'; import { I18nextProvider } from 'react-i18next'; import OrgContriCards from './OrgContriCards'; diff --git a/src/components/OrgContriCards/OrgContriCards.tsx b/src/components/OrgContriCards/OrgContriCards.tsx index 09f965f8c6..69a9e03d58 100644 --- a/src/components/OrgContriCards/OrgContriCards.tsx +++ b/src/components/OrgContriCards/OrgContriCards.tsx @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'; import styles from './OrgContriCards.module.css'; -interface OrgContriCardsProps { +interface InterfaceOrgContriCardsProps { key: string; id: string; userName: string; @@ -14,7 +14,7 @@ interface OrgContriCardsProps { contriTransactionId: string; userEmail: string; } -function OrgContriCards(props: OrgContriCardsProps): JSX.Element { +function orgContriCards(props: InterfaceOrgContriCardsProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'orgContriCards', }); @@ -39,4 +39,4 @@ function OrgContriCards(props: OrgContriCardsProps): JSX.Element { ); } -export default OrgContriCards; +export default orgContriCards; diff --git a/src/components/OrgDelete/OrgDelete.test.tsx b/src/components/OrgDelete/OrgDelete.test.tsx index ed669efcdd..cc89241f56 100644 --- a/src/components/OrgDelete/OrgDelete.test.tsx +++ b/src/components/OrgDelete/OrgDelete.test.tsx @@ -1,11 +1,7 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; -import { - ApolloClient, - NormalizedCacheObject, - ApolloProvider, - InMemoryCache, -} from '@apollo/client'; +import type { NormalizedCacheObject } from '@apollo/client'; +import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client'; import { I18nextProvider } from 'react-i18next'; import OrgDelete from './OrgDelete'; diff --git a/src/components/OrgDelete/OrgDelete.tsx b/src/components/OrgDelete/OrgDelete.tsx index 36c4241d5c..0f1335dae4 100644 --- a/src/components/OrgDelete/OrgDelete.tsx +++ b/src/components/OrgDelete/OrgDelete.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; -function OrgDelete(): JSX.Element { +function orgDelete(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'orgDelete', }); @@ -14,4 +14,4 @@ function OrgDelete(): JSX.Element { ); } -export default OrgDelete; +export default orgDelete; diff --git a/src/components/OrgPeopleListCard/OrgPeopleListCard.test.tsx b/src/components/OrgPeopleListCard/OrgPeopleListCard.test.tsx index 7666738960..e283f92e13 100644 --- a/src/components/OrgPeopleListCard/OrgPeopleListCard.test.tsx +++ b/src/components/OrgPeopleListCard/OrgPeopleListCard.test.tsx @@ -28,7 +28,7 @@ const MOCKS = [ }, ]; const link = new StaticMockLink(MOCKS, true); -async function wait(ms = 100) { +async function wait(ms = 100): Promise { await act(() => { return new Promise((resolve) => { setTimeout(resolve, ms); @@ -49,7 +49,7 @@ describe('Testing Organization People List Card', () => { global.alert = jest.fn(); test('should render props and text elements test for the page component', async () => { - global.confirm = () => true; + global.confirm = (): boolean => true; render( @@ -72,7 +72,7 @@ describe('Testing Organization People List Card', () => { }); test('Should render text elements when props value is not passed', async () => { - global.confirm = () => false; + global.confirm = (): boolean => false; render( diff --git a/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx b/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx index ad741c9a0c..233bf81980 100644 --- a/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx +++ b/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx @@ -12,7 +12,7 @@ import { Link } from 'react-router-dom'; import defaultImg from 'assets/third_image.png'; import { errorHandler } from 'utils/errorHandler'; -interface OrgPeopleListCardProps { +interface InterfaceOrgPeopleListCardProps { key: string; id: string; memberName: string; @@ -21,19 +21,21 @@ interface OrgPeopleListCardProps { memberEmail: string; } -function OrgPeopleListCard(props: OrgPeopleListCardProps): JSX.Element { +function orgPeopleListCard( + props: InterfaceOrgPeopleListCardProps +): JSX.Element { const currentUrl = window.location.href.split('=')[1]; const [remove] = useMutation(REMOVE_MEMBER_MUTATION); const [showRemoveAdminModal, setShowRemoveAdminModal] = React.useState(false); - const toggleRemoveAdminModal = () => + const toggleRemoveAdminModal = (): void => setShowRemoveAdminModal(!showRemoveAdminModal); const { t } = useTranslation('translation', { keyPrefix: 'orgPeopleListCard', }); - const RemoveMember = async () => { + const removeMember = async (): Promise => { try { const { data } = await remove({ variables: { @@ -107,7 +109,7 @@ function OrgPeopleListCard(props: OrgPeopleListCardProps): JSX.Element {
- {/* delete modal */} + {/* Delete Modal */}
{t('deletePost')}
@@ -208,7 +214,7 @@ function OrgPostCard(props: OrgPostCardProps): JSX.Element { @@ -232,7 +236,7 @@ function OrgPostCard(props: OrgPostCardProps): JSX.Element { - {t('information')} -