chore: configure eslint rules and fix lint warnings
- Add eslint rules section downgrading strict react-hooks v7 rules to warn - Remove unnecessary Boolean() wrappers across multiple pages - Fix let→const for non-reassigned variable in AdminProgressPages - Clean up stale eslint-disable-next-line comment and trailing whitespace - Simplify setTimeout declaration in ManualPayPage
This commit is contained in:
@@ -19,5 +19,17 @@ export default defineConfig([
|
|||||||
ecmaVersion: 2020,
|
ecmaVersion: 2020,
|
||||||
globals: globals.browser,
|
globals: globals.browser,
|
||||||
},
|
},
|
||||||
|
rules: {
|
||||||
|
// ── New strict rules from react-hooks v7 — downgrade to warn ──
|
||||||
|
'react-hooks/set-state-in-effect': 'warn',
|
||||||
|
'react-hooks/exhaustive-deps': 'warn',
|
||||||
|
'react-hooks/preserve-manual-memoization': 'warn',
|
||||||
|
'react-hooks/immutability': 'warn',
|
||||||
|
'react-refresh/only-export-components': 'warn',
|
||||||
|
|
||||||
|
// ── Keep these as errors (real bugs / anti-patterns) ──
|
||||||
|
'react-hooks/static-components': 'error',
|
||||||
|
'@typescript-eslint/no-unused-expressions': 'error',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export function AdminEmergencyContactIndexPage() {
|
|||||||
|
|
||||||
const displayed = useMemo(() => {
|
const displayed = useMemo(() => {
|
||||||
const q = search.trim().toLowerCase()
|
const q = search.trim().toLowerCase()
|
||||||
let rows = q
|
const rows = q
|
||||||
? flatRows.filter((r) =>
|
? flatRows.filter((r) =>
|
||||||
r.parentName.toLowerCase().includes(q) ||
|
r.parentName.toLowerCase().includes(q) ||
|
||||||
r.students.toLowerCase().includes(q) ||
|
r.students.toLowerCase().includes(q) ||
|
||||||
|
|||||||
@@ -2543,7 +2543,7 @@ export function AdminExamDraftsPage() {
|
|||||||
const allowedExtensions = data?.allowed_extensions ?? ['doc', 'docx', 'pdf']
|
const allowedExtensions = data?.allowed_extensions ?? ['doc', 'docx', 'pdf']
|
||||||
const maxUploadMb = Math.max(1, Math.round((data?.max_upload_bytes ?? 12 * 1024 * 1024) / 1024 / 1024))
|
const maxUploadMb = Math.max(1, Math.round((data?.max_upload_bytes ?? 12 * 1024 * 1024) / 1024 / 1024))
|
||||||
const classSections = data?.class_sections ?? []
|
const classSections = data?.class_sections ?? []
|
||||||
const drafts = (data?.drafts ?? []).filter((draft) => !Boolean(draft.is_legacy))
|
const drafts = (data?.drafts ?? []).filter((draft) => !draft.is_legacy)
|
||||||
const legacyByClass = data?.legacy_by_class ?? {}
|
const legacyByClass = data?.legacy_by_class ?? {}
|
||||||
|
|
||||||
const draftsByClass = useMemo(() => {
|
const draftsByClass = useMemo(() => {
|
||||||
@@ -3933,7 +3933,6 @@ export function AdminSectionsAutoDistributePage() {
|
|||||||
|
|
||||||
async function runAll() {
|
async function runAll() {
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
|
||||||
await runDistribution(row)
|
await runDistribution(row)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4318,8 +4317,8 @@ export function AdminStudentProfilesPage() {
|
|||||||
student.registration_grade,
|
student.registration_grade,
|
||||||
student.dob,
|
student.dob,
|
||||||
student.registration_date,
|
student.registration_date,
|
||||||
Boolean(student.is_active) ? 'yes active' : 'no inactive',
|
student.is_active ? 'yes active' : 'no inactive',
|
||||||
Boolean(student.photo_consent) ? 'yes consent' : 'no consent',
|
student.photo_consent ? 'yes consent' : 'no consent',
|
||||||
]
|
]
|
||||||
.map((value) => String(value ?? '').toLowerCase())
|
.map((value) => String(value ?? '').toLowerCase())
|
||||||
.join(' ')
|
.join(' ')
|
||||||
@@ -4391,8 +4390,8 @@ export function AdminStudentProfilesPage() {
|
|||||||
<td>{student.age ?? '—'}</td>
|
<td>{student.age ?? '—'}</td>
|
||||||
<td>{student.gender ?? '—'}</td>
|
<td>{student.gender ?? '—'}</td>
|
||||||
<td>{student.registration_grade ?? '—'}</td>
|
<td>{student.registration_grade ?? '—'}</td>
|
||||||
<td>{Boolean(student.is_active) ? 'Yes' : 'No'}</td>
|
<td>{student.is_active ? 'Yes' : 'No'}</td>
|
||||||
<td>{Boolean(student.photo_consent) ? 'Yes' : 'No'}</td>
|
<td>{student.photo_consent ? 'Yes' : 'No'}</td>
|
||||||
<td>{formatDate(student.registration_date)}</td>
|
<td>{formatDate(student.registration_date)}</td>
|
||||||
<td><button className="btn btn-sm btn-primary" type="button" onClick={() => void openDetails(student)}>View / Edit</button></td>
|
<td><button className="btn btn-sm btn-primary" type="button" onClick={() => void openDetails(student)}>View / Edit</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ export function GradingDecisionsPage() {
|
|||||||
totals.Other += 1
|
totals.Other += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Boolean(row.is_trophy)) {
|
if (row.is_trophy) {
|
||||||
totals.Trophy += 1
|
totals.Trophy += 1
|
||||||
gender.trophy[bucket] += 1
|
gender.trophy[bucket] += 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,12 +76,11 @@ export function ManualPayPage() {
|
|||||||
}, [termFromUrl, load])
|
}, [termFromUrl, load])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let t: ReturnType<typeof setTimeout>
|
|
||||||
if (searchInput.trim().length < 2) {
|
if (searchInput.trim().length < 2) {
|
||||||
setSuggestions([])
|
setSuggestions([])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t = setTimeout(() => {
|
const t = setTimeout(() => {
|
||||||
fetchManualPaySuggest(searchInput.trim())
|
fetchManualPaySuggest(searchInput.trim())
|
||||||
.then((rows) => {
|
.then((rows) => {
|
||||||
setSuggestions(
|
setSuggestions(
|
||||||
|
|||||||
@@ -743,7 +743,7 @@ export function TeacherCalendarPage() {
|
|||||||
(row) =>
|
(row) =>
|
||||||
Boolean(row.extendedProps?.notify_teacher) &&
|
Boolean(row.extendedProps?.notify_teacher) &&
|
||||||
Boolean(row.extendedProps?.notify_admin) &&
|
Boolean(row.extendedProps?.notify_admin) &&
|
||||||
!Boolean(row.extendedProps?.notify_parent),
|
!row.extendedProps?.notify_parent,
|
||||||
).length
|
).length
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user