From b307f2e7a8b68df2261fb90275fc69687ca7f4e5 Mon Sep 17 00:00:00 2001
From: Albin Henriksson <albhe428@student.liu.se>
Date: Tue, 9 Mar 2021 18:09:45 +0100
Subject: [PATCH 1/2] Change linting rules and fix linting errors

---
 client/.eslintrc                                            | 4 +++-
 client/package.json                                         | 2 +-
 client/src/Main.tsx                                         | 2 +-
 client/src/pages/admin/AdminPage.tsx                        | 2 +-
 client/src/pages/admin/components/CompetitionManager.tsx    | 6 +++---
 client/src/pages/admin/components/Regions.tsx               | 2 +-
 client/src/pages/login/LoginPage.tsx                        | 2 +-
 client/src/pages/login/components/AdminLogin.tsx            | 4 ++--
 client/src/pages/login/components/CompetitionLogin.tsx      | 4 ++--
 .../src/pages/presentationEditor/PresentationEditorPage.tsx | 4 ++--
 .../presentationEditor/components/CompetitionSettings.tsx   | 5 +----
 .../pages/presentationEditor/components/SettingsPanel.tsx   | 2 +-
 client/src/pages/views/AudienceViewPage.tsx                 | 2 +-
 client/src/pages/views/JudgeViewPage.tsx                    | 2 +-
 client/src/pages/views/ParticipantViewPage.tsx              | 2 +-
 client/src/pages/views/ViewSelectPage.tsx                   | 4 ++--
 client/src/reportWebVitals.ts                               | 2 +-
 17 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/client/.eslintrc b/client/.eslintrc
index 9f14e433..3e2dbeb0 100644
--- a/client/.eslintrc
+++ b/client/.eslintrc
@@ -21,7 +21,9 @@
         "plugin:prettier/recommended"
     ],
     "rules": {
-      "prettier/prettier": ["warn"]
+      "prettier/prettier": ["warn", {
+       "endOfLine":"auto"
+     }]
     }
   }
   
diff --git a/client/package.json b/client/package.json
index 29f94e91..ccfa1134 100644
--- a/client/package.json
+++ b/client/package.json
@@ -53,7 +53,7 @@
     "build": "react-scripts build",
     "test": "react-scripts test",
     "eject": "react-scripts eject",
-    "lint": "eslint \"./src/**/*.{js,ts,tsx}\"",
+    "lint": "eslint \"./src/**/*.{ts,tsx}\"",
     "test:coverage": "react-scripts test --coverage --coverageDirectory=output/coverage/jest",
     "test:coverage:html": "npm test -- --coverage --watchAll=false --coverageDirectory=output/coverage/jest"
   },
diff --git a/client/src/Main.tsx b/client/src/Main.tsx
index 568d1010..0d85c12a 100644
--- a/client/src/Main.tsx
+++ b/client/src/Main.tsx
@@ -8,7 +8,7 @@ import JudgeViewPage from './pages/views/JudgeViewPage'
 import ParticipantViewPage from './pages/views/ParticipantViewPage'
 import ViewSelectPage from './pages/views/ViewSelectPage'
 
-const Main = () => {
+const Main: React.FC = () => {
   return (
     <BrowserRouter>
       <Switch>
diff --git a/client/src/pages/admin/AdminPage.tsx b/client/src/pages/admin/AdminPage.tsx
index a95bf04e..196595c9 100644
--- a/client/src/pages/admin/AdminPage.tsx
+++ b/client/src/pages/admin/AdminPage.tsx
@@ -50,7 +50,7 @@ const useStyles = makeStyles((theme: Theme) =>
   })
 )
 
-const AdminView: React.FC = (props) => {
+const AdminView: React.FC = () => {
   const classes = useStyles()
   const [openIndex, setOpenIndex] = React.useState(0)
   const { path, url } = useRouteMatch()
diff --git a/client/src/pages/admin/components/CompetitionManager.tsx b/client/src/pages/admin/components/CompetitionManager.tsx
index a85378ab..8a4b9afb 100644
--- a/client/src/pages/admin/components/CompetitionManager.tsx
+++ b/client/src/pages/admin/components/CompetitionManager.tsx
@@ -80,7 +80,7 @@ const useStyles = makeStyles((theme: Theme) =>
   })
 )
 
-const CompetitionManager: React.FC = (props) => {
+const CompetitionManager: React.FC = () => {
   const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null)
   const classes = useStyles()
   const yearInitialValue = 0
@@ -124,7 +124,7 @@ const CompetitionManager: React.FC = (props) => {
               <MenuItem value={noFilterText} onClick={() => setRegion(regionInitialValue)}>
                 {noFilterText}
               </MenuItem>
-              {regions.map((text, index) => (
+              {regions.map((text) => (
                 <MenuItem key={text} value={text} onClick={() => setRegion(text)}>
                   {text}
                 </MenuItem>
@@ -143,7 +143,7 @@ const CompetitionManager: React.FC = (props) => {
               <MenuItem value={noFilterText} onClick={() => setYear(yearInitialValue)}>
                 {noFilterText}
               </MenuItem>
-              {years.map((year, index) => (
+              {years.map((year) => (
                 <MenuItem key={year} value={year} onClick={() => setYear(year)}>
                   {year}
                 </MenuItem>
diff --git a/client/src/pages/admin/components/Regions.tsx b/client/src/pages/admin/components/Regions.tsx
index f40c8344..d58802d0 100644
--- a/client/src/pages/admin/components/Regions.tsx
+++ b/client/src/pages/admin/components/Regions.tsx
@@ -1,7 +1,7 @@
 import Typography from '@material-ui/core/Typography'
 import React from 'react'
 
-const Regions: React.FC = (props) => {
+const Regions: React.FC = () => {
   return (
     <Typography variant="h1" noWrap>
       Regions
diff --git a/client/src/pages/login/LoginPage.tsx b/client/src/pages/login/LoginPage.tsx
index 776e64b1..582154a2 100644
--- a/client/src/pages/login/LoginPage.tsx
+++ b/client/src/pages/login/LoginPage.tsx
@@ -23,7 +23,7 @@ const useStyles = makeStyles((theme: Theme) => ({
   },
 }))
 
-const LoginPage: React.FC = (props) => {
+const LoginPage: React.FC = () => {
   const classes = useStyles()
   const [loginTab, setLoginTab] = React.useState(0)
   return (
diff --git a/client/src/pages/login/components/AdminLogin.tsx b/client/src/pages/login/components/AdminLogin.tsx
index 77dc2a4c..f2624004 100644
--- a/client/src/pages/login/components/AdminLogin.tsx
+++ b/client/src/pages/login/components/AdminLogin.tsx
@@ -29,7 +29,7 @@ const accountSchema: Yup.SchemaOf<AccountLoginFormModel> = Yup.object({
 const handleAccountSubmit = async (values: AccountLoginFormModel, actions: FormikHelpers<AccountLoginFormModel>) => {
   await axios
     .post<ServerResponse>(`users/login`, values.model)
-    .then((res) => {
+    .then(() => {
       actions.resetForm()
     })
     .catch(({ response }) => {
@@ -41,7 +41,7 @@ const handleAccountSubmit = async (values: AccountLoginFormModel, actions: Formi
     })
 }
 
-const AdminLogin: React.FC = (props) => {
+const AdminLogin: React.FC = () => {
   const accountInitialValues: AccountLoginFormModel = {
     model: { email: '', password: '' },
   }
diff --git a/client/src/pages/login/components/CompetitionLogin.tsx b/client/src/pages/login/components/CompetitionLogin.tsx
index 2450196d..7ac9e6db 100644
--- a/client/src/pages/login/components/CompetitionLogin.tsx
+++ b/client/src/pages/login/components/CompetitionLogin.tsx
@@ -32,7 +32,7 @@ const handleCompetitionSubmit = async (
   console.log(values.model)
   await axios
     .post<ServerResponse>(`users/login`, { code: values.model.code })
-    .then((res) => {
+    .then(() => {
       actions.resetForm()
     })
     .catch(({ response }) => {
@@ -44,7 +44,7 @@ const handleCompetitionSubmit = async (
     })
 }
 
-const CompetitionLogin: React.FC = (props) => {
+const CompetitionLogin: React.FC = () => {
   const competitionInitialValues: CompetitionLoginFormModel = {
     model: { code: '' },
   }
diff --git a/client/src/pages/presentationEditor/PresentationEditorPage.tsx b/client/src/pages/presentationEditor/PresentationEditorPage.tsx
index c48e8958..97da7889 100644
--- a/client/src/pages/presentationEditor/PresentationEditorPage.tsx
+++ b/client/src/pages/presentationEditor/PresentationEditorPage.tsx
@@ -68,7 +68,7 @@ interface CompetitionParams {
   id: string
 }
 
-const PresentationEditorPage: React.FC = (props) => {
+const PresentationEditorPage: React.FC = () => {
   const classes = useStyles()
   const params: CompetitionParams = useParams()
   return (
@@ -103,7 +103,7 @@ const PresentationEditorPage: React.FC = (props) => {
         <div className={classes.toolbar} />
         <Divider />
         <List>
-          {slides.map((slide, index) => (
+          {slides.map((slide) => (
             <ListItem className="slide-list-item" divider button key={slide.name}>
               <ListItemText primary={slide.name} />
             </ListItem>
diff --git a/client/src/pages/presentationEditor/components/CompetitionSettings.tsx b/client/src/pages/presentationEditor/components/CompetitionSettings.tsx
index 72478634..6b555abc 100644
--- a/client/src/pages/presentationEditor/components/CompetitionSettings.tsx
+++ b/client/src/pages/presentationEditor/components/CompetitionSettings.tsx
@@ -24,11 +24,8 @@ const useStyles = makeStyles((theme: Theme) =>
     },
   })
 )
-interface TeamListItemProps {
-  name: string
-}
 
-const CompetitionSettings: React.FC = (props) => {
+const CompetitionSettings: React.FC = () => {
   const classes = useStyles()
   const initialList = [
     { id: '1', name: 'Lag1' },
diff --git a/client/src/pages/presentationEditor/components/SettingsPanel.tsx b/client/src/pages/presentationEditor/components/SettingsPanel.tsx
index 946befe7..00fc1962 100644
--- a/client/src/pages/presentationEditor/components/SettingsPanel.tsx
+++ b/client/src/pages/presentationEditor/components/SettingsPanel.tsx
@@ -17,7 +17,7 @@ function TabContent(props: TabPanelProps) {
   return <div>3</div>
 }
 
-const SettingsPanel: React.FC = (props) => {
+const SettingsPanel: React.FC = () => {
   const [activeTab, setActiveTab] = React.useState(0)
   return (
     <div>
diff --git a/client/src/pages/views/AudienceViewPage.tsx b/client/src/pages/views/AudienceViewPage.tsx
index f0cd70bc..45ec132d 100644
--- a/client/src/pages/views/AudienceViewPage.tsx
+++ b/client/src/pages/views/AudienceViewPage.tsx
@@ -1,6 +1,6 @@
 import React from 'react'
 
-const AudienceViewPage: React.FC = (props) => {
+const AudienceViewPage: React.FC = () => {
   return <div>Publik</div>
 }
 
diff --git a/client/src/pages/views/JudgeViewPage.tsx b/client/src/pages/views/JudgeViewPage.tsx
index 0051152b..457ebe08 100644
--- a/client/src/pages/views/JudgeViewPage.tsx
+++ b/client/src/pages/views/JudgeViewPage.tsx
@@ -1,6 +1,6 @@
 import React from 'react'
 
-const JudgeViewPage: React.FC = (props) => {
+const JudgeViewPage: React.FC = () => {
   return <div>Judge</div>
 }
 
diff --git a/client/src/pages/views/ParticipantViewPage.tsx b/client/src/pages/views/ParticipantViewPage.tsx
index 6a22cd44..a5ff1f4f 100644
--- a/client/src/pages/views/ParticipantViewPage.tsx
+++ b/client/src/pages/views/ParticipantViewPage.tsx
@@ -1,6 +1,6 @@
 import React from 'react'
 
-const ParticipantViewPage: React.FC = (props) => {
+const ParticipantViewPage: React.FC = () => {
   return <div>Deltagare</div>
 }
 
diff --git a/client/src/pages/views/ViewSelectPage.tsx b/client/src/pages/views/ViewSelectPage.tsx
index 81decf7c..b7b753fa 100644
--- a/client/src/pages/views/ViewSelectPage.tsx
+++ b/client/src/pages/views/ViewSelectPage.tsx
@@ -3,8 +3,8 @@ import React from 'react'
 import { Link, useRouteMatch } from 'react-router-dom'
 import './ViewSelectPage.css'
 
-const ViewSelectPage: React.FC = (props) => {
-  const { path, url } = useRouteMatch()
+const ViewSelectPage: React.FC = () => {
+  const url = useRouteMatch().url
   return (
     <div className="root">
       <div className="button-group">
diff --git a/client/src/reportWebVitals.ts b/client/src/reportWebVitals.ts
index 57a24a21..a832dfa7 100644
--- a/client/src/reportWebVitals.ts
+++ b/client/src/reportWebVitals.ts
@@ -1,6 +1,6 @@
 import { ReportHandler } from 'web-vitals'
 
-const reportWebVitals = (onPerfEntry?: ReportHandler) => {
+const reportWebVitals: () => void = (onPerfEntry?: ReportHandler) => {
   if (onPerfEntry && onPerfEntry instanceof Function) {
     import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
       getCLS(onPerfEntry)
-- 
GitLab


From c712faae4d51ae877e1ce4c4df7949da53738a90 Mon Sep 17 00:00:00 2001
From: Albin Henriksson <albhe428@student.liu.se>
Date: Tue, 9 Mar 2021 18:13:39 +0100
Subject: [PATCH 2/2] fix last warning

---
 client/src/index.tsx | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/client/src/index.tsx b/client/src/index.tsx
index e6048321..6d8b17f9 100644
--- a/client/src/index.tsx
+++ b/client/src/index.tsx
@@ -23,10 +23,7 @@ declare global {
 // const store = createStore(allReducers, composeEnhancers(applyMiddleware()))
 
 // simple store with plugin
-const store = createStore(
-  allReducers,
-  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
-)
+const store = createStore(allReducers, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__())
 
 // Provider wraps the app component so that it can access store
 ReactDOM.render(
-- 
GitLab