mirror of
https://github.com/coder/coder.git
synced 2026-11-12 12:45:36 +08:00
Noticed while running through the build steps (`make build`) that we were getting some lint warnings that weren't blocking build: ```sh ./pages/workspaces/[user]/[workspace].tsx 32:58 Warning: Unexpected any. Specify a different type. @typescript-eslint/no-explicit-any 32:96 Warning: Unexpected any. Specify a different type. @typescript-eslint/no-explicit-any ./components/Form/FormCloseButton.tsx 26:6 Warning: React Hook useEffect has a missing dependency: 'onClose'. Either include it or remove the dependency array. If 'onClose' changes too often, find the parent component that defines it and wrap that definition in useCallback. react-hooks/exhaustive-deps ./components/Navbar/UserDropdown.tsx 38:14 Warning: Unnecessary conditional, value is always truthy. @typescript-eslint/no-unnecessary-condition 68:10 Warning: Unnecessary conditional, value is always truthy. @typescript-eslint/no-unnecessary-condition ./components/Redirect.tsx 20:6 Warning: React Hook useEffect has missing dependencies: 'router' and 'to'. Either include them or remove the dependency array. react-hooks/exhaustive-deps ./components/SignIn/SignInForm.tsx 126:19 Warning: Unnecessary optional chain on a non-nullish value. @typescript-eslint/no-unnecessary-condition ``` It turns out our ESLint config wasn't being picked up, so I fixed that (it wasn't properly named). This PR turns warnings-as-errors on, fixes the issues, and also removes the "Project Create" page, because it isn't used at this time. Wanted to clean this up before on-boarding more FE developers
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import IconButton from "@material-ui/core/IconButton"
|
|
import { makeStyles } from "@material-ui/core/styles"
|
|
import Typography from "@material-ui/core/Typography"
|
|
import React, { useEffect } from "react"
|
|
import { CloseIcon } from "../Icons/Close"
|
|
|
|
export interface FormCloseButtonProps {
|
|
onClose: () => void
|
|
}
|
|
|
|
export const FormCloseButton: React.FC<FormCloseButtonProps> = ({ onClose }) => {
|
|
const styles = useStyles()
|
|
|
|
useEffect(() => {
|
|
const handleKeyPress = (event: KeyboardEvent) => {
|
|
if (event.key === "Escape") {
|
|
onClose()
|
|
}
|
|
}
|
|
|
|
document.body.addEventListener("keydown", handleKeyPress, false)
|
|
|
|
return () => {
|
|
document.body.removeEventListener("keydown", handleKeyPress, false)
|
|
}
|
|
}, [onClose])
|
|
|
|
return (
|
|
<IconButton className={styles.closeButton} onClick={onClose} size="medium">
|
|
<CloseIcon />
|
|
<Typography variant="caption" className={styles.label}>
|
|
ESC
|
|
</Typography>
|
|
</IconButton>
|
|
)
|
|
}
|
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
closeButton: {
|
|
position: "fixed",
|
|
top: theme.spacing(3),
|
|
right: theme.spacing(6),
|
|
opacity: 0.5,
|
|
color: theme.palette.text.primary,
|
|
"&:hover": {
|
|
opacity: 1,
|
|
},
|
|
},
|
|
label: {
|
|
position: "absolute",
|
|
left: "50%",
|
|
top: "100%",
|
|
transform: "translate(-50%, 50%)",
|
|
},
|
|
}))
|