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

wip: address ESLint errors #262

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions components/analytics/graph.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable react/no-unused-prop-types, react/prop-types */

import {
Area,
AreaChart,
Expand Down
2 changes: 1 addition & 1 deletion components/banner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cn from 'classnames';
import { useState } from 'react';
import useTranslation from 'next-translate/useTranslation';
import cn from 'classnames';

import styles from './banner.module.scss';

Expand Down
2 changes: 1 addition & 1 deletion components/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
ButtonProps as MDCButtonProps,
} from '@rmwc/button';
import Link from 'next/link';
import { useMemo } from 'react';
import cn from 'classnames';
import { useMemo } from 'react';

import Arrow from './arrow';
import styles from './button.module.scss';
Expand Down
5 changes: 1 addition & 4 deletions components/calendar/meetings/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ export default function MeetingItem({
const edit = (e: MouseEvent) => {
e.stopPropagation();
if (lastPosition)
mouseMovement += Math.sqrt(
Math.pow(lastPosition.x - e.clientX, 2) +
Math.pow(lastPosition.y - e.clientY, 2)
);
mouseMovement += Math.sqrt(((lastPosition.x - e.clientX) ** 2 + (lastPosition.y - e.clientY) ** 2));
lastPosition = { x: e.clientX, y: e.clientY };
if (mouseMovement > 10) {
removeListeners();
Expand Down
14 changes: 7 additions & 7 deletions components/calendar/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FormEvent, createContext, useContext } from 'react';

import { Callback, CallbackParam } from 'lib/model/callback';
import { Callback } from 'lib/model/callback';
import { Meeting } from 'lib/model/meeting';
import { MeetingsQuery } from 'lib/model/query/meetings';

Expand All @@ -27,15 +27,15 @@ export interface CalendarState {
export const CalendarStateContext = createContext<CalendarState>({
start: new MeetingsQuery().from,
editing: new Meeting(),
setEditing: (param: CallbackParam<Meeting>) => {},
onEditStop: (evt?: FormEvent) => {},
setEditing: () => {},
onEditStop: () => {},
rnd: false,
setRnd: (param: CallbackParam<boolean>) => {},
setRnd: () => {},
dialog: false,
setDialog: (param: CallbackParam<boolean>) => {},
setDialogPage: (param: CallbackParam<DialogPage>) => {},
setDialog: () => {},
setDialogPage: () => {},
dragging: false,
setDragging: (param: CallbackParam<boolean>) => {},
setDragging: () => {},
});

export const useCalendarState = (): CalendarState =>
Expand Down
2 changes: 1 addition & 1 deletion components/carousel/cards.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import Link from 'next/link';
import React from 'react';
import { Ripple } from '@rmwc/ripple';
import cn from 'classnames';

Expand Down
2 changes: 1 addition & 1 deletion components/carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { nanoid } from 'nanoid';
import { useEffect } from 'react';

import { User, UserJSON } from 'lib/model/user';
import { UsersQuery } from 'lib/model/query/users';
import { ListUsersRes } from 'lib/api/routes/users/list';
import { UsersQuery } from 'lib/model/query/users';
import { useOrg } from 'lib/context/org';

import { LoadingCard, UserCard } from './cards';
Expand Down
2 changes: 1 addition & 1 deletion components/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import useTranslation from 'next-translate/useTranslation';
import Avatar from 'components/avatar';
import Button from 'components/button';

import { getEmailLink } from 'lib/utils';
import Link from 'lib/intl/link';
import { Org } from 'lib/model/org';
import { getEmailLink } from 'lib/utils';

import styles from './home.module.scss';

Expand Down
2 changes: 1 addition & 1 deletion components/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Button from 'components/button';

import { APIErrorJSON } from 'lib/model/error';
import getLocation from 'lib/utils/location';
import { period } from 'lib/utils';
import { loginWithGoogle } from 'lib/firebase/login';
import { period } from 'lib/utils';
import useTrack from 'lib/hooks/track';

import styles from './login.module.scss';
Expand Down
6 changes: 3 additions & 3 deletions components/navigation/pop-over.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import AddIcon from 'components/icons/add';
import Avatar from 'components/avatar';
import ContactSupportIcon from 'components/icons/contact-support';

import Intercom from 'lib/intercom';
import { AccountInterface } from 'lib/model/account';
import Intercom from 'lib/intercom';
import Link from 'lib/intl/link';
import { Org } from 'lib/model/org';
import { User } from 'lib/model/user';
import Link from 'lib/intl/link';
import { useTheme } from 'lib/context/theme';
import { useUser } from 'lib/context/user';

Expand Down Expand Up @@ -168,7 +168,7 @@ export default function PopOverMenu({
window.analytics?.reset();
Intercom('shutdown');
Intercom('boot');
}, []);
}, [updateUser]);

return (
<MenuSurfaceAnchor className={styles.anchor}>
Expand Down
2 changes: 0 additions & 2 deletions components/notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import styles from './notification.module.scss';

export interface NotificationProps {
header: string;
intercom?: boolean;
children?: React.ReactNode;
}

export default function Notification({
header,
intercom,
children,
}: NotificationProps): JSX.Element {
return (
Expand Down
4 changes: 2 additions & 2 deletions components/settings/context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext, useContext } from 'react';

import { Callback, CallbackParam } from 'lib/model/callback';
import { Callback } from 'lib/model/callback';
import { Org } from 'lib/model/org';

export interface SettingsContextValue {
Expand All @@ -10,7 +10,7 @@ export interface SettingsContextValue {

export const SettingsContext = createContext<SettingsContextValue>({
org: new Org(),
setOrg: (org: CallbackParam<Org>) => {},
setOrg: () => {},
});

export const useSettings = () =>
Expand Down
2 changes: 1 addition & 1 deletion components/settings/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import PhotoInput from 'components/photo-input';

import { Org } from 'lib/model/org';

import { useSettings } from './context';
import styles from './settings.module.scss';
import { useSettings } from './context';

export default function Home(): JSX.Element {
const { t, lang: locale } = useTranslation();
Expand Down
8 changes: 4 additions & 4 deletions components/time-select/select-surface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@ function SelectSurface({
uid ? `/api/users/${uid}/availability?month=${month}&year=${year}` : null
);
const full = useMemo(() => {
const full = new Availability();
const fill = new Availability();
const days = Array(7).fill(null);
days.forEach((_, day) => {
full.push(new Timeslot({ from: getDate(day, 0), to: getDate(day, 24) }));
fill.push(new Timeslot({ from: getDate(day, 0), to: getDate(day, 24) }));
});
return getMonthsTimeslots(full, month, year);
return getMonthsTimeslots(fill, month, year);
}, [month, year]);
const availability = useMemo(() => {
// TODO: Shouldn't I make this empty by default? Not filled?
const base = data ? Availability.fromJSON(data) : full;
return new Availability(...base.filter((t) => t.from > now));
}, [data, month, year, now, full]);
}, [data, now, full]);
const availabilityOnSelected = useMemo(() => availability.onDate(selected), [
selected,
availability,
Expand Down
14 changes: 0 additions & 14 deletions lib/api/get/rand-background.ts

This file was deleted.

6 changes: 3 additions & 3 deletions pages/[org]/users/[id]/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ export const getStaticProps: GetStaticProps<
> = async (ctx: GetStaticPropsContext<UserEditPageQuery>) => {
if (!ctx.params) throw new Error('Cannot fetch org and user w/out params.');
try {
const [org, user] = await Promise.all([
const [org, usr] = await Promise.all([
getOrg(ctx.params.org),
getUser(ctx.params.id),
]);
const { props } = await getPageProps();
return {
props: { org: org.toJSON(), user: user.toJSON(), ...props },
props: { org: org.toJSON(), user: usr.toJSON(), ...props },
revalidate: 1,
};
} catch (e) {
Expand All @@ -88,7 +88,7 @@ export const getStaticProps: GetStaticProps<
// TODO: We want to statically generate skeleton loading pages for each org.
// @see {@link https://github.com/vercel/next.js/issues/14200}
// @see {@link https://github.com/vercel/next.js/discussions/14486}
export const getStaticPaths: GetStaticPaths<UserEditPageQuery> = async () => ({
export const getStaticPaths: GetStaticPaths<UserEditPageQuery> = () => ({
paths: [],
fallback: true,
});
Expand Down
8 changes: 4 additions & 4 deletions pages/[org]/users/[id]/hours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useRouter } from 'next/router';
import useSWR from 'swr';

import Page from 'components/page';
import { TabHeader } from 'components/navigation';
import Hours from 'components/user/hours';
import { TabHeader } from 'components/navigation';

import { Org, OrgJSON } from 'lib/model/org';
import { PageProps, getPageProps } from 'lib/page';
Expand Down Expand Up @@ -83,13 +83,13 @@ export const getStaticProps: GetStaticProps<
> = async (ctx: GetStaticPropsContext<UserHoursPageQuery>) => {
if (!ctx.params) throw new Error('Cannot fetch org and user w/out params.');
try {
const [org, user] = await Promise.all([
const [org, usr] = await Promise.all([
getOrg(ctx.params.org),
getUser(ctx.params.id),
]);
const { props } = await getPageProps();
return {
props: { org: org.toJSON(), user: user.toJSON(), ...props },
props: { org: org.toJSON(), user: usr.toJSON(), ...props },
revalidate: 1,
};
} catch (e) {
Expand All @@ -100,7 +100,7 @@ export const getStaticProps: GetStaticProps<
// TODO: We want to statically generate skeleton loading pages for each org.
// @see {@link https://github.com/vercel/next.js/issues/14200}
// @see {@link https://github.com/vercel/next.js/discussions/14486}
export const getStaticPaths: GetStaticPaths<UserHoursPageQuery> = async () => ({
export const getStaticPaths: GetStaticPaths<UserHoursPageQuery> = () => ({
paths: [],
fallback: true,
});
Expand Down
2 changes: 1 addition & 1 deletion pages/[org]/users/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,6 @@ export const getStaticProps: GetStaticProps<
};

export const getStaticPaths: GetStaticPaths<UserDisplayPageQuery> =
async () => ({ paths: [], fallback: true });
() => ({ paths: [], fallback: true });

export default withI18n(UserDisplayPage, { common, error, match3rd, user3rd });
6 changes: 3 additions & 3 deletions pages/[org]/users/[id]/vet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ export const getStaticProps: GetStaticProps<
> = async (ctx: GetStaticPropsContext<UserVetPageQuery>) => {
if (!ctx.params) throw new Error('Cannot fetch org and user w/out params.');
try {
const [org, user] = await Promise.all([
const [org, usr] = await Promise.all([
getOrg(ctx.params.org),
getUser(ctx.params.id),
]);
const { props } = await getPageProps();
return {
props: { org: org.toJSON(), user: user.toJSON(), ...props },
props: { org: org.toJSON(), user: usr.toJSON(), ...props },
revalidate: 1,
};
} catch (e) {
Expand All @@ -88,7 +88,7 @@ export const getStaticProps: GetStaticProps<
// TODO: We want to statically generate skeleton loading pages for each org.
// @see {@link https://github.com/vercel/next.js/issues/14200}
// @see {@link https://github.com/vercel/next.js/discussions/14486}
export const getStaticPaths: GetStaticPaths<UserVetPageQuery> = async () => ({
export const getStaticPaths: GetStaticPaths<UserVetPageQuery> = () => ({
paths: [],
fallback: true,
});
Expand Down
4 changes: 2 additions & 2 deletions pages/[org]/users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { withI18n } from 'lib/intl';

import common from 'locales/en/common.json';
import query from 'locales/en/query.json';
import user from 'locales/en/user.json';
import users from 'locales/en/users.json';
import request from 'locales/en/request.json';
import search from 'locales/en/search.json';
import user from 'locales/en/user.json';
import users from 'locales/en/users.json';

function UsersPage(props: PageProps): JSX.Element {
const { orgs } = useUser();
Expand Down
2 changes: 1 addition & 1 deletion pages/api/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { serialize } from 'cookie';
* GET - Logs the user out by removing the HttpOnly authentication cookie and
* redirecting to the login page.
*/
export default async function logout(req: Req, res: Res): Promise<void> {
export default function logout(req: Req, res: Res): void {
if (req.method !== 'GET') {
res.setHeader('Allow', ['GET']);
res.status(405).end(`Method ${req.method as string} Not Allowed`);
Expand Down
2 changes: 1 addition & 1 deletion pages/api/orgs/[id]/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { APIError } from 'lib/model/error';
import fetchOrg, { FetchOrgRes } from 'lib/api/routes/orgs/fetch';
import updateOrg, { UpdateOrgRes } from 'lib/api/routes/orgs/update';
import { APIError } from 'lib/model/error';

/**
* GET - Fetches the org's profile document.
Expand Down