From 191757ab8925eb7d560c65768eae66d9e1d09903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Palma?= Date: Mon, 16 Sep 2024 13:39:34 +0100 Subject: [PATCH] ci: added workflow to run linter --- .github/workflows/codeanalysis.yaml | 44 +++++++++++++++++++ eslint.config.js | 2 +- package.json | 1 + .../CoursesController/ClassSelector.tsx | 3 +- .../ClassSelectorDropdownController.tsx | 13 +----- src/contexts/ThemeContext.tsx | 3 +- 6 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/codeanalysis.yaml diff --git a/.github/workflows/codeanalysis.yaml b/.github/workflows/codeanalysis.yaml new file mode 100644 index 00000000..86ff3126 --- /dev/null +++ b/.github/workflows/codeanalysis.yaml @@ -0,0 +1,44 @@ +name: Code analysis + +on: + push: + branches: + - develop + - main + pull_request: + branches: + - develop + - main + +jobs: + lint: + runs-on: ubuntu-latest + name: Lint + + strategy: + matrix: + node-version: [21.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + **/node_modules + key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} + + - name: Install dependencies + run: npm install + + - name: Build site + run: npm run build + + - name: Lint Code + run: npm run lint + diff --git a/eslint.config.js b/eslint.config.js index dcfb2294..c96ecfed 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -21,7 +21,7 @@ export default [ }, }, { - ignores: ["src/components/ui/*", "src/components/svgs/*"], + ignores: ["src/components/ui/*", "src/components/svgs/*", "build/"], }, pluginJs.configs.recommended, ...tseslint.configs.recommended, diff --git a/package.json b/package.json index 322143dd..39607613 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "scripts": { "dev": "vite --host", "build": "tsc && vite build", + "lint": "eslint .", "preview": "vite preview", "check": "npx prettier --check .", "format": "npx prettier --write ." diff --git a/src/components/planner/sidebar/CoursesController/ClassSelector.tsx b/src/components/planner/sidebar/CoursesController/ClassSelector.tsx index eaa9c851..35994f7e 100644 --- a/src/components/planner/sidebar/CoursesController/ClassSelector.tsx +++ b/src/components/planner/sidebar/CoursesController/ClassSelector.tsx @@ -114,8 +114,7 @@ const ClassSelector = ({ course }: Props) => { >] - previewHook: [number | null, Dispatch>] - display: number + setPreview: Dispatch> removePreview: () => void, contentRef: any triggerRef: any @@ -48,8 +47,7 @@ const NoOptionsFound = ({ mobile }: { mobile: boolean }) => { const ClassSelectorDropdownController = ({ course, selectedClassIdHook, - previewHook, - display, + setPreview, removePreview, contentRef, triggerRef @@ -57,7 +55,6 @@ const ClassSelectorDropdownController = ({ const { multipleOptions, setMultipleOptions, selectedOption } = useContext(MultipleOptionsContext); const { pickedCourses, choosingNewCourse } = useContext(CourseContext); const [selectedClassId, setSelectedClassId] = selectedClassIdHook; - const [preview, setPreview] = previewHook; // This is used to store the ids of the teachers so it is easy to verify if a teacher is filtered or not const [filteredTeachers, setFilteredTeachers] = useState(teacherIdsFromCourseInfo(course)); @@ -224,9 +221,6 @@ const ClassSelectorDropdownController = ({ key={`schedule-${classInfo.name}`} course_id={course.id} classInfo={classInfo} - displayed={display === classInfo.id} - checked={selectedOption === classInfo.id} - preview={preview} conflict={timesCollideWithSelected(classInfo)} onSelect={() => { setSelectedClassId(classInfo.id) @@ -261,9 +255,6 @@ const ClassSelectorDropdownController = ({ key={`schedule-${classInfo.name}`} course_id={course.id} classInfo={classInfo} - displayed={display === classInfo.id} - checked={selectedOption === classInfo.id} - preview={preview} conflict={timesCollideWithSelected(classInfo)} onSelect={() => { setSelectedClassId(classInfo.id) diff --git a/src/contexts/ThemeContext.tsx b/src/contexts/ThemeContext.tsx index 9c318885..54adda6f 100644 --- a/src/contexts/ThemeContext.tsx +++ b/src/contexts/ThemeContext.tsx @@ -3,5 +3,6 @@ import { createContext } from 'react' //TODO: Change the boolean to a more appropriate name, like "darkMode" export const ThemeContext = createContext({ enabled: false, - setEnabled: () => { }, + // eslint-disable-next-line + setEnabled: (enabled: boolean) => { }, })