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 17, 2024
1 parent 0d0a50c commit dceb9d4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/codeanalysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Code analysis

on:
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 @@ -111,8 +111,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 @@ -14,8 +14,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 @@ -49,16 +48,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 } = 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<Array<number>>(() => {
Expand Down Expand Up @@ -227,9 +224,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 @@ -264,9 +258,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 dceb9d4

Please sign in to comment.