diff --git a/backend/controllers/configurations.js b/backend/controllers/configurations.js index 05a320c..2df9d06 100644 --- a/backend/controllers/configurations.js +++ b/backend/controllers/configurations.js @@ -220,9 +220,11 @@ configurationsRouter.delete( const success = await db.Configuration.destroy({ where: { id: req.params.configurationId }, }) - success - ? console.log(`Configuration ${req.params.configurationId} destroyed.`) - : console.log('Nothing to delete.') + if (success) { + console.log(`Configuration ${req.params.configurationId} destroyed.`) + } else { + console.log('Nothing to delete.') + } return res.status(204).end() } ) diff --git a/backend/controllers/email.js b/backend/controllers/email.js index c24fdff..087c68b 100644 --- a/backend/controllers/email.js +++ b/backend/controllers/email.js @@ -242,7 +242,7 @@ emailRouter.get('/templates', checkAdmin, async (req, res) => { const payload = templates.length > 0 ? templates[0] : defaultEmailTemplates return res.json(serializeTemplatesByLanguage(payload)) - } catch (err) { + } catch { res.status(500).json({ error: 'Something is wrong... try reloading the page' }) } }) @@ -281,7 +281,7 @@ const parseTemplates = (req, res, next) => { templates: deserialized } next() - } catch (e) { + } catch { res.status(500).json({ error: 'internal server error' }) } } @@ -311,7 +311,7 @@ emailRouter.post( customer_review_link_eng }) res.status(200).json(serializeTemplatesByLanguage(createdTemplates)) - } catch (e) { + } catch { res.status(500).json({ error: 'Something is wrong... try reloading the page' }) } } diff --git a/backend/controllers/groups.js b/backend/controllers/groups.js index 1c11a1c..019cffe 100644 --- a/backend/controllers/groups.js +++ b/backend/controllers/groups.js @@ -283,9 +283,11 @@ router.put('/:groupId', checkAdmin, async (req, res) => { router.delete('/:groupId', checkAdmin, async (req, res) => { const success = await db.Group.destroy({ where: { id: req.params.groupId } }) - success - ? console.log(`Group ${req.params.groupId} destroyed.`) - : console.log('Nothing to delete.') + if (success) { + console.log(`Group ${req.params.groupId} destroyed.`) + } else { + console.log('Nothing to delete.') + } return res.status(204).end() }) diff --git a/backend/controllers/instructorTimeLogs.js b/backend/controllers/instructorTimeLogs.js index 1cc6326..1332105 100644 --- a/backend/controllers/instructorTimeLogs.js +++ b/backend/controllers/instructorTimeLogs.js @@ -75,7 +75,7 @@ instructorTimeLogsRouter.get('/', checkInstructor, async (req, res) => { try { const timeLogs = await fetchAllFromDb() return res.status(200).json(timeLogs) - } catch (error) { + } catch { return res.status(500).json({ error: 'Error fetching time logs.' }) } }) diff --git a/backend/controllers/timeLogs.js b/backend/controllers/timeLogs.js index 62a5335..4d861b3 100644 --- a/backend/controllers/timeLogs.js +++ b/backend/controllers/timeLogs.js @@ -178,7 +178,7 @@ timeLogsRouter.get('/', checkLogin, async (req, res) => { const user_id = req.user.id const timeLogs = user_id ? await fetchFromDb(user_id) : [] return res.status(200).json(timeLogs) - } catch (error) { + } catch { return res.status(500).json({ error: 'Error fetching time logs.' }) } }) diff --git a/backend/index.js b/backend/index.js index 2489089..563af52 100644 --- a/backend/index.js +++ b/backend/index.js @@ -33,7 +33,7 @@ const shibbolethHeaders = [ app.use(cors()) app.use(bodyParser.json({ limit: '100mb' })) app.use(headersMiddleware(shibbolethHeaders)) -isDevelopmentEnvironment() && app.use(fakeshibbo) +if (isDevelopmentEnvironment()) app.use(fakeshibbo) app.use(unless('/api/login', logger)) // Routers diff --git a/frontend/.oxlintrc.json b/frontend/.oxlintrc.json index 9a7d3f8..8c0fc98 100644 --- a/frontend/.oxlintrc.json +++ b/frontend/.oxlintrc.json @@ -16,5 +16,13 @@ "rules": { "eqeqeq": "error", "react-hooks/exhaustive-deps": "warn" - } + }, + "overrides": [ + { + "files": ["src/components/RegistrationDetailsPage.jsx"], + "rules": { + "react/no-did-mount-set-state": "warn" + } + } + ] } \ No newline at end of file diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 32fe54c..d683d96 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -116,8 +116,8 @@ const App = (props) => { const fetchData = async () => { updateIsLoading(true) - !isCustomerReviewPage && (await handleLogin()) - user && (await handleGroupInit()) + if (!isCustomerReviewPage) await handleLogin() + if (user) await handleGroupInit() await fetchRegistrationManagementData() updateIsLoading(false) } diff --git a/frontend/src/components/AdminSprintsPage/AdminSprintsPage.jsx b/frontend/src/components/AdminSprintsPage/AdminSprintsPage.jsx index 33575d1..524157e 100644 --- a/frontend/src/components/AdminSprintsPage/AdminSprintsPage.jsx +++ b/frontend/src/components/AdminSprintsPage/AdminSprintsPage.jsx @@ -97,7 +97,7 @@ const AdminSprintsPage = (props) => { await fetchSprints(selectedGroupId) setIsLoading(false) } - selectedGroup?.id && fetchData(selectedGroup.id) + if (selectedGroup?.id) fetchData(selectedGroup.id) }, [selectedGroup, selectedConfiguration]) diff --git a/frontend/src/components/EmailTemplatesPage/EmailTemplatesPage.jsx b/frontend/src/components/EmailTemplatesPage/EmailTemplatesPage.jsx index 132942c..43d3abc 100644 --- a/frontend/src/components/EmailTemplatesPage/EmailTemplatesPage.jsx +++ b/frontend/src/components/EmailTemplatesPage/EmailTemplatesPage.jsx @@ -27,7 +27,7 @@ class EmailTemplatesPage extends React.Component { try { await this.props.updateEmailTemplates(newTemplates) this.props.setSuccess('Email templates saved!') - } catch (e) { + } catch { this.props.setError('Failed to update email templates') } } diff --git a/frontend/src/components/GroupManagementPage/GroupManagementPage.jsx b/frontend/src/components/GroupManagementPage/GroupManagementPage.jsx index 3c1f317..88f0feb 100644 --- a/frontend/src/components/GroupManagementPage/GroupManagementPage.jsx +++ b/frontend/src/components/GroupManagementPage/GroupManagementPage.jsx @@ -37,7 +37,7 @@ const GroupManagementPage = (props) => { setUsers(fetchedUsers) setGroups(fetchedGroups) await fetchTopics() - } catch (err) { + } catch { setError('Some error happened') } } diff --git a/frontend/src/components/InstructorReviewPage.jsx b/frontend/src/components/InstructorReviewPage.jsx index 2468027..e26a42f 100644 --- a/frontend/src/components/InstructorReviewPage.jsx +++ b/frontend/src/components/InstructorReviewPage.jsx @@ -311,7 +311,7 @@ const Review = ({ student, updateAnswer, index }) => { const Reviews = ({ answerSheet, updateAnswer }) => { return answerSheet.map((student, index) => { return ( - + ) }) } diff --git a/frontend/src/components/PeerReviewPage.jsx b/frontend/src/components/PeerReviewPage.jsx index d900e56..f6cbc59 100644 --- a/frontend/src/components/PeerReviewPage.jsx +++ b/frontend/src/components/PeerReviewPage.jsx @@ -19,7 +19,13 @@ import timeLogService from '../services/timeLogs' import TextField from '@material-ui/core/TextField' import Button from '@material-ui/core/Button' -import { Table, TableHead, TableRow, TableBody, TableCell } from '@material-ui/core' +import { + Table, + TableHead, + TableRow, + TableBody, + TableCell, +} from '@material-ui/core' class PeerReview extends React.Component { async componentDidMount() { @@ -264,7 +270,7 @@ const Question = ({ updateAnswer, updatePeerReview, }) => { - if (!questionId === undefined) { + if (!questionId) { console.error('No questionId given') return (
@@ -281,10 +287,7 @@ const Question = ({ return (

{question.header}

- +
diff --git a/frontend/src/components/QuestionSetForm.jsx b/frontend/src/components/QuestionSetForm.jsx index 4c9b451..8bda75f 100644 --- a/frontend/src/components/QuestionSetForm.jsx +++ b/frontend/src/components/QuestionSetForm.jsx @@ -9,7 +9,7 @@ const validateQuestionsJson = (str) => { return { ok: false, error: 'Questions should be an array' } } return { ok: true } - } catch (err) { + } catch { return { ok: false, error: 'Field contains invalid JSON' } } } diff --git a/frontend/src/components/TagPage/StudentTagPage.jsx b/frontend/src/components/TagPage/StudentTagPage.jsx index e1a4248..7559491 100644 --- a/frontend/src/components/TagPage/StudentTagPage.jsx +++ b/frontend/src/components/TagPage/StudentTagPage.jsx @@ -70,7 +70,7 @@ const StudentTagPage = (props) => { const fetchData = async () => { setIsLoading(true) - group?.id && (await fetchSprints()) + if (group?.id) await fetchSprints() await tagService.getTagsByStudent(user.studentNumber).then((data) => { setStudentTags(data) }) diff --git a/frontend/src/components/TimeLogsPage/InstructorTimeLogsPage.jsx b/frontend/src/components/TimeLogsPage/InstructorTimeLogsPage.jsx index 407466d..f6fcd63 100644 --- a/frontend/src/components/TimeLogsPage/InstructorTimeLogsPage.jsx +++ b/frontend/src/components/TimeLogsPage/InstructorTimeLogsPage.jsx @@ -196,7 +196,7 @@ const InstructorTimeLogsPage = (props) => { await fetchSprintData(selectedGroupId) setIsLoading(false) } - selectedGroupId && fetchChartData(selectedGroupId) + if (selectedGroupId) fetchChartData(selectedGroupId) }, [selectedGroupId]) const handleTimeLogCheck = (logId) => { @@ -233,7 +233,7 @@ const InstructorTimeLogsPage = (props) => { const updatedLogs = await instructorTimeLogsService.deleteTimeLog(logId) setAllLogs(updatedLogs) setSuccess('Time log deleted successfully') - } catch (error) { + } catch { setError('Error deleting time log') } } diff --git a/frontend/src/components/TimeLogsPage/TimeLogChart.jsx b/frontend/src/components/TimeLogsPage/TimeLogChart.jsx index 42d6192..90e61dc 100644 --- a/frontend/src/components/TimeLogsPage/TimeLogChart.jsx +++ b/frontend/src/components/TimeLogsPage/TimeLogChart.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react' import { connect } from 'react-redux' -import { ResponsiveContainer, BarChart, XAxis, YAxis, Tooltip, ReferenceLine, Label, LabelList, Bar, Cell } from 'recharts' +import { ResponsiveContainer, BarChart, XAxis, YAxis, Tooltip, ReferenceLine, LabelList, Bar, Cell } from 'recharts' import { NoTimeLogsPlaceholderSprint, NoTimeLogsPlaceholderProject } from '../common/Placeholders' import Error from '@material-ui/icons/Error' import { useTheme } from '@material-ui/core/styles'; @@ -130,7 +130,7 @@ const checkStudentProgressPaceTotal = (studentName, allStudentHours, totalDurati const checkStudentProgressPacePerSprint = (targetStudent, allStudentHours, allSprintDates, isShortProject) => { const { idealHoursPerDay, okHoursPerDay, dangerousHoursPerDay } = getProjectHours(isShortProject) const sprintPaces = {} - allStudentHours.forEach((student, index) => { + allStudentHours.forEach((student, _index) => { if (student.sprint === -1) return diff --git a/frontend/src/components/TimeLogsPage/TimeLogsPage.jsx b/frontend/src/components/TimeLogsPage/TimeLogsPage.jsx index 4137331..d42b310 100644 --- a/frontend/src/components/TimeLogsPage/TimeLogsPage.jsx +++ b/frontend/src/components/TimeLogsPage/TimeLogsPage.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState, useCallback } from 'react' +import React, { useEffect, useState } from 'react' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import { TimeLogForm } from './TimeLogForm' @@ -107,9 +107,9 @@ const TimeLogsPage = (props) => { } const fetchData = async () => { setIsLoading(true) - group?.id && await fetchSprints() + if (group?.id) await fetchSprints() await fetchTimeLogs() - group?.id && await fetchGroupSprintSummary(group.id) + if (group?.id) await fetchGroupSprintSummary(group.id) await fetchTags() setIsLoading(false) } @@ -131,12 +131,14 @@ const TimeLogsPage = (props) => { } ) - currentSprintObject && setCurrentSprintNumber(currentSprintObject.sprint) - currentSprintObject && setSelectedSprintNumber(currentSprintObject.sprint) - !currentSprintObject && + if (currentSprintObject) { + setCurrentSprintNumber(currentSprintObject.sprint) + setSelectedSprintNumber(currentSprintObject.sprint) + } else { setSelectedSprintNumber( existingSprintNumbers.length > 0 ? existingSprintNumbers.at(-1) : null ) + } }, [allSprints]) const handleSubmit = async (date, time, description, tags) => { diff --git a/frontend/src/components/TopicFormPageInfo.jsx b/frontend/src/components/TopicFormPageInfo.jsx index 52a7b5d..cf211da 100644 --- a/frontend/src/components/TopicFormPageInfo.jsx +++ b/frontend/src/components/TopicFormPageInfo.jsx @@ -5,7 +5,12 @@ import { Typography } from '@material-ui/core' import topicFormPageActions from '../reducers/actions/topicFormPageActions' import './TopicFormPageInfo.css' -const TopicFormPageInfo = ({ topicOpen, topicMessage, updateShowInfo, toggle }) => { +const TopicFormPageInfo = ({ + topicOpen, + topicMessage, + updateShowInfo, + toggle, +}) => { const allowCretion = topicOpen && toggle return ( @@ -30,26 +35,25 @@ const TopicFormPageInfo = ({ topicOpen, topicMessage, updateShowInfo, toggle }) {!allowCretion && (
{topicMessage}
)} - {false && updateShowInfo(false)}>.} ) } const mapStateToProps = (state) => { return { - toggle: true || state && state.login && state.login.user && state.login.user.user && state.login.user.user.username === 'mluukkai2', + toggle: true, topicOpen: state.registrationManagement.topicRegistrationOpen, - topicMessage: state.registrationManagement.topicRegistrationMessage + topicMessage: state.registrationManagement.topicRegistrationMessage, } } const mapDispatchToProps = { - ...topicFormPageActions + ...topicFormPageActions, } const ConnectedTopicFormPageInfo = connect( mapStateToProps, - mapDispatchToProps + mapDispatchToProps, )(TopicFormPageInfo) export default ConnectedTopicFormPageInfo diff --git a/frontend/src/components/ViewUsersPage/ViewUsersPage.jsx b/frontend/src/components/ViewUsersPage/ViewUsersPage.jsx index 6c6a1fa..11a510c 100644 --- a/frontend/src/components/ViewUsersPage/ViewUsersPage.jsx +++ b/frontend/src/components/ViewUsersPage/ViewUsersPage.jsx @@ -19,13 +19,11 @@ const customTheme = createMuiTheme({ overline: { color: 'darkOrange', }, + useNextVariants: true, }, link: { color: 'darkOrange', }, - typography: { - useNextVariants: true, - }, }) const TopicDetailsLink = ({ topicId, ...props }) => (