feat: check-path-alias autofix (#124)
* feat: add autofix * chore: autofix repo with new custom ESLint rule
This commit is contained in:
@@ -12,7 +12,7 @@ module.exports = {
|
|||||||
category: 'Possible Errors',
|
category: 'Possible Errors',
|
||||||
recommended: true,
|
recommended: true,
|
||||||
},
|
},
|
||||||
fixable: null,
|
fixable: 'code', // Enable autofix
|
||||||
schema: [],
|
schema: [],
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -43,9 +43,16 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pathList.some(path => importPath.startsWith(path))) {
|
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({
|
context.report({
|
||||||
node,
|
node,
|
||||||
message: 'Use a path alias here',
|
message: `Run autofix to use path alias: ${alias}`,
|
||||||
|
fix: fixer => {
|
||||||
|
return fixer.replaceText(node.source, `'${updatedImportPath}'`);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import { Calendar } from '@views/components/calendar/Calendar/Calendar';
|
||||||
import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot';
|
import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Calendar } from 'src/views/components/calendar/Calendar/Calendar';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calendar page
|
* Calendar page
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Course, Status } from '@shared/types/Course';
|
import { Course, Status } from '@shared/types/Course';
|
||||||
import { CourseMeeting } from '@shared/types/CourseMeeting';
|
import { CourseMeeting } from '@shared/types/CourseMeeting';
|
||||||
import Instructor from '@shared/types/Instructor';
|
import Instructor from '@shared/types/Instructor';
|
||||||
|
import { tailwindColorways } from '@shared/util/storybook';
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import List from '@views/components/common/List/List';
|
import List from '@views/components/common/List/List';
|
||||||
import PopupCourseBlock from '@views/components/common/PopupCourseBlock/PopupCourseBlock';
|
import PopupCourseBlock from '@views/components/common/PopupCourseBlock/PopupCourseBlock';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { tailwindColorways } from 'src/shared/util/storybook';
|
|
||||||
|
|
||||||
const numberOfCourses = 5;
|
const numberOfCourses = 5;
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import { Course, Status } from '@shared/types/Course';
|
|||||||
import { CourseMeeting } from '@shared/types/CourseMeeting';
|
import { CourseMeeting } from '@shared/types/CourseMeeting';
|
||||||
import Instructor from '@shared/types/Instructor';
|
import Instructor from '@shared/types/Instructor';
|
||||||
import { getCourseColors } from '@shared/util/colors';
|
import { getCourseColors } from '@shared/util/colors';
|
||||||
|
import { tailwindColorways } from '@shared/util/storybook';
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import PopupCourseBlock from '@views/components/common/PopupCourseBlock/PopupCourseBlock';
|
import PopupCourseBlock from '@views/components/common/PopupCourseBlock/PopupCourseBlock';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { tailwindColorways } from 'src/shared/util/storybook';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an example course.
|
* Represents an example course.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import logoImage from '@assets/logo.png'; // Adjust the path as necessary
|
import logoImage from '@assets/logo.png'; // Adjust the path as necessary
|
||||||
import { Status } from '@shared/types/Course';
|
import { Status } from '@shared/types/Course';
|
||||||
import { StatusIcon } from '@shared/util/icons';
|
import { StatusIcon } from '@shared/util/icons';
|
||||||
|
import { tailwindColorways } from '@shared/util/storybook';
|
||||||
import Divider from '@views/components/common/Divider/Divider';
|
import Divider from '@views/components/common/Divider/Divider';
|
||||||
import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot';
|
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
|
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 { openTabFromContentScript } from '@views/lib/openNewTabFromContentScript';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react-dom/test-utils';
|
||||||
import { tailwindColorways } from 'src/shared/util/storybook';
|
|
||||||
|
|
||||||
import CalendarIcon from '~icons/material-symbols/calendar-month';
|
import CalendarIcon from '~icons/material-symbols/calendar-month';
|
||||||
import RefreshIcon from '~icons/material-symbols/refresh';
|
import RefreshIcon from '~icons/material-symbols/refresh';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import type { Course } from '@shared/types/Course';
|
||||||
|
import type { CourseMeeting } from '@shared/types/CourseMeeting';
|
||||||
import React from 'react';
|
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';
|
import styles from './CalendarCourseMeeting.module.scss';
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import type { StatusType } from '@shared/types/Course';
|
import type { StatusType } from '@shared/types/Course';
|
||||||
import { Status } 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 Text from '@views/components/common/Text/Text';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import React from 'react';
|
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 ClosedIcon from '~icons/material-symbols/lock';
|
||||||
import WaitlistIcon from '~icons/material-symbols/timelapse';
|
import WaitlistIcon from '~icons/material-symbols/timelapse';
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import type { Course } from '@shared/types/Course';
|
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 calIcon from 'src/assets/icons/cal.svg';
|
||||||
import pngIcon from 'src/assets/icons/png.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 CalendarCell from '@views/components/calendar/CalendarGridCell/CalendarGridCell';
|
||||||
import type { CalendarGridCourse } from '@views/hooks/useFlattenedCourseSchedule';
|
import type { CalendarGridCourse } from '@views/hooks/useFlattenedCourseSchedule';
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
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';
|
import styles from './CalendarGrid.module.scss';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import calIcon from '@assets/logo.png';
|
||||||
import { Status } from '@shared/types/Course';
|
import { Status } from '@shared/types/Course';
|
||||||
import { Button } from '@views/components/common/Button/Button';
|
import { Button } from '@views/components/common/Button/Button';
|
||||||
import CourseStatus from '@views/components/common/CourseStatus/CourseStatus';
|
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 Text from '@views/components/common/Text/Text';
|
||||||
import { openTabFromContentScript } from '@views/lib/openNewTabFromContentScript';
|
import { openTabFromContentScript } from '@views/lib/openNewTabFromContentScript';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import calIcon from 'src/assets/logo.png';
|
|
||||||
|
|
||||||
import MenuIcon from '~icons/material-symbols/menu';
|
import MenuIcon from '~icons/material-symbols/menu';
|
||||||
import RedoIcon from '~icons/material-symbols/redo';
|
import RedoIcon from '~icons/material-symbols/redo';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import type { Course } from '@shared/types/Course';
|
||||||
import Text from '@views/components/common/Text/Text';
|
import Text from '@views/components/common/Text/Text';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type { Course } from 'src/shared/types/Course';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Props for ConflictWithWarningProps
|
* Props for ConflictWithWarningProps
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Disclosure, Transition } from '@headlessui/react';
|
import { Disclosure, Transition } from '@headlessui/react';
|
||||||
|
import userScheduleHandler from '@pages/background/handler/userScheduleHandler';
|
||||||
import type { UserSchedule } from '@shared/types/UserSchedule';
|
import type { UserSchedule } from '@shared/types/UserSchedule';
|
||||||
import List from '@views/components/common/List/List';
|
import List from '@views/components/common/List/List';
|
||||||
import Text from '@views/components/common/Text/Text';
|
import Text from '@views/components/common/Text/Text';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import userScheduleHandler from 'src/pages/background/handler/userScheduleHandler';
|
|
||||||
|
|
||||||
import DropdownArrowDown from '~icons/material-symbols/arrow-drop-down';
|
import DropdownArrowDown from '~icons/material-symbols/arrow-drop-down';
|
||||||
import DropdownArrowUp from '~icons/material-symbols/arrow-drop-up';
|
import DropdownArrowUp from '~icons/material-symbols/arrow-drop-up';
|
||||||
|
|||||||
@@ -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 { Button } from '@views/components/common/Button/Button';
|
||||||
import { Chip, flagMap } from '@views/components/common/Chip/Chip';
|
import { Chip, flagMap } from '@views/components/common/Chip/Chip';
|
||||||
import Divider from '@views/components/common/Divider/Divider';
|
import Divider from '@views/components/common/Divider/Divider';
|
||||||
import Text from '@views/components/common/Text/Text';
|
import Text from '@views/components/common/Text/Text';
|
||||||
|
import { openTabFromContentScript } from '@views/lib/openNewTabFromContentScript';
|
||||||
import React, { useState } from 'react';
|
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 Add from '~icons/material-symbols/add';
|
||||||
import CalendarMonth from '~icons/material-symbols/calendar-month';
|
import CalendarMonth from '~icons/material-symbols/calendar-month';
|
||||||
|
|||||||
Reference in New Issue
Block a user