chore: update oxlint config and fix lint errors

This commit is contained in:
Markus
2026-08-04 12:59:41 +03:00
parent 84d93f1e11
commit fcc4622e7d
20 changed files with 65 additions and 46 deletions
+5 -3
View File
@@ -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()
}
)
+3 -3
View File
@@ -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' })
}
}
+5 -3
View File
@@ -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()
})
+1 -1
View File
@@ -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.' })
}
})
+1 -1
View File
@@ -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.' })
}
})
+1 -1
View File
@@ -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
+9 -1
View File
@@ -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"
}
}
]
}
+2 -2
View File
@@ -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)
}
@@ -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])
@@ -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')
}
}
@@ -37,7 +37,7 @@ const GroupManagementPage = (props) => {
setUsers(fetchedUsers)
setGroups(fetchedGroups)
await fetchTopics()
} catch (err) {
} catch {
setError('Some error happened')
}
}
@@ -311,7 +311,7 @@ const Review = ({ student, updateAnswer, index }) => {
const Reviews = ({ answerSheet, updateAnswer }) => {
return answerSheet.map((student, index) => {
return (
<Review student={student} updateAnswer={updateAnswer} index={index} />
<Review key={index} student={student} updateAnswer={updateAnswer} index={index} />
)
})
}
+9 -6
View File
@@ -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 (
<div>
@@ -281,10 +287,7 @@ const Question = ({
return (
<div className="peer-review-box">
<h3 className="peer-review-box__h3">{question.header}</h3>
<Table
size="small"
className="peer-review-box__radio-button-table"
>
<Table size="small" className="peer-review-box__radio-button-table">
<TableHead>
<TableRow hover>
<TableCell className="peer-review-box__radio-header" />
+1 -1
View File
@@ -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' }
}
}
@@ -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)
})
@@ -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')
}
}
@@ -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
@@ -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) => {
+10 -6
View File
@@ -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 && (
<div className="topic-form-page-info-message">{topicMessage}</div>
)}
{false && <span style={{ margin: 10, color: 'white' }} onClick={() => updateShowInfo(false)}>.</span>}
</div>
)
}
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
@@ -19,13 +19,11 @@ const customTheme = createMuiTheme({
overline: {
color: 'darkOrange',
},
useNextVariants: true,
},
link: {
color: 'darkOrange',
},
typography: {
useNextVariants: true,
},
})
const TopicDetailsLink = ({ topicId, ...props }) => (