Skip to content

Commit

Permalink
Remove unused imports and variables and fix other linter warnings (#513)
Browse files Browse the repository at this point in the history
Closes #510
* delete a lot of unused imports and unused variables
* delete one unused file
* add an alt text
* change a == to a ===
* add a couple things to .gitignore
  • Loading branch information
Gabe-Mitnick authored Sep 24, 2022
1 parent 84b34ba commit c8c7897
Show file tree
Hide file tree
Showing 21 changed files with 13 additions and 76 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ build/docker-compose.yml
config.statuspage.json
*.cert
*.key
db/
mdb.archive
5 changes: 1 addition & 4 deletions frontend/src/components/Common/Banner.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC } from 'react'
import { connect, ConnectedProps } from 'react-redux'
// import { Button } from 'react-bootstrap'
import { useLocation, useHistory } from 'react-router-dom'
import { useHistory } from 'react-router-dom'
import { Button } from 'bt/custom';
import { ReduxState } from '../../redux/store'
import { closeBanner } from '../../redux/common/actions'
Expand All @@ -11,9 +11,7 @@ import close from '../../assets/svg/common/close.svg'
interface Props extends PropsFromRedux {}

const Banner: FC<Props> = (props) => {
const location = useLocation();
const history = useHistory();

function redirect(site: string) {
history.push("/redirect?site=" + site)
}
Expand Down Expand Up @@ -42,4 +40,3 @@ const connector = connect(mapState, mapDispatch)
type PropsFromRedux = ConnectedProps<typeof connector>

export default connector(Banner)

2 changes: 0 additions & 2 deletions frontend/src/components/Common/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React, { FC } from 'react';
import { Container, Row, Col } from 'react-bootstrap';
import { H6, A } from 'bt/custom';

const New: FC = () => <span className="footer-new ml-1">New</span>;

const Footer: FC = () => (
<footer className="py-5">
<Container>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/Login/LoginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Nav } from 'react-bootstrap';
import btn_google_signin from 'assets/svg/profile/btn_google_signin.svg';
import { ReactComponent as GoogleIcon } from '../../assets/svg/profile/google.svg';

type Props = {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/Login/LoginModal.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Component } from 'react';
import { Modal } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import LoginButton from './LoginButton';
import { H3, P } from 'bt/custom';
import close from 'assets/svg/common/close.svg';
Expand All @@ -10,7 +9,7 @@ export class LoginModal extends Component {
return (
<Modal show={this.props.showLogin} onHide={this.props.hideLogin} className="login">
<button className="link-btn back-btn" onClick={this.props.hideLogin}>
<img src={close} />
<img src={close} alt="close"/>
</button>
<H3 bold className="mb-2">Welcome to Berkeleytime</H3>
<P className="login-text">
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/Profile/AccountSubview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useState } from 'react';

import Property from './Property';
import ProfileCourseCard from './ProfileCourseCard';
import EditPencil from '../../assets/svg/profile/edit.svg';
import {
CourseOverviewFragment,
ScheduleOverviewFragment,
Expand All @@ -11,7 +10,6 @@ import {

import MAJORS from './majors.json';
import { useUpdateUser } from '../../graphql/hooks/user';
import { useUnsaveCourse } from '../../graphql/hooks/saveCourse';
import { compareDepartmentName } from 'utils/courses/sorting';
import { Button } from 'react-bootstrap';
import Subview from './Subview';
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/Profile/ProfileCourseCard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React from 'react';
import {
formatUnits,
formatPercentage,
applyIndicatorPercent,
applyIndicatorGrade,
} from '../../utils/utils';
import { CourseOverviewFragment } from '../../graphql/graphql';
import { useUnsaveCourse } from 'graphql/hooks/saveCourse';
import { Link } from 'react-router-dom';
import TrashButton from 'components/Common/TrashButton';
import ProfileCard from './ProfileCard';

type Props = {
Expand Down
9 changes: 0 additions & 9 deletions frontend/src/components/Profile/ProfileScheduleCard.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import React, { useState } from 'react';
import {
formatUnits,
applyIndicatorPercent,
applyIndicatorGrade,
} from '../../utils/utils';
import {
CourseOverviewFragment,
ScheduleOverviewFragment,
} from '../../graphql/graphql';
import { ReactComponent as Trash } from '../../assets/svg/profile/trash.svg';
import { Button } from 'react-bootstrap';
import { useUnsaveCourse } from 'graphql/hooks/saveCourse';
import { Link } from 'react-router-dom';
import { semesterToString } from 'utils/playlists/semesters';
import ScheduleModal from 'components/Scheduler/ScheduleModal';
import { useDeleteSchedule } from 'graphql/hooks/schedule';
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/Scheduler/CourseSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BTSelect from 'components/Custom/Select';
import { CourseOverviewFragment } from 'graphql/graphql';
import React, { Dispatch, SetStateAction, useMemo } from 'react';
import React, { useMemo } from 'react';
import { courseToName } from 'utils/courses/course';
import { reactSelectCourseSearch } from 'utils/courses/search';
import { compareDepartmentName } from 'utils/courses/sorting';
Expand All @@ -13,7 +13,6 @@ import {
SchedulerCourseType,
SchedulerSectionType,
} from 'utils/scheduler/scheduler';
import Callout from './Callout';
import SchedulerCourse from './Selector/SchedulerCourse';
import { ScheduleContext } from './ScheduleContext';
import { unitsToString } from 'utils/courses/units';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const RemoteScheduler = ({ scheduleId, schedule, setRawSchedule }: Props) => {

const [
getScheduleForId,
{ loading: isLoadingSchedule, error: scheduleLoadError },
{ error: scheduleLoadError },
] = useGetScheduleForIdLazyQuery({
onCompleted: (data) => {
if (!data.schedule) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Props = {
};

const SelectClasses = ({ schedule, setSchedule }: Props) => {
const { isLoggedIn, user, loading } = useUser();
const { user } = useUser();

const savedClasses = ((user && user.savedClasses) || [])
.filter((c): c is CourseOverviewFragment => c !== null)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Scheduler/Onboard/Welcome.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Container, Row, Col, ButtonToolbar } from 'react-bootstrap';
import { Container, Row, Col } from 'react-bootstrap';
import { useUser } from '../../../graphql/hooks/user';
import ProfileScheduleCard from './../../Profile/ProfileScheduleCard';
import { getNodes } from 'utils/graphql';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Scheduler/ScheduleContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createContext, Dispatch, SetStateAction, useContext } from 'react';
import { createContext, useContext } from 'react';
import { Schedule, SchedulerSectionType } from 'utils/scheduler/scheduler';

type ContextType = {
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/graphql/hooks/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import {
FetchResult,
LazyQueryHookOptions,
LazyQueryResult,
MutationFunction,
MutationHookOptions,
MutationResult,
MutationTuple,
QueryTuple,
useMutation,
} from '@apollo/client';
import { useCallback } from 'react';

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/utils/date.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CalendarOptions, ICalendar, ICSPropertyValue } from 'datebook';
import { floorMod } from './number';

/**
* Converts time string to date
Expand Down Expand Up @@ -106,7 +105,7 @@ export function timeToHourString(time: number): string {

if (time < 12) {
return `${floorModTime}am`;
} else if (time == 12) {
} else if (time === 12) {
return `12pm`;
} else {
return `${floorModTime % 12}pm`;
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/utils/playlists/playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ const SEMESTER_TYPE_TO_OFFSET: { [key: string]: number } = {
fall: 0.2,
};

// Higher = appear further behind
const PLAYLIST_CATEGORY_TO_ORDER: { [key: string]: number } = {
units: 2.0,
};

/**
* Converts a playlist to a quantifiable year value. Greater = newer
*/
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/utils/scheduler/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ import {
addWeeks,
isBefore,
min,
nextDay,
setDay,
subDays,
subWeeks,
} from 'date-fns';

// Update the version when the scheduler schema changes.
Expand Down
30 changes: 0 additions & 30 deletions frontend/src/views/LoginModal.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/views/Profile/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ComponentType, ReactNode, useState } from 'react';
import { Container, Row, Col, Button } from 'react-bootstrap';
import { Container, Button } from 'react-bootstrap';

import AccountSubview from '../../components/Profile/AccountSubview';
import NotificationsSubview from '../../components/Profile/NotificationsSubview';
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/views/RedirectLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import { FC } from 'react'
import { useHistory, useLocation } from 'react-router-dom';

// We must have an allowlist of redirects to prevent an attacker from arbitrarily opening external sites.
Expand All @@ -19,4 +19,3 @@ const RedirectLink: FC = () => {
}

export default RedirectLink

4 changes: 1 addition & 3 deletions frontend/src/views/Scheduler/LocalSchedulerPage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React, { Dispatch, SetStateAction } from 'react';
import React from 'react';
import { Button, OverlayTrigger, Tooltip } from 'react-bootstrap';

import { CourseOverviewFragment } from '../../graphql/graphql';
import BTLoader from 'components/Common/BTLoader';
import {
DEFAULT_SCHEDULE,
Schedule,
SCHEDULER_LOCALSTORAGE_KEY,
} from 'utils/scheduler/scheduler';
import { Semester } from 'utils/playlists/semesters';
import { useUser } from 'graphql/hooks/user';
import { useCreateSchedule } from 'graphql/hooks/schedule';
import { useLocalStorageState } from 'utils/hooks';
Expand Down

0 comments on commit c8c7897

Please sign in to comment.