[Eslint] run --fix + fix shared

This commit is contained in:
joonas-a
2025-08-07 15:05:22 +03:00
parent 40c3cf7ca1
commit d208012f07
19 changed files with 64 additions and 72 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ export default tseslint.config(
// Disable type-aware linting for javascript files
{
files: ['**/*{.js.cjs.mjs,jsx}'],
files: ['{updater,services}/**/*.{js,cjs}'],
extends: [tseslint.configs.disableTypeChecked]
},
+1 -2
View File
@@ -1,8 +1,7 @@
const { orderBy } = require('lodash')
// dbConnections must be imported to avoid Sequelize errors even if it's not used
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { dbConnections } = require('../database/connection')
const { computeCreditsProduced } = require('../services/providerCredits')
const { parseCsv, printProgressBar } = require('./helpers')
@@ -6,9 +6,9 @@ import { FormattedProgramme, OrganizationDetails } from './helpers'
type Programme = {
name: Name
students: { [yearCode: number]: string[] }
passed: { [yearCode: number]: string[] }
credits: { [yearCode: number]: number }
students: Record<number, string[]>
passed: Record<number, string[]>
credits: Record<number, number>
}
type Faculty = {
@@ -22,11 +22,11 @@ type FacultyYearStats = {
year: string
allStudents: string[]
allPassed: string[]
faculties: { [facultyCode: string]: Faculty }
faculties: Record<string, Faculty>
allCredits: number
}
type Grades = { [grade: string]: string[] }
type Grades = Record<string, string[]>
type GroupAttempts = {
grades: Grades
@@ -37,7 +37,7 @@ type GroupAttempts = {
}
type GroupStudents = {
grades: { [studentNumber: string]: { grade: string; passed: boolean } }
grades: Record<string, { grade: string; passed: boolean }>
studentNumbers: string[]
}
@@ -58,9 +58,9 @@ type Student = {
}
export class CourseYearlyStatsCounter {
private groups: { [groupCode: number]: Group }
private programmes: { [code: string]: Programme }
private facultyStats: { [yearCode: number]: FacultyYearStats }
private groups: Record<number, Group>
private programmes: Record<string, Programme>
private facultyStats: Record<number, FacultyYearStats>
private obfuscated: boolean
private students: Map<string, Student>
@@ -215,11 +215,12 @@ export class CourseYearlyStatsCounter {
enrollment => enrollment.studentNumber === studentNumber
)
if (!oldEnrollment) {
return this.groups[groupCode].enrollments.push({ studentNumber, enrollmentDateTime })
this.groups[groupCode].enrollments.push({ studentNumber, enrollmentDateTime })
} else {
this.groups[groupCode].enrollments = this.groups[groupCode].enrollments
.filter(enrollment => enrollment.studentNumber !== studentNumber)
.concat([enrollment])
}
this.groups[groupCode].enrollments = this.groups[groupCode].enrollments
.filter(enrollment => enrollment.studentNumber !== studentNumber)
.concat([enrollment])
}
private markCreditToAttempts(studentNumber: string, passed: boolean, grade: string, groupCode: number) {
@@ -11,11 +11,10 @@ type CourseInfo = {
}
}
type StudentStats = {
[studentNumber: string]: {
courseInfo: {
[courseCode: string]: CourseInfo
}
type StudentStats = Record<
string,
{
courseInfo: Record<string, CourseInfo>
email: string
secondaryEmail: string
totals: {
@@ -24,7 +23,7 @@ type StudentStats = {
unfinished: number
}
}
}
>
const uniq = objects => [...new Set(objects)]
@@ -47,7 +47,7 @@ const getTransferSource = (code: string, studyRights: StudentStudyRight[]): [boo
return [false, undefined]
}
const getCriteriaBase = (criteria: ProgressCriteria): [boolean, { [year: string]: CriteriaYear }] => {
const getCriteriaBase = (criteria: ProgressCriteria): [boolean, Record<string, CriteriaYear>] => {
const thereAreCriteriaCourses = !!Object.values(criteria.courses).flatMap(val => val).length
const thereAreCriteriaCredits = !!Object.values(criteria.credits).reduce((acc, cur) => acc + cur, 0)
@@ -57,7 +57,7 @@ const getCriteriaBase = (criteria: ProgressCriteria): [boolean, { [year: string]
coursesSatisfied: Object.fromEntries(criteria.courses[year].map(course => [course, null])),
})
const criteriaChecked: { [year: string]: CriteriaYear } = {
const criteriaChecked: Record<string, CriteriaYear> = {
year1: createEmptyCriteriaYear(criteria, 'yearOne'),
year2: createEmptyCriteriaYear(criteria, 'yearTwo'),
year3: createEmptyCriteriaYear(criteria, 'yearThree'),
+8 -6
View File
@@ -5,23 +5,25 @@ import { dateMinFromList, dateMaxFromList } from '@oodikone/shared/util/datetime
import { SemesterModel } from '../models'
type SemestersAndYears = {
years: {
[yearcode: string]: {
years: Record<
string,
{
yearcode: number
yearname: string
startdate: Date
enddate: Date
}
}
semesters: {
[semestercode: string]: {
>
semesters: Record<
string,
{
semestercode: number
name: Name
yearcode: number
startdate: Date
enddate: Date
}
}
>
}
export const getSemesterNames = async (semesterCodes: number[]) => {
@@ -68,9 +68,7 @@ const getGroupsFromImporter = async (sisPersonId: string) => {
type Tags = { studyProgramme?: string | null; year?: string | null }
type TagsByGroupId = {
[groupId: string]: Tags
}
type TagsByGroupId = Record<string, Tags>
type GroupsWithTags = StudyGuidanceGroup & { tags: Tags }
@@ -15,9 +15,7 @@ import { getStudyRightsInProgramme } from './studyRightFinders'
export const getDateOfFirstSemesterPresent = (
semesterEnrollments: SemesterEnrollment[] | null,
semesters: {
[semestercode: string]: { semestercode: number; name: Name; yearcode: number; startdate: Date; enddate: Date }
},
semesters: Record<string, { semestercode: number; name: Name; yearcode: number; startdate: Date; enddate: Date }>,
currentSemester: number,
since: Date
) => {
@@ -235,9 +235,7 @@ type QueryParameters = {
includeAllSpecials: boolean
}
type ProgrammeWithYears = {
[key: string]: number | string | Name
} & StudyTrack
type ProgrammeWithYears = Record<string, number | string | Name> & StudyTrack
const getProgrammesBeforeStarting = async ({
studyProgramme,
@@ -57,9 +57,8 @@ type CustomPopulation = {
dataExport: JSX.Element
}
type PopulationStudentsProps = (PopulationDetails | CoursePopulation | StudyGuidanceGroup | CustomPopulation) & {
[key: string]: undefined
}
type PopulationStudentsProps = (PopulationDetails | CoursePopulation | StudyGuidanceGroup | CustomPopulation) &
Record<string, undefined>
export const PopulationStudents = ({
variant,
@@ -125,12 +124,13 @@ export const PopulationStudents = ({
const { handleTabChange, showSubstitutionToggle } = useTabChangeAnalytics()
const [includeSubstitutions, toggleIncludeSubstitutions] = useToggle(false)
const contentByVariant: {
[K in PopulationStudentsProps['variant']]: {
const contentByVariant: Record<
PopulationStudentsProps['variant'],
{
tabs: (keyof typeof availableTabs)[]
tooltip: string
}
} = {
> = {
population: {
tabs:
year === 'All' || (programme && !isBachelorOrLicentiateProgramme(programme))
@@ -1,5 +1,4 @@
/* eslint-disable class-methods-use-this */
/* eslint-disable @typescript-eslint/class-methods-use-this */
import { getDataItemType, DataItemType } from '@/components/SortableTable/common'
class DataVisitorContext {
+1
View File
@@ -1,3 +1,4 @@
// eslint-disable-next-line import-x/no-unused-modules
export interface GenericError {
error: string
}
+7 -10
View File
@@ -16,10 +16,11 @@ export type CourseStats = {
course: Course
attempts: number
enrollments: EnrollmentObject & {
semesters: { [semester: string]: EnrollmentObject }
semesters: Record<string, EnrollmentObject>
}
grades: {
[grade: string]: {
grades: Record<
string,
{
count: number
status: {
passingGrade: boolean
@@ -27,7 +28,7 @@ export type CourseStats = {
improvedGrade: boolean
}
}
}
>
/**
* all: string[]
* passed: string[]
@@ -36,13 +37,9 @@ export type CourseStats = {
* markedToSemester: string[]
* enrolledNoGrade: string[]
*/
students: {
[key: string]: string[]
}
students: Record<string, string[]>
stats: {
passingSemesters: {
[semester: string]: number
}
passingSemesters: Record<string, number>
}
}
+4 -3
View File
@@ -3,14 +3,15 @@ export type FacultyClassSizes = {
bcMsCombo: Record<string, number>
master: Record<string, number>
doctor: Record<string, number>
programmes: {
[code: string]: {
programmes: Record<
string,
{
bachelor: Record<string, number>
bcMsCombo: Record<string, number>
master: Record<string, number>
doctor: Record<string, number>
}
}
>
}
export type ProgrammeClassSizes = {
+1 -1
View File
@@ -39,7 +39,7 @@ export type {
MedianEntry,
Module,
ProgrammeCourse,
ProgrammeModule,
ProgrammeModule, // eslint-disable-line import-x/no-unused-modules
ProgrammeOrStudyTrackGraduationStats,
StudyProgrammeCourse,
StudyTrackStats,
+6 -1
View File
@@ -26,6 +26,7 @@ type StudentStudyRightElement = Pick<
'code' | 'name' | 'studyTrack' | 'graduated' | 'startDate' | 'endDate' | 'phase' | 'degreeProgrammeType'
>
// eslint-disable-next-line import-x/no-unused-modules
export type StudentStudyRight = Pick<
SISStudyRight,
'id' | 'extentCode' | 'facultyCode' | 'admissionType' | 'cancelled' | 'semesterEnrollments' | 'startDate' | 'tvex'
@@ -33,6 +34,7 @@ export type StudentStudyRight = Pick<
studyRightElements: Array<StudentStudyRightElement>
}
// eslint-disable-next-line import-x/no-unused-modules
export type StudentStudyPlan = Pick<
Studyplan,
| 'included_courses'
@@ -43,15 +45,18 @@ export type StudentStudyPlan = Pick<
| 'sis_study_right_id'
>
// eslint-disable-next-line import-x/no-unused-modules
export type StudentData = StudentPersonalData & {
studyplans: Array<StudentStudyPlan>
studyRights: Array<StudentStudyRight>
}
// eslint-disable-next-line import-x/no-unused-modules
export type StudentTags = TagStudent & {
tag: Pick<Tag, 'tag_id' | 'tagname' | 'personal_user_id'>
}
// eslint-disable-next-line import-x/no-unused-modules
export type TaggetStudentData = StudentData & {
tags: StudentTags[]
}
@@ -77,7 +82,7 @@ export type FormattedStudent = {
birthdate: Date
sis_person_id: string
citizenships: Name[]
criteriaProgress: { [year: string]: CriteriaYear }
criteriaProgress: Record<string, CriteriaYear>
curriculumVersion: string | null
transferredStudyright: boolean
+2 -3
View File
@@ -41,14 +41,13 @@ export type ProgrammeOrStudyTrackGraduationStats = {
}
}
// eslint-disable-next-line import-x/no-unused-modules
export type Goals = {
basic: number
combo: number
}
export type GraduationTimes = {
[programmeOrStudyTrack: string]: ProgrammeOrStudyTrackGraduationStats
} & {
export type GraduationTimes = Record<string, ProgrammeOrStudyTrackGraduationStats> & {
goals: Goals
}
+1
View File
@@ -14,6 +14,7 @@ export const dateYearsFromNow = (date: Date, years: number) => {
* @param months Number of months to add to the start date
* @returns A new date with months incremented by the given amount
*/
// eslint-disable-next-line import-x/no-unused-modules
export const dateMonthsFromNow = (date: string, months?: string) => {
const initialDate = new Date(date)
// NOTE: Cast to number, uses "MAGIC_NUMBER" if undefined or NaN
+1 -7
View File
@@ -60,17 +60,11 @@ export const formatToArray = <T>(param: T | T[]): T[] => {
return Array.isArray(param) ? param : [param]
}
export const formatQueryParamsToArrays = (query: Record<string, any>, params: string[]) => {
const result = { ...query }
params.filter(param => !!result[param]).forEach(param => (result[param] = formatToArray(result[param])))
return result
}
export const omitKeys = <T extends object, K extends keyof T>(input: T, toOmit: K[]): Omit<T, K> => {
return Object.fromEntries(Object.entries(input).filter(([key, _]) => !toOmit.includes(key as K))) as Omit<T, K>
}
// eslint-disable-next-line import-x/no-unused-modules
export const keyBy = <T extends object, K extends keyof T>(input: T[], key: K): Record<K, T> =>
Object.fromEntries(input.map(item => [item[key], item]))