Skip to content

Commit 1a490df

Browse files
committed
Fix remaining lint issues
1 parent b37f485 commit 1a490df

File tree

6 files changed

+33
-80
lines changed

6 files changed

+33
-80
lines changed

site/components/Form/FormCloseButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const FormCloseButton: React.FC<FormCloseButtonProps> = ({ onClose }) =>
2323
return () => {
2424
document.body.removeEventListener("keydown", handleKeyPress, false)
2525
}
26-
}, [])
26+
}, [onClose])
2727

2828
return (
2929
<IconButton className={styles.closeButton} onClick={onClose} size="medium">

site/contexts/UserContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ const UserContext = React.createContext<UserContext>({
2525

2626
export const useUser = (redirectOnError = false): UserContext => {
2727
const ctx = useContext(UserContext)
28-
const router = useRouter()
28+
const { push, asPath } = useRouter()
2929

3030
const requestError = ctx.error
3131
useEffect(() => {
3232
if (redirectOnError && requestError) {
3333
// 'void' means we are ignoring handling the promise returned
3434
// from router.push (and lets the linter know we're OK with that!)
35-
void router.push({
35+
void push({
3636
pathname: "/login",
3737
query: {
38-
redirect: router.asPath,
38+
redirect: asPath,
3939
},
4040
})
4141
}
42-
}, [redirectOnError, requestError])
42+
}, [asPath, push, redirectOnError, requestError])
4343

4444
return ctx
4545
}

site/jest.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ module.exports = {
2424
displayName: "lint",
2525
runner: "jest-runner-eslint",
2626
testMatch: ["<rootDir>/**/*.js", "<rootDir>/**/*.ts", "<rootDir>/**/*.tsx"],
27-
testPathIgnorePatterns: ["/.next/", "/out/", "/_jest/", "jest.config.js", "jest-runner.*.js", "next.config.js"],
27+
testPathIgnorePatterns: [
28+
"/.next/",
29+
"/out/",
30+
"/_jest/",
31+
"dev.ts",
32+
"jest.config.js",
33+
"jest-runner.*.js",
34+
"next.config.js",
35+
],
2836
},
2937
],
3038
collectCoverageFrom: [

site/pages/projects/[organization]/[project]/create.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react"
1+
import React, { useCallback } from "react"
22
import { makeStyles } from "@material-ui/core/styles"
33
import { useRouter } from "next/router"
44
import useSWR from "swr"
@@ -10,14 +10,24 @@ import { FullScreenLoader } from "../../../../components/Loader/FullScreenLoader
1010
import { CreateWorkspaceForm } from "../../../../forms/CreateWorkspaceForm"
1111

1212
const CreateWorkspacePage: React.FC = () => {
13-
const router = useRouter()
13+
const { push, query } = useRouter()
1414
const styles = useStyles()
1515
const { me } = useUser(/* redirectOnError */ true)
16-
const { organization, project: projectName } = router.query
16+
const { organization, project: projectName } = query
1717
const { data: project, error: projectError } = useSWR<API.Project, Error>(
1818
`/api/v2/projects/${organization}/${projectName}`,
1919
)
2020

21+
const onCancel = useCallback(async () => {
22+
await push(`/projects/${organization}/${projectName}`)
23+
}, [push, organization, projectName])
24+
25+
const onSubmit = async (req: API.CreateWorkspaceRequest) => {
26+
const workspace = await API.Workspace.create(req)
27+
await push(`/workspaces/me/${workspace.name}`)
28+
return workspace
29+
}
30+
2131
if (projectError) {
2232
return <ErrorSummary error={projectError} />
2333
}
@@ -26,16 +36,6 @@ const CreateWorkspacePage: React.FC = () => {
2636
return <FullScreenLoader />
2737
}
2838

29-
const onCancel = async () => {
30-
await router.push(`/projects/${organization}/${projectName}`)
31-
}
32-
33-
const onSubmit = async (req: API.CreateWorkspaceRequest) => {
34-
const workspace = await API.Workspace.create(req)
35-
await router.push(`/workspaces/me/${workspace.name}`)
36-
return workspace
37-
}
38-
3939
return (
4040
<div className={styles.root}>
4141
<CreateWorkspaceForm onCancel={onCancel} onSubmit={onSubmit} project={project} />

site/pages/projects/create.tsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

site/pages/workspaces/[user]/[workspace].tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ const WorkspacesPage: React.FC = () => {
2727
// So if the user is the same as 'me', use 'me' as the parameter
2828
const normalizedUserParam = me && userParam === me.id ? "me" : userParam
2929

30-
// The SWR API expects us to 'throw' if the query isn't ready yet, so these casts to `any` are OK
31-
// because the API expects exceptions.
32-
return `/api/v2/workspaces/${(normalizedUserParam as any).toString()}/${(workspaceParam as any).toString()}`
30+
// The SWR API expects us to 'throw' if the query isn't ready yet:
31+
if (normalizedUserParam === null || workspaceParam === null) {
32+
throw "Data not yet available to make API call"
33+
}
34+
35+
return `/api/v2/workspaces/${normalizedUserParam}/${workspaceParam}`
3336
})
3437

3538
if (workspaceError) {

0 commit comments

Comments
 (0)