Skip to content

Commit

Permalink
ci: added workflow to run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaspalma committed Sep 16, 2024
1 parent d50ad00 commit 191757a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 15 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/codeanalysis.yaml
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ const ClassSelector = ({ course }: Props) => {
<ClassSelectorDropdownController
course={course}
selectedClassIdHook={[selectedClassId, setSelectedClassId]}
previewHook={[preview, setPreview]}
display={display}
setPreview={setPreview}
removePreview={removePreview}
contentRef={classSelectorContentRef}
triggerRef={classSelectorTriggerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import ProfessorItem from "./ProfessorItem";
type Props = {
course: CourseInfo
selectedClassIdHook: [number | null, Dispatch<SetStateAction<number | null>>]
previewHook: [number | null, Dispatch<SetStateAction<number | null>>]
display: number
setPreview: Dispatch<SetStateAction<number | null>>
removePreview: () => void,
contentRef: any
triggerRef: any
Expand Down Expand Up @@ -48,16 +47,14 @@ const NoOptionsFound = ({ mobile }: { mobile: boolean }) => {
const ClassSelectorDropdownController = ({
course,
selectedClassIdHook,
previewHook,
display,
setPreview,
removePreview,
contentRef,
triggerRef
}: Props) => {
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));
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/contexts/ThemeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => { },
})

0 comments on commit 191757a

Please sign in to comment.