From eb306787aee57b0716fa196a3cca5413d444253c Mon Sep 17 00:00:00 2001 From: Samuel Gunter Date: Tue, 22 Oct 2024 21:47:35 -0500 Subject: [PATCH] chore: fix lint warnings (#385) --- .eslintrc.cjs | 9 ++++++++- src/pages/background/background.ts | 2 +- src/shared/util/icons.tsx | 2 +- src/views/components/PopupMain.tsx | 2 +- src/views/components/calendar/CalendarGrid.tsx | 2 +- src/views/components/common/Chip.tsx | 2 +- src/views/components/common/Link.tsx | 4 ++-- src/views/components/settings/Settings.tsx | 7 ++++--- src/views/lib/CourseCatalogScraper.ts | 4 ---- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 52f53254..10f1fd13 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -172,7 +172,14 @@ module.exports = { }, ], '@typescript-eslint/no-explicit-any': 'error', - '@typescript-eslint/no-unused-vars': 'warn', + '@typescript-eslint/no-unused-vars': [ + 'warn', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }, + ], '@typescript-eslint/naming-convention': 'off', '@typescript-eslint/space-before-function-paren': 'off', '@typescript-eslint/ban-ts-comment': 'off', diff --git a/src/pages/background/background.ts b/src/pages/background/background.ts index b382f045..9bfcd08f 100644 --- a/src/pages/background/background.ts +++ b/src/pages/background/background.ts @@ -32,7 +32,7 @@ chrome.runtime.onInstalled.addListener(details => { }); // migration/login logic -chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => { +chrome.tabs.onUpdated.addListener(async (tabId, changeInfo) => { // console.log(changeInfo); if (changeInfo.url === 'https://utdirect.utexas.edu/apps/registrar/course_schedule/utrp_login/') { function openPopupAction() { diff --git a/src/shared/util/icons.tsx b/src/shared/util/icons.tsx index 059344e2..64bf629b 100644 --- a/src/shared/util/icons.tsx +++ b/src/shared/util/icons.tsx @@ -15,7 +15,7 @@ import CancelledIcon from '~icons/material-symbols/warning'; export function StatusIcon(props: SVGProps & { status: StatusType }): JSX.Element | null { const { status, ...rest } = props; - switch (props.status) { + switch (status) { case Status.WAITLISTED: return ; case Status.CLOSED: diff --git a/src/views/components/PopupMain.tsx b/src/views/components/PopupMain.tsx index ced9ade6..12d622bb 100644 --- a/src/views/components/PopupMain.tsx +++ b/src/views/components/PopupMain.tsx @@ -59,7 +59,7 @@ export default function PopupMain(): JSX.Element { }, []); const [activeSchedule, schedules] = useSchedules(); - const [isRefreshing, setIsRefreshing] = useState(false); + // const [isRefreshing, setIsRefreshing] = useState(false); const [funny, setFunny] = useState(''); useEffect(() => { diff --git a/src/views/components/calendar/CalendarGrid.tsx b/src/views/components/calendar/CalendarGrid.tsx index b4e3af86..ce672bfd 100644 --- a/src/views/components/calendar/CalendarGrid.tsx +++ b/src/views/components/calendar/CalendarGrid.tsx @@ -47,7 +47,7 @@ function makeGridRow(row: number, cols: number): JSX.Element { */ export default function CalendarGrid({ courseCells, - saturdayClass, // TODO: implement/move away from props + saturdayClass: _saturdayClass, // TODO: implement/move away from props setCourse, }: React.PropsWithChildren): JSX.Element { return ( diff --git a/src/views/components/common/Chip.tsx b/src/views/components/common/Chip.tsx index 691736af..1e3dfb9e 100644 --- a/src/views/components/common/Chip.tsx +++ b/src/views/components/common/Chip.tsx @@ -58,7 +58,7 @@ export function Chip({ variant, label }: React.PropsWithChildren): JSX.El default: labelMap = {}; } - const longName = Object.entries(labelMap).find(([full, short]) => short === label)?.[0] ?? label; + const longName = Object.entries(labelMap).find(([_full, short]) => short === label)?.[0] ?? label; return ( & { * A reusable Text component with props that build on top of the design system for the extension */ export default function Link(props: PropsWithChildren): JSX.Element { - let { className, href, ...passedProps } = props; + const { className, href, ...passedProps } = props; if (href && !props.onClick) { passedProps.onClick = e => { @@ -37,7 +37,7 @@ export default function Link(props: PropsWithChildren): JSX.Element { 'underline cursor-pointer': !isDisabled, 'cursor-not-allowed color-ut-gray': isDisabled, }, - props.className + className )} /> ); diff --git a/src/views/components/settings/Settings.tsx b/src/views/components/settings/Settings.tsx index 21cf66aa..b9125658 100644 --- a/src/views/components/settings/Settings.tsx +++ b/src/views/components/settings/Settings.tsx @@ -79,11 +79,11 @@ const useDevMode = (targetCount: number): [boolean, () => void] => { * @returns The Settings component. */ export default function Settings(): JSX.Element { - const [enableCourseStatusChips, setEnableCourseStatusChips] = useState(false); - const [showTimeLocation, setShowTimeLocation] = useState(false); + const [_enableCourseStatusChips, setEnableCourseStatusChips] = useState(false); + const [_showTimeLocation, setShowTimeLocation] = useState(false); const [highlightConflicts, setHighlightConflicts] = useState(false); const [loadAllCourses, setLoadAllCourses] = useState(false); - const [enableDataRefreshing, setEnableDataRefreshing] = useState(false); + const [_enableDataRefreshing, setEnableDataRefreshing] = useState(false); const showMigrationDialog = useMigrationDialog(); @@ -216,6 +216,7 @@ export default function Settings(): JSX.Element { try { response = await fetch(link); } catch (e) { + // eslint-disable-next-line no-alert alert(`Failed to fetch url '${link}'`); return; } diff --git a/src/views/lib/CourseCatalogScraper.ts b/src/views/lib/CourseCatalogScraper.ts index 96474531..23f4d496 100644 --- a/src/views/lib/CourseCatalogScraper.ts +++ b/src/views/lib/CourseCatalogScraper.ts @@ -22,8 +22,6 @@ const TableDataSelector = { CORE_CURRICULUM: 'td[data-th="Core"] ul li', } as const satisfies Record; -type TableDataSelectorType = (typeof TableDataSelector)[keyof typeof TableDataSelector]; - /** * The selectors that we use to scrape the course details page for an individual course (https://utdirect.utexas.edu/apps/registrar/course_schedule/20239/52700/) */ @@ -32,8 +30,6 @@ const DetailsSelector = { COURSE_DESCRIPTION: '#details p', } as const; -type DetailsSelectorType = (typeof DetailsSelector)[keyof typeof DetailsSelector]; - /** * A class that allows us to scrape information from UT's course catalog to create our internal representation of a course */