Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lint workflow #272

Merged
merged 3 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/core-web-vitals", "next/typescript"]
}
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: lint

on:
push:
branches: [main, development]
pull_request:
branches: [main, development]

jobs:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- name: Setup repo
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- run: npm ci
- run: npm run lint
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/node_modules
**/.next
**/.husky
**/.github
public/*
LICENSE
.prettierignore
Expand Down
8 changes: 1 addition & 7 deletions app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import styles from "./Error.module.scss";
import Link from "next/link";
import clsx from "clsx";

const Error = ({
error,
reset
}: {
error: Error & { digest?: string };
reset: () => void;
}) => {
const Error = ({ error }: { error: Error & { digest?: string } }) => {
const [showDetails, setShowDetails] = useState(false);

const handleToggleDetails = () => {
Expand Down
4 changes: 1 addition & 3 deletions app/register/(general)/(form)/transportation/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Checkboxes, {
CheckboxOption
} from "@/components/Form/Checkboxes/Checkboxes";
import Checkboxes from "@/components/Form/Checkboxes/Checkboxes";
import styles from "./styles.module.scss";
import React from "react";
import {
Expand Down
7 changes: 1 addition & 6 deletions app/register/challenge/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ import FOREGROUND from "@/public/registration/pro/foreground.svg";
import EXAMPLE_CHALLENGE_GRAPHIC from "@/public/registration/example_challenge_graphic.svg";

import NavigationButton from "@/components/Form/NavigationButton/NavigationButton";
import {
isAuthenticated,
authenticate,
getRegistrationOrDefault,
getChallenge
} from "@/util/api";
import { isAuthenticated, authenticate, getChallenge } from "@/util/api";
import { usePathname, useRouter } from "next/navigation";
import { useState, useEffect } from "react";
import Loading from "@/components/Loading/Loading";
Expand Down
3 changes: 2 additions & 1 deletion components/Form/Checkboxes/Checkboxes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const Checkboxes: React.FC<PropTypes> = ({
name,
label,
options = [],
hideErrors,
className,
style,
threeColEnabled,
Expand All @@ -57,6 +56,7 @@ const Checkboxes: React.FC<PropTypes> = ({
const isValueOther = (value: string) =>
options.every(option => option.value !== value);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const selectedValues: any[] = useMemo(() => {
return value || [];
}, [field]);
Expand Down Expand Up @@ -86,6 +86,7 @@ const Checkboxes: React.FC<PropTypes> = ({
checked: boolean,
{ value, isRadio, isOther }: CheckboxOption
) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let newSelectedValues: any[] = [];

// if checked === true and the option isn't already selected, select it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const StyledCheckbox: React.FC<PropTypes> = ({
label,
checked,
className,
radio,
style,
blue,
...props
Expand Down
2 changes: 0 additions & 2 deletions components/Form/Checkboxes/StyledInput/StyledInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ type StyledInputProps = {
};

const StyledInput: React.FC<StyledInputProps> = ({
name,
className,
multiline,
required,
...props
}) => {
return multiline ? (
Expand Down
2 changes: 1 addition & 1 deletion components/Form/DropdownBox/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Dropdown: React.FC<DropdownProps> = ({
const [field, meta, helpers] = useField(name);
const showFeedback = meta.error && meta.touched;

let formattedOptions = options.map(option => ({
const formattedOptions = options.map(option => ({
label: option,
value: option
}));
Expand Down
1 change: 1 addition & 0 deletions components/Form/NavigationButton/NavigationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const NavigationButton: React.FC<NavButtonProps> = ({
// Function to handle the Enter key press
const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {
if (event.key === "Enter" || event.key === "Return") {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onClick?.(event as any); // Trigger the onClick function
}
};
Expand Down
2 changes: 1 addition & 1 deletion components/Form/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const TextInput: React.FC<TextInputProps> = ({
required,
...props
}) => {
const [field, meta] = useField(name);
const [, meta] = useField(name);
const showFeedback = meta.error && meta.touched;

return (
Expand Down
7 changes: 2 additions & 5 deletions components/Registration/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, {
useRef,
useState
} from "react";
import { Form, Formik, FormikHelpers, FormikProps } from "formik";
import { Form, Formik, FormikProps } from "formik";
import { RegistrationData } from "@/util/types";
import { usePathname, useRouter } from "next/navigation";
import NavigationButton from "../Form/NavigationButton/NavigationButton";
Expand Down Expand Up @@ -129,10 +129,7 @@ const Registration: React.FC<PropTypes> = ({
);
};

const handleSubmit = async (
values: RegistrationData,
helpers: FormikHelpers<RegistrationData>
) => {
const handleSubmit = async (values: RegistrationData) => {
const schemaKeys = Object.keys(schema.fields);
const newIgnore = Object.fromEntries(
Object.entries(ignoredFields).filter(
Expand Down
1 change: 1 addition & 0 deletions components/Registration/RegistrationResponseGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const RegistrationResponseGroup: React.FC<{
responseProvided = true;
}
const fieldOptionsHaveLabels = field.options.every(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(option: any) => option.label
);
if (fieldOptionsHaveLabels) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint": "next lint && npx prettier . --check",
"format": "npx prettier . --write",
"prepare": "husky"
},
Expand Down
Loading