diff --git a/custom-eslint-rules/check-path-alias.js b/custom-eslint-rules/check-path-alias.js index 2993e07d..0c4d3bc7 100644 --- a/custom-eslint-rules/check-path-alias.js +++ b/custom-eslint-rules/check-path-alias.js @@ -12,7 +12,7 @@ module.exports = { category: 'Possible Errors', recommended: true, }, - fixable: null, + fixable: 'code', // Enable autofix schema: [], }, @@ -43,9 +43,16 @@ module.exports = { } if (pathList.some(path => importPath.startsWith(path))) { + const matchingPath = pathList.find(path => importPath.startsWith(path)); + const alias = Object.keys(paths).find(key => paths[key].includes(matchingPath + '/*')); + const aliasParsed = alias.replace('/*', ''); + const updatedImportPath = importPath.replace(matchingPath, aliasParsed); context.report({ node, - message: 'Use a path alias here', + message: `Run autofix to use path alias: ${alias}`, + fix: fixer => { + return fixer.replaceText(node.source, `'${updatedImportPath}'`); + }, }); } }, diff --git a/src/pages/calendar/CalendarMain.tsx b/src/pages/calendar/CalendarMain.tsx index 225e120d..d01033d8 100644 --- a/src/pages/calendar/CalendarMain.tsx +++ b/src/pages/calendar/CalendarMain.tsx @@ -1,6 +1,6 @@ +import { Calendar } from '@views/components/calendar/Calendar/Calendar'; import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot'; import React from 'react'; -import { Calendar } from 'src/views/components/calendar/Calendar/Calendar'; /** * Calendar page diff --git a/src/stories/components/List.stories.tsx b/src/stories/components/List.stories.tsx index 3714667e..585e798e 100644 --- a/src/stories/components/List.stories.tsx +++ b/src/stories/components/List.stories.tsx @@ -1,11 +1,11 @@ import { Course, Status } from '@shared/types/Course'; import { CourseMeeting } from '@shared/types/CourseMeeting'; import Instructor from '@shared/types/Instructor'; +import { tailwindColorways } from '@shared/util/storybook'; import type { Meta, StoryObj } from '@storybook/react'; import List from '@views/components/common/List/List'; import PopupCourseBlock from '@views/components/common/PopupCourseBlock/PopupCourseBlock'; import React from 'react'; -import { tailwindColorways } from 'src/shared/util/storybook'; const numberOfCourses = 5; diff --git a/src/stories/components/PopupCourseBlock.stories.tsx b/src/stories/components/PopupCourseBlock.stories.tsx index be5b8e69..60b848fe 100644 --- a/src/stories/components/PopupCourseBlock.stories.tsx +++ b/src/stories/components/PopupCourseBlock.stories.tsx @@ -2,10 +2,10 @@ import { Course, Status } from '@shared/types/Course'; import { CourseMeeting } from '@shared/types/CourseMeeting'; import Instructor from '@shared/types/Instructor'; import { getCourseColors } from '@shared/util/colors'; +import { tailwindColorways } from '@shared/util/storybook'; import type { Meta, StoryObj } from '@storybook/react'; import PopupCourseBlock from '@views/components/common/PopupCourseBlock/PopupCourseBlock'; import React from 'react'; -import { tailwindColorways } from 'src/shared/util/storybook'; /** * Represents an example course. diff --git a/src/views/components/PopupMain.tsx b/src/views/components/PopupMain.tsx index 05d0f739..69920486 100644 --- a/src/views/components/PopupMain.tsx +++ b/src/views/components/PopupMain.tsx @@ -1,6 +1,7 @@ import logoImage from '@assets/logo.png'; // Adjust the path as necessary import { Status } from '@shared/types/Course'; import { StatusIcon } from '@shared/util/icons'; +import { tailwindColorways } from '@shared/util/storybook'; import Divider from '@views/components/common/Divider/Divider'; import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot'; import List from '@views/components/common/List/List'; // Ensure this path is correctly pointing to your List component @@ -11,7 +12,6 @@ import useSchedules from '@views/hooks/useSchedules'; import { openTabFromContentScript } from '@views/lib/openNewTabFromContentScript'; import React from 'react'; import { act } from 'react-dom/test-utils'; -import { tailwindColorways } from 'src/shared/util/storybook'; import CalendarIcon from '~icons/material-symbols/calendar-month'; import RefreshIcon from '~icons/material-symbols/refresh'; diff --git a/src/views/components/calendar/CalendarCourseBlock/CalendarCourseMeeting.tsx b/src/views/components/calendar/CalendarCourseBlock/CalendarCourseMeeting.tsx index 52128e8c..525cd915 100644 --- a/src/views/components/calendar/CalendarCourseBlock/CalendarCourseMeeting.tsx +++ b/src/views/components/calendar/CalendarCourseBlock/CalendarCourseMeeting.tsx @@ -1,6 +1,6 @@ +import type { Course } from '@shared/types/Course'; +import type { CourseMeeting } from '@shared/types/CourseMeeting'; import React from 'react'; -import type { Course } from 'src/shared/types/Course'; -import type { CourseMeeting } from 'src/shared/types/CourseMeeting'; import styles from './CalendarCourseMeeting.module.scss'; diff --git a/src/views/components/calendar/CalendarCourseCell/CalendarCourseCell.tsx b/src/views/components/calendar/CalendarCourseCell/CalendarCourseCell.tsx index c9ba5673..b9ec4fb0 100644 --- a/src/views/components/calendar/CalendarCourseCell/CalendarCourseCell.tsx +++ b/src/views/components/calendar/CalendarCourseCell/CalendarCourseCell.tsx @@ -1,10 +1,10 @@ import type { StatusType } from '@shared/types/Course'; import { Status } from '@shared/types/Course'; +import type { CourseColors } from '@shared/util/colors'; +import { pickFontColor } from '@shared/util/colors'; import Text from '@views/components/common/Text/Text'; import clsx from 'clsx'; import React from 'react'; -import type { CourseColors } from 'src/shared/util/colors'; -import { pickFontColor } from 'src/shared/util/colors'; import ClosedIcon from '~icons/material-symbols/lock'; import WaitlistIcon from '~icons/material-symbols/timelapse'; diff --git a/src/views/components/calendar/CalendarGrid/CalendarGrid.tsx b/src/views/components/calendar/CalendarGrid/CalendarGrid.tsx index 59afe4bf..02382cdd 100644 --- a/src/views/components/calendar/CalendarGrid/CalendarGrid.tsx +++ b/src/views/components/calendar/CalendarGrid/CalendarGrid.tsx @@ -1,4 +1,6 @@ import type { Course } from '@shared/types/Course'; +// import html2canvas from 'html2canvas'; +import { DAY_MAP } from '@shared/types/CourseMeeting'; /* import calIcon from 'src/assets/icons/cal.svg'; import pngIcon from 'src/assets/icons/png.svg'; */ @@ -7,8 +9,6 @@ import CalendarCourseCell from '@views/components/calendar/CalendarCourseCell/Ca import CalendarCell from '@views/components/calendar/CalendarGridCell/CalendarGridCell'; import type { CalendarGridCourse } from '@views/hooks/useFlattenedCourseSchedule'; import React, { useEffect, useRef, useState } from 'react'; -// import html2canvas from 'html2canvas'; -import { DAY_MAP } from 'src/shared/types/CourseMeeting'; import styles from './CalendarGrid.module.scss'; diff --git a/src/views/components/calendar/CalendarHeader/CalenderHeader.tsx b/src/views/components/calendar/CalendarHeader/CalenderHeader.tsx index 0b862564..6c95a707 100644 --- a/src/views/components/calendar/CalendarHeader/CalenderHeader.tsx +++ b/src/views/components/calendar/CalendarHeader/CalenderHeader.tsx @@ -1,3 +1,4 @@ +import calIcon from '@assets/logo.png'; import { Status } from '@shared/types/Course'; import { Button } from '@views/components/common/Button/Button'; import CourseStatus from '@views/components/common/CourseStatus/CourseStatus'; @@ -6,7 +7,6 @@ import ScheduleTotalHoursAndCourses from '@views/components/common/ScheduleTotal import Text from '@views/components/common/Text/Text'; import { openTabFromContentScript } from '@views/lib/openNewTabFromContentScript'; import React from 'react'; -import calIcon from 'src/assets/logo.png'; import MenuIcon from '~icons/material-symbols/menu'; import RedoIcon from '~icons/material-symbols/redo'; diff --git a/src/views/components/common/ConflictsWithWarning/ConflictsWithWarning.tsx b/src/views/components/common/ConflictsWithWarning/ConflictsWithWarning.tsx index 54efb3fe..b4055e5c 100644 --- a/src/views/components/common/ConflictsWithWarning/ConflictsWithWarning.tsx +++ b/src/views/components/common/ConflictsWithWarning/ConflictsWithWarning.tsx @@ -1,7 +1,7 @@ +import type { Course } from '@shared/types/Course'; import Text from '@views/components/common/Text/Text'; import clsx from 'clsx'; import React from 'react'; -import type { Course } from 'src/shared/types/Course'; /** * Props for ConflictWithWarningProps diff --git a/src/views/components/common/Dropdown/Dropdown.tsx b/src/views/components/common/Dropdown/Dropdown.tsx index 62632007..e357f009 100644 --- a/src/views/components/common/Dropdown/Dropdown.tsx +++ b/src/views/components/common/Dropdown/Dropdown.tsx @@ -1,9 +1,9 @@ import { Disclosure, Transition } from '@headlessui/react'; +import userScheduleHandler from '@pages/background/handler/userScheduleHandler'; import type { UserSchedule } from '@shared/types/UserSchedule'; import List from '@views/components/common/List/List'; import Text from '@views/components/common/Text/Text'; import React from 'react'; -import userScheduleHandler from 'src/pages/background/handler/userScheduleHandler'; import DropdownArrowDown from '~icons/material-symbols/arrow-drop-down'; import DropdownArrowUp from '~icons/material-symbols/arrow-drop-up'; diff --git a/src/views/components/injected/CourseCatalogInjectedPopup/HeadingAndActions.tsx b/src/views/components/injected/CourseCatalogInjectedPopup/HeadingAndActions.tsx index 09c5997b..09296f66 100644 --- a/src/views/components/injected/CourseCatalogInjectedPopup/HeadingAndActions.tsx +++ b/src/views/components/injected/CourseCatalogInjectedPopup/HeadingAndActions.tsx @@ -1,13 +1,13 @@ +import addCourse from '@pages/background/lib/addCourse'; +import removeCourse from '@pages/background/lib/removeCourse'; +import type { Course } from '@shared/types/Course'; +import type { UserSchedule } from '@shared/types/UserSchedule'; import { Button } from '@views/components/common/Button/Button'; import { Chip, flagMap } from '@views/components/common/Chip/Chip'; import Divider from '@views/components/common/Divider/Divider'; import Text from '@views/components/common/Text/Text'; +import { openTabFromContentScript } from '@views/lib/openNewTabFromContentScript'; import React, { useState } from 'react'; -import addCourse from 'src/pages/background/lib/addCourse'; -import removeCourse from 'src/pages/background/lib/removeCourse'; -import type { Course } from 'src/shared/types/Course'; -import type { UserSchedule } from 'src/shared/types/UserSchedule'; -import { openTabFromContentScript } from 'src/views/lib/openNewTabFromContentScript'; import Add from '~icons/material-symbols/add'; import CalendarMonth from '~icons/material-symbols/calendar-month';