From 46e724e731aa7b42221bfafff6f3c634d720634c Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Sun, 23 Aug 2020 12:27:56 -0500 Subject: [PATCH] feat: add pre commit hook to lint frontend & fix warnings --- .pre-commit-config.yaml | 9 + frontend/package.json | 3 +- frontend/src/Admin/index.tsx | 29 +- frontend/src/App/Routes.tsx | 5 +- frontend/src/App/ThemeStyles.ts | 4 +- frontend/src/App/TopNavbar.tsx | 23 +- frontend/src/App/index.tsx | 2 +- frontend/src/Auth/index.tsx | 11 +- frontend/src/Install/index.tsx | 11 +- frontend/src/Profile/index.tsx | 10 +- frontend/src/Projects/Project/Board/index.tsx | 45 +-- .../src/Projects/Project/Details/index.tsx | 33 +- frontend/src/Projects/Project/index.tsx | 11 +- frontend/src/Projects/index.tsx | 28 +- frontend/src/Teams/Members/index.tsx | 13 +- frontend/src/Teams/index.tsx | 18 +- frontend/src/index.tsx | 9 +- .../shared/components/Admin/Admin.stories.tsx | 10 +- .../src/shared/components/Admin/index.tsx | 123 +----- .../components/Button/Button.stories.tsx | 2 +- frontend/src/shared/components/Card/index.tsx | 11 +- .../Checklist/Checklist.stories.tsx | 11 +- .../ControlledInput/Input.stories.tsx | 4 +- .../DueDateManager/DueDateManager.stories.tsx | 4 +- .../components/DueDateManager/index.tsx | 22 +- .../shared/components/Input/Input.stories.tsx | 4 +- .../shared/components/List/List.stories.tsx | 9 +- .../src/shared/components/Lists/index.tsx | 2 +- .../src/shared/components/Member/index.tsx | 3 +- .../shared/components/MemberManager/index.tsx | 5 +- .../shared/components/MiniProfile/index.tsx | 2 +- .../NewProject/NewProject.stories.tsx | 7 +- .../shared/components/NewProject/index.tsx | 23 +- .../PopupMenu/PopupMenu.stories.tsx | 381 ------------------ .../src/shared/components/PopupMenu/Styles.ts | 1 - .../src/shared/components/PopupMenu/index.tsx | 7 +- .../QuickCardEditor.stories.tsx | 7 +- .../src/shared/components/Select/index.tsx | 23 +- .../shared/components/TaskDetails/index.tsx | 12 +- .../src/shared/components/TopNavbar/Styles.ts | 1 + .../src/shared/components/TopNavbar/index.tsx | 2 +- .../src/shared/graphql/user/updateUserRole.ts | 16 +- frontend/src/shared/undraw/NoData.tsx | 6 +- frontend/src/shared/utils/noop.ts | 1 + frontend/src/wdy.ts | 8 - magefile.go | 15 + 46 files changed, 256 insertions(+), 730 deletions(-) delete mode 100644 frontend/src/shared/components/PopupMenu/PopupMenu.stories.tsx create mode 100644 frontend/src/shared/utils/noop.ts delete mode 100644 frontend/src/wdy.ts diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5316be..6562667 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,13 @@ repos: +- repo: local + hooks: + - id: eslint + name: eslint + entry: go run cmd/mage/main.go frontend:lint + language: system + files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx + types: [file] + pass_filenames: false - hooks: - id: check-yaml - id: end-of-file-fixer diff --git a/frontend/package.json b/frontend/package.json index 04395ff..3aa1f1d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -71,7 +71,8 @@ "storybook": "start-storybook -p 9009 -s public", "build-storybook": "build-storybook -s public", "generate": "graphql-codegen", - "lint": "eslint --ext js,ts,tsx src" + "lint": "eslint --ext js,ts,tsx src", + "tsc": "tsc" }, "eslintConfig": { "extends": "react-app" diff --git a/frontend/src/Admin/index.tsx b/frontend/src/Admin/index.tsx index 7b03de9..45dfa92 100644 --- a/frontend/src/Admin/index.tsx +++ b/frontend/src/Admin/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState, useContext } from 'react'; +import React, { useEffect } from 'react'; import Admin from 'shared/components/Admin'; import Select from 'shared/components/Select'; import GlobalTopNavbar from 'App/TopNavbar'; @@ -16,8 +16,9 @@ import { useForm, Controller } from 'react-hook-form'; import { usePopup, Popup } from 'shared/components/PopupMenu'; import produce from 'immer'; import updateApolloCache from 'shared/utils/cache'; -import UserContext, { useCurrentUser } from 'App/context'; +import { useCurrentUser } from 'App/context'; import { Redirect } from 'react-router'; +import NOOP from 'shared/utils/noop'; const DeleteUserWrapper = styled.div` display: flex; @@ -37,6 +38,7 @@ const DeleteUserButton = styled(Button)` type DeleteUserPopupProps = { onDeleteUser: () => void; }; + const DeleteUserPopup: React.FC = ({ onDeleteUser }) => { return ( @@ -47,10 +49,12 @@ const DeleteUserPopup: React.FC = ({ onDeleteUser }) => { ); }; + type RoleCodeOption = { label: string; value: string; }; + type CreateUserData = { email: string; username: string; @@ -65,6 +69,7 @@ const CreateUserForm = styled.form` flex-direction: column; margin: 0 12px; `; + const CreateUserButton = styled(Button)` margin-top: 8px; padding: 6px 12px; @@ -85,7 +90,7 @@ type AddUserPopupProps = { }; const AddUserPopup: React.FC = ({ onAddUser }) => { - const { register, handleSubmit, errors, setValue, control } = useForm(); + const { register, handleSubmit, errors, control } = useForm(); const createUser = (data: CreateUserData) => { onAddUser(data); @@ -115,7 +120,7 @@ const AddUserPopup: React.FC = ({ onAddUser }) => { control={control} name="roleCode" rules={{ required: 'Role is required' }} - render={({ onChange, onBlur, value }) => ( + render={({ onChange, value }) => (