Skip to content

Commit feb7dee

Browse files
committed
fix eslint and updates react types used
1 parent 645de0e commit feb7dee

File tree

13 files changed

+45
-29
lines changed

13 files changed

+45
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"docker:down": "docker compose down",
1616
"docker:up": "docker compose up -d",
1717
"lint": "npm run -s lint:eslint && npm run -s lint:prettier && npm run -s lint:ts",
18-
"lint:eslint": "eslint --ext=.js,.jsx,.mjs,.ts,.tsx --ignore-path .gitignore --max-warnings 0",
18+
"lint:eslint": "eslint --ext=.js,.jsx,.mjs,.ts,.tsx --ignore-path .gitignore --max-warnings 0 .",
1919
"lint:prettier": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config .prettierrc",
2020
"lint:ts": "tsc",
2121
"pre-commit": "lint-staged && npm run -s lint:ts",

src/components/ActiveLink/ActiveLink.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export interface ActiveLinkProps extends LinkProps {
1111
nested?: boolean;
1212
}
1313

14-
const ActiveLink: React.FC<ActiveLinkProps> = ({
14+
const ActiveLink = ({
1515
children,
1616
nested,
1717
...linkProps
18-
}) => {
18+
}: ActiveLinkProps): React.ReactElement => {
1919
const { asPath } = useRouter();
2020
const isActive =
2121
asPath === linkProps.href ||

src/components/Auth/Auth.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@ export interface AuthSettings {
1111
allowedRoles?: Role[];
1212
loginUrl?: Url;
1313
}
14-
export type AuthProps = AuthSettings;
14+
export interface AuthProps extends AuthSettings {
15+
children: React.ReactNode;
16+
}
1517
export type Session = ReturnType<typeof useSession>[0];
1618
export interface AuthChildProps {
1719
session: Session;
1820
}
1921

20-
const Auth: React.FC<AuthProps> = ({ allowedRoles, children, loginUrl }) => {
22+
const Auth = ({
23+
allowedRoles,
24+
children,
25+
loginUrl,
26+
}: AuthProps): React.ReactElement => {
2127
const [session, loading] = useSession();
2228
const hasAuth = isAuthenticated(session?.user);
2329
const router = useRouter();

src/components/Notifications/Notifications.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ export interface SimpleNotificationProps extends Toast {
2121
state: SimpleNotificationState;
2222
}
2323

24-
const SimpleNotification: React.FC<SimpleNotificationProps> = ({
24+
const SimpleNotification = ({
2525
content,
2626
icon,
2727
id,
2828
state,
2929
visible,
30-
}) => (
30+
}: SimpleNotificationProps) => (
3131
<>
3232
<Transition
3333
as={Fragment}

src/components/UserAdminForm/UserAdminForm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import type { UpdateUserInput } from 'types/graphql/globalTypes';
1616

1717
export type UserAdminFormProps = Pick<User, 'id'>;
1818

19-
const UserAdminForm: React.FC<UserAdminFormProps> = ({ id }) => {
19+
const UserAdminForm = ({
20+
id,
21+
}: UserAdminFormProps): React.ReactElement | null => {
2022
const { data, loading: queryLoading } = useQuery<GetUserForAdmin>(
2123
getUserForAdminQuery,
2224
{ variables: { id } }

src/components/UserAvatar/UserAvatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface AvatarProps {
77
size?: [number, number];
88
}
99

10-
const Avatar: React.FC<AvatarProps> = ({ image, name, size }) => (
10+
const Avatar = ({ image, name, size }: AvatarProps): React.ReactElement => (
1111
<span className="flex items-center justify-between min-w-0 space-x-3">
1212
{image ? (
1313
<Image

src/components/UserGeneralSettingsForm/UserGeneralSettingsForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { GetMe } from 'types/graphql/GetMe';
1313
import type { UpdateUser } from 'types/graphql/UpdateUser';
1414
import type { UpdateMeInput } from 'types/graphql/globalTypes';
1515

16-
const UserSettingsForm: React.FC = () => {
16+
const UserSettingsForm = (): React.ReactElement | null => {
1717
const { data, loading: queryLoading } = useQuery<GetMe>(meQuery);
1818
const [updateUserSettings, { loading: mutationLoading }] =
1919
useMutation<UpdateUser>(updateMeMutation);

src/components/UserProfileDropdown/UserProfileDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React, { Fragment } from 'react';
77
import ActiveLink from 'src/components/ActiveLink';
88
import { ACCOUNT_SETTINGS, ADMIN_LOGIN } from 'src/routes';
99

10-
const AccountDropdown: React.FC = () => (
10+
const AccountDropdown = (): React.ReactElement => (
1111
<Menu as="div" className="relative ml-3">
1212
{({ open }) => (
1313
<>

src/layouts/AdminLayout/AdminLayout.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,46 @@ import Sidebar from './Sidebar';
88

99
import type { AuthChildProps } from 'src/components/Auth';
1010

11-
export const AdminLayout: React.FC<AuthChildProps> = ({
11+
export interface AdminlayoutProps extends AuthChildProps {
12+
children: React.ReactChild;
13+
}
14+
15+
export const AdminLayout = ({
1216
children,
1317
session,
14-
}) => {
18+
}: AdminlayoutProps): React.ReactElement => {
1519
const [sidebarOpen, setSidebarOpen] = useState(false);
1620
return (
17-
<div className="h-screen flex overflow-hidden bg-white">
21+
<div className="flex h-screen overflow-hidden bg-white">
1822
<Sidebar
1923
handleState={setSidebarOpen}
2024
open={sidebarOpen}
2125
session={session}
2226
/>
2327
{/* Main column */}
24-
<div className="flex flex-col w-0 flex-1 overflow-hidden">
28+
<div className="flex flex-col flex-1 w-0 overflow-hidden">
2529
{/* Search header */}
26-
<div className="relative z-10 flex-shrink-0 flex h-16 bg-white border-b border-gray-200 lg:hidden">
30+
<div className="relative z-10 flex flex-shrink-0 h-16 bg-white border-b border-gray-200 lg:hidden">
2731
<button
28-
className="px-4 border-r border-gray-200 text-gray-500 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-purple-500 lg:hidden"
32+
className="px-4 text-gray-500 border-r border-gray-200 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-purple-500 lg:hidden"
2933
onClick={() => setSidebarOpen(true)}
3034
type="button"
3135
>
3236
<span className="sr-only">Open sidebar</span>
33-
<MenuAlt1Icon aria-hidden="true" className="h-6 w-6" />
37+
<MenuAlt1Icon aria-hidden="true" className="w-6 h-6" />
3438
</button>
35-
<div className="flex-1 flex justify-between px-4 sm:px-6 lg:px-8">
36-
<div className="flex-1 flex">
37-
<form action="#" className="w-full flex md:ml-0" method="GET">
39+
<div className="flex justify-between flex-1 px-4 sm:px-6 lg:px-8">
40+
<div className="flex flex-1">
41+
<form action="#" className="flex w-full md:ml-0" method="GET">
3842
<label className="sr-only" htmlFor="search_field">
3943
Search
4044
</label>
4145
<div className="relative w-full text-gray-400 focus-within:text-gray-600">
4246
<div className="absolute inset-y-0 left-0 flex items-center pointer-events-none">
43-
<SearchIcon aria-hidden="true" className="h-5 w-5" />
47+
<SearchIcon aria-hidden="true" className="w-5 h-5" />
4448
</div>
4549
<input
46-
className="block w-full h-full pl-8 pr-3 py-2 border-transparent text-gray-900 placeholder-gray-500 focus:outline-none focus:ring-0 focus:border-transparent focus:placeholder-gray-400 sm:text-sm"
50+
className="block w-full h-full py-2 pl-8 pr-3 text-gray-900 placeholder-gray-500 border-transparent focus:outline-none focus:ring-0 focus:border-transparent focus:placeholder-gray-400 sm:text-sm"
4751
id="search_field"
4852
name="search_field"
4953
placeholder="Search"

src/layouts/AdminLayout/Sidebar.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ const navigation = [ADMIN_DASHBOARD, ADMIN_USERS, ADMIN_SESSIONS];
2828

2929
const userNavigation = [ACCOUNT_SETTINGS];
3030

31-
const Sidebar: React.FC<SidebarProps> = ({ handleState, open, session }) => {
31+
const Sidebar = ({
32+
handleState,
33+
open,
34+
session,
35+
}: SidebarProps): React.ReactElement => {
3236
// eslint-disable-next-line react-hooks/exhaustive-deps
3337
const filterRoutes = useCallback(filterRoutesForRole(session?.user), [
3438
session,

src/pages/_app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { AppInitialState, useApollo } from 'src/graphql/client';
88

99
import type { Session } from 'next-auth';
1010
import type { AppProps } from 'next/app';
11-
import type { FC, FunctionComponent } from 'react';
11+
import type { FunctionComponent } from 'react';
1212

1313
import '../styles/globals.css';
1414

@@ -27,7 +27,7 @@ export interface MyAppProps extends AppProps {
2727
};
2828
}
2929

30-
const MyApp: FC<MyAppProps> = ({ Component, pageProps }) => {
30+
const MyApp = ({ Component, pageProps }: MyAppProps): React.ReactElement => {
3131
const client = useApollo(pageProps.initialApolloState);
3232
const Layout = Component.layout ?? (({ children }) => <>{children}</>);
3333
return (

src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { signIn, signOut, useSession } from 'next-auth/client';
22
import Head from 'next/head';
33
import React from 'react';
44

5-
const Home: React.FC = () => {
5+
const Home = (): React.ReactElement => {
66
const [session] = useSession();
77

88
return (

src/routes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { isAuthorized } from 'src/utils/auth';
1414

1515
import type { NextPage } from 'next';
1616
import type { ReactNode } from 'react';
17-
import type { AuthProps, AuthSettings } from 'src/components/Auth';
17+
import type { AuthSettings } from 'src/components/Auth';
1818
import type { AuthSessionUser } from 'src/types/next-auth';
1919

2020
export type Url = string;
@@ -26,7 +26,7 @@ export interface AppRoute {
2626
path: Url;
2727
}
2828
export type NextRoutePage<P> = NextPage<P, P> & {
29-
auth?: AuthProps | boolean;
29+
auth?: AuthSettings | boolean;
3030
layout?: ReactNode;
3131
};
3232

0 commit comments

Comments
 (0)