Skip to content

Commit

Permalink
cleaned up deprecated linting rules, fixed a bunch of minor linting w…
Browse files Browse the repository at this point in the history
…arnings
  • Loading branch information
qiandrewj committed Sep 22, 2024
1 parent f315c20 commit d2a647a
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 56 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,24 @@
"sourceType": "module"
},
"rules": {
"camelcase": "warn",
"camelcase": "off",
"explicit-function-return-type": "off",
"no-empty-function": "warn",
"import/prefer-default-export": "off",
"consistent-return": "warn",
"guard-for-in": "warn",
"import/extensions": "off",
"max-len": ["warn", 160],
"new-cap": "warn",
"quotes": "off",
"no-await-in-loop": "warn",
"no-continue": "off",
"no-nested-ternary": "off",
"no-plusplus": "off",
"no-prototype-builtins": "warn",
"no-return-await": "off",
"no-shadow": "warn",
"no-underscore-dangle": "off",
"no-unused-vars": "warn",
"no-undef": "warn",
"no-var": "error",
"object-curly-newline": "off",
"react/prop-types": "warn",
"react/no-string-refs": "warn",
"react/no-deprecated": "warn"
Expand Down
6 changes: 3 additions & 3 deletions client/src/auth/auth_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export function useAuthMandatoryLogin(redirectFrom: string): {
history.push('/login')
}

const token = getAuthToken()
const authToken = getAuthToken()

if (!token || token === '') {
if (!authToken || authToken === '') {
signIn(redirectFrom)
} else {
axios
Expand All @@ -88,7 +88,7 @@ export function useAuthMandatoryLogin(redirectFrom: string): {
.catch((e) => console.log(e.response))
}

setToken(token)
setToken(authToken)
setIsAuthenticating(false)
setIsLoggedIn(true)
}, [redirectFrom, history])

Check warning on line 94 in client/src/auth/auth_utils.ts

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has a missing dependency: 'token'. Either include it or remove the dependency array
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/Admin/Components/AdminReview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'
import React, { useState } from 'react'
import axios from 'axios'
import styles from '../Styles/AdminReview.module.css'

Expand Down
3 changes: 1 addition & 2 deletions client/src/modules/Admin/Components/AdminUser.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useEffect, useState } from 'react'
import axios from 'axios'
import React from 'react'
import styles from '../Styles/AdminUser.module.css'

type Props = {
Expand Down
1 change: 0 additions & 1 deletion client/src/modules/Admin/Components/Stats.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useState } from 'react'
import axios from 'axios'
import styles from '../Styles/Stats.module.css'
import { Review } from 'common'

type StatsProps = {
token: string
Expand Down
8 changes: 4 additions & 4 deletions client/src/modules/AuthRedirect/Components/AuthRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ Saves Google ID Token from URL parameters when Google redirects user back to thi

export const AuthRedirect = ({location}: Props) => {

const google_hash = location.hash
if (google_hash !== '') {
const google_token = google_hash
const googleHash = location.hash
if (googleHash !== '') {
const googleToken = googleHash
.match(/(?=id_token=)([^&]+)/)![0]
.split('=')[1]
setAuthToken(google_token)
setAuthToken(googleToken)
}

if (Session.get('redirectFrom') === 'course') {
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/Course/Components/CourseReviews.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react'
import axios from 'axios'
import { toast, ToastContainer } from 'react-toastify'
import { toast } from 'react-toastify'
import 'react-toastify/dist/ReactToastify.css'

import ReviewCard from './ReviewCard'
Expand Down
4 changes: 2 additions & 2 deletions client/src/modules/Course/Components/Feedback.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* globals gtag */
export function courseVisited(classSub, classNum) {
gtag('event', 'Course Visited', {
event_category: 'Courses Visited',
event_label: classSub + classNum,
eventCategory: 'Courses Visited',
eventLabel: classSub + classNum,
})
}
10 changes: 5 additions & 5 deletions client/src/modules/Course/Components/PreviewReviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function PreviewReviewCard({
review,
isPreview,
isProfile,
}: ReviewProps): JSX.Element {
}: ReviewProps): React.JSX.Element {
const { isLoggedIn } = useAuthOptionalLogin()
const pending = isPreview && isProfile

Expand All @@ -55,11 +55,11 @@ export default function PreviewReviewCard({
if (!_review.date) return ''

const date = new Date(_review.date)
let review_year = String(date.getFullYear()).substring(2)
let review_month = date.getMonth() + 1
let review_day = date.getDate()
let reviewYear = String(date.getFullYear()).substring(2)
let reviewMonth = date.getMonth() + 1
let reviewDay = date.getDate()

return review_month + '/' + review_day + '/' + review_year
return reviewMonth + '/' + reviewDay + '/' + reviewYear
}

/**
Expand Down
12 changes: 6 additions & 6 deletions client/src/modules/Home/Components/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ export const Home = () => {

/** Logic for deciding the home pages' background image */
function setBackground() {
const sunset_start_times = [
const sunsetStartTimes = [
17.0, 17.5, 18, 19.5, 20, 20.5, 20.5, 19.5, 18.5, 18, 16.5, 16.5,
]
const sunset_end_times = [
const sunsetEndTimes = [
18.5, 19, 20.5, 21, 22, 22, 22, 21.5, 20.5, 20, 19, 18,
]
const date = new Date()
const month = date.getMonth()
const hours = date.getHours()
const minutes = date.getMinutes()

let time_of_day = hours
let timeOfDay = hours
if (minutes > 30) {
time_of_day += 0.51
timeOfDay += 0.51
}
if (month === 11 || month === 0 || month === 1) {
setSeason('winter')
Expand All @@ -54,9 +54,9 @@ export const Home = () => {
setSeason('fall')
}

if (time_of_day < 6 || time_of_day >= sunset_end_times[month]) {
if (timeOfDay < 6 || timeOfDay >= sunsetStartTimes[month]) {
setTime('night')
} else if (time_of_day >= sunset_start_times[month]) {
} else if (timeOfDay >= sunsetEndTimes[month]) {
setTime('sunset')
}
}
Expand Down
6 changes: 0 additions & 6 deletions client/src/modules/Results/Components/FilteredResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ type Props = {
sortBy: 'rating' | 'relevance' | 'diff' | 'work'
}

type State = {
course: Class
current_index: number
sortBy: string
}

/**
Filtered Result Component.
Expand Down
32 changes: 16 additions & 16 deletions client/src/modules/Results/Components/ResultsDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default class ResultsDisplay extends Component {
super(props)
this.state = {
courseList: this.props.courses,
card_course: this.props.courses[0],
active_card: 0,
cardCourse: this.props.courses[0],
activeCard: 0,
selected: props.type === 'major' ? 'rating' : 'relevance',
filters: {
Fall: true,
Expand Down Expand Up @@ -65,7 +65,7 @@ export default class ResultsDisplay extends Component {
{
courseList: this.props.courses,
relevantCourseList: this.props.courses,
card_course: this.props.courses[0],
cardCourse: this.props.courses[0],
},
() => this.filterClasses()
)
Expand Down Expand Up @@ -124,8 +124,8 @@ export default class ResultsDisplay extends Component {
})
this.setState({
filteredItems: courseList,
card_course: courseList[0],
active_card: 0,
cardCourse: courseList[0],
activeCard: 0,
})
}

Expand Down Expand Up @@ -183,12 +183,12 @@ export default class ResultsDisplay extends Component {
)
)

let subjects_objects = this.state.filterMap.get('subjects')
if (subjects_objects && subjects_objects.length > 0) {
let subjectsObjects = this.state.filterMap.get('subjects')
if (subjectsObjects && subjectsObjects.length > 0) {
filteredItems = filteredItems.filter((course) =>
subjects_objects.some(
(subject_object) =>
course.classSub.toUpperCase() === subject_object.value
subjectsObjects.some(
(subjectObject) =>
course.classSub.toUpperCase() === subjectObject.value
)
)
}
Expand All @@ -213,8 +213,8 @@ export default class ResultsDisplay extends Component {
//if the course's [index] in the list of FilteredResult components is clicked
previewHandler(course, index) {
this.setState({
card_course: course,
active_card: index,
cardCourse: course,
activeCard: index,
})
this.setState({ transformGauges: false })
}
Expand Down Expand Up @@ -250,7 +250,7 @@ export default class ResultsDisplay extends Component {
<FilteredResult
key={index}
index={index}
selected={index === this.state.active_card}
selected={index === this.state.activeCard}
course={result}
previewHandler={this.previewHandler}
sortBy={this.state.selected}
Expand All @@ -260,8 +260,8 @@ export default class ResultsDisplay extends Component {
}

renderCheckboxes(group) {
let group_list = Array.from(this.state.filterMap.get(group).keys())
return group_list.map((name, index) => (
let groupList = Array.from(this.state.filterMap.get(group).keys())
return groupList.map((name, index) => (
<div className = {styles.filterlabel}>
<label className={styles.filterlabel}>
<input
Expand Down Expand Up @@ -402,7 +402,7 @@ export default class ResultsDisplay extends Component {
</div>
<div className={styles.preview}>
<PreviewCard
course={this.state.card_course}
course={this.state.cardCourse}
transformGauges = {this.state.transformGauges} />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import React from 'react'
import '../Styles/Course.css'
import { Redirect } from 'react-router'
import { Professor } from 'common'
Expand Down
2 changes: 0 additions & 2 deletions client/src/modules/SearchBar/Components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ export const SearchBar = ({
const renderResults = () => {
/** Only render if the query is not empty */
if (query !== '' && !selected) {
let results = []

/* User press [ENTER] button?
=> Redirect user to '/results/keyword/query+query'
*/
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/SearchBar/Components/SubjectResult.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import React from 'react'
import '../Styles/Course.css'
import { Redirect } from 'react-router'
import { Subject } from 'common'
Expand Down

0 comments on commit d2a647a

Please sign in to comment.