Skip to content

chore: bump the eslint group in /site with 5 updates #8636

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

Merged
merged 7 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix redudant types
  • Loading branch information
BrunoQuaresma committed Jul 27, 2023
commit d753f0e32f4d949b2323701ebe2fd2a59fd06c7c
2 changes: 0 additions & 2 deletions site/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ rules:
"@typescript-eslint/restrict-template-expressions": "off"
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
"@typescript-eslint/unbound-method": "off"
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
"@typescript-eslint/no-redundant-type-constituents": "off"
# We're disabling the `no-namespace` rule to use a pattern of defining an interface,
# and then defining functions that operate on that data via namespace. This is helpful for
# dealing with immutable objects. This is a common pattern that shows up in some other
Expand Down
10 changes: 3 additions & 7 deletions site/src/api/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const mapApiErrorToFieldErrors = (
* @returns error's message if ApiError or Error, else defaultMessage
*/
export const getErrorMessage = (
error: Error | ApiError | unknown,
error: unknown,
defaultMessage: string,
): string =>
isApiError(error)
Expand All @@ -74,19 +74,15 @@ export const getErrorMessage = (
* @returns a combined validation error message if the error is an ApiError
* and contains validation messages for different form fields.
*/
export const getValidationErrorMessage = (
error: Error | ApiError | unknown,
): string => {
export const getValidationErrorMessage = (error: unknown): string => {
const validationErrors =
isApiError(error) && error.response.data.validations
? error.response.data.validations
: []
return validationErrors.map((error) => error.detail).join("\n")
}

export const getErrorDetail = (
error: Error | ApiError | unknown,
): string | undefined | null =>
export const getErrorDetail = (error: unknown): string | undefined | null =>
isApiError(error)
? error.response.data.detail
: error instanceof Error
Expand Down
6 changes: 2 additions & 4 deletions site/src/components/DeploySettingsLayout/Option.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeStyles } from "@mui/styles"
import { PropsWithChildren, FC, ReactNode } from "react"
import { PropsWithChildren, FC } from "react"
import { MONOSPACE_FONT_FAMILY } from "theme/constants"
import { DisabledBadge, EnabledBadge } from "./Badges"

Expand All @@ -19,9 +19,7 @@ const NotSet: FC = () => {
return <span className={styles.optionValue}>Not set</span>
}

export const OptionValue: FC<{ children?: ReactNode | unknown }> = ({
children,
}) => {
export const OptionValue: FC<{ children?: unknown }> = ({ children }) => {
const styles = useStyles()

if (typeof children === "boolean") {
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/DeploySettingsLayout/Options.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const defaultOption: DeploymentOption = {
describe("optionValue", () => {
it.each<{
option: DeploymentOption
expected: string | string[] | unknown
expected: unknown
}>([
{
option: {
Expand Down
4 changes: 1 addition & 3 deletions site/src/components/DeploySettingsLayout/OptionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ const OptionsTable: FC<{
}

// optionValue is a helper function to format the value of a specific deployment options
export function optionValue(
option: DeploymentOption,
): string[] | string | unknown {
export function optionValue(option: DeploymentOption) {
switch (option.name) {
case "Max Token Lifetime":
case "Session Duration":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface AccountFormProps {
isLoading: boolean
initialValues: AccountFormValues
onSubmit: (values: AccountFormValues) => void
updateProfileError?: Error | unknown
updateProfileError?: unknown
// initialTouched is only used for testing the error state of the form.
initialTouched?: FormikTouched<AccountFormValues>
}
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Workspace/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export interface WorkspaceProps {
canChangeVersions: boolean
hideSSHButton?: boolean
hideVSCodeDesktopButton?: boolean
workspaceErrors: Partial<Record<WorkspaceErrors, Error | unknown>>
workspaceErrors: Partial<Record<WorkspaceErrors, unknown>>
buildInfo?: TypesGen.BuildInfoResponse
sshPrefix?: string
template?: TypesGen.Template
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/WorkspacesTable/WorkspacesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface WorkspacesTableProps {
workspaces?: Workspace[]
isUsingFilter: boolean
onUpdateWorkspace: (workspace: Workspace) => void
error?: Error | unknown
error?: unknown
}

export const WorkspacesTable: FC<WorkspacesTableProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface TableBodyProps {
workspaces?: Workspace[]
isUsingFilter: boolean
onUpdateWorkspace: (workspace: Workspace) => void
error?: Error | unknown
error?: unknown
}

export const WorkspacesTableBody: FC<
Expand Down
2 changes: 1 addition & 1 deletion site/src/contexts/ProxyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface ProxyContextValue {
// isFetched is true when the 'proxies' api call is complete.
isFetched: boolean
isLoading: boolean
error?: Error | unknown
error?: unknown
// proxyLatencies is a map of proxy id to latency report. If the proxyLatencies[proxy.id] is undefined
// then the latency has not been fetched yet. Calculations happen async for each proxy in the list.
// Refer to the returned report for a given proxy for more information.
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/AuditPage/AuditPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface AuditPageViewProps {
onPageChange: (page: number) => void
isNonInitialPage: boolean
isAuditLogVisible: boolean
error?: Error | unknown
error?: unknown
filterProps: ComponentProps<typeof AuditFilter>
}

Expand Down
4 changes: 2 additions & 2 deletions site/src/pages/CreateTokenPage/CreateTokenForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import { Stack } from "components/Stack/Stack"
interface CreateTokenFormProps {
form: FormikContextType<CreateTokenData>
maxTokenLifetime?: number
formError: Error | unknown
setFormError: (arg0: Error | unknown) => void
formError: unknown
setFormError: (arg0: unknown) => void
isCreating: boolean
creationFailed: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/CreateTokenPage/CreateTokenPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const CreateTokenPage: FC = () => {
queryFn: getTokenConfig,
})

const [formError, setFormError] = useState<unknown | undefined>(undefined)
const [formError, setFormError] = useState<unknown>(undefined)

const onCreateSuccess = () => {
displaySuccess(t("createToken.createSuccess"))
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/GroupsPage/CreateGroupPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const validationSchema = Yup.object({

export type CreateGroupPageViewProps = {
onSubmit: (data: CreateGroupRequest) => void
formErrors: unknown | undefined
formErrors?: unknown
isLoading: boolean
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const Language = {
export interface SSHKeysPageViewProps {
isLoading: boolean
hasLoaded: boolean
getSSHKeyError?: Error | unknown
regenerateSSHKeyError?: Error | unknown
getSSHKeyError?: unknown
regenerateSSHKeyError?: unknown
sshKey?: GitSSHKey
onRegenerateClick: () => void
}
Expand Down
4 changes: 2 additions & 2 deletions site/src/pages/UserSettingsPage/TokensPage/TokensPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ const lastUsedOrNever = (lastUsed: string) => {

export interface TokensPageViewProps {
tokens?: APIKeyWithOwner[]
getTokensError?: Error | unknown
getTokensError?: unknown
isLoading: boolean
hasLoaded: boolean
onDelete: (token: APIKeyWithOwner) => void
deleteTokenError?: Error | unknown
deleteTokenError?: unknown
}

export const TokensPageView: FC<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import { ErrorAlert } from "components/Alert/ErrorAlert"
export interface WorkspaceProxyViewProps {
proxies?: Region[]
proxyLatencies?: Record<string, ProxyLatencyReport>
getWorkspaceProxiesError?: Error | unknown
getWorkspaceProxiesError?: unknown
isLoading: boolean
hasLoaded: boolean
preferredProxy?: Region
selectProxyError?: Error | unknown
selectProxyError?: unknown
}

export const WorkspaceProxyView: FC<
Expand Down
4 changes: 2 additions & 2 deletions site/src/xServices/appearance/appearanceXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { AppearanceConfig } from "../../api/typesGenerated"

export type AppearanceContext = {
appearance?: AppearanceConfig
getAppearanceError?: Error | unknown
setAppearanceError?: Error | unknown
getAppearanceError?: unknown
setAppearanceError?: unknown
preview: boolean
}

Expand Down
2 changes: 1 addition & 1 deletion site/src/xServices/auth/authMethodsXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as API from "api/api"

export interface AuthMethodsContext {
authMethods?: TypeGen.AuthMethods
error?: Error | unknown
error?: unknown
}

export const authMethodsXService = createMachine(
Expand Down
4 changes: 2 additions & 2 deletions site/src/xServices/auth/authXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ const signOut = async () => {
} as UnauthenticatedData
}
export interface AuthContext {
error?: Error | unknown
updateProfileError?: Error | unknown
error?: unknown
updateProfileError?: unknown
data?: AuthData
}

Expand Down
2 changes: 1 addition & 1 deletion site/src/xServices/buildInfo/buildInfoXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as API from "../../api/api"
import * as TypesGen from "../../api/typesGenerated"

export interface BuildInfoContext {
getBuildInfoError?: Error | unknown
getBuildInfoError?: unknown
buildInfo?: TypesGen.BuildInfoResponse
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type CreateWorkspaceContext = {
templateName: string
mode: CreateWorkspaceMode
defaultName: string
error?: Error | unknown
error?: unknown
// Form
template?: Template
parameters?: TemplateVersionParameter[]
Expand Down
2 changes: 1 addition & 1 deletion site/src/xServices/entitlements/entitlementsXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Entitlements } from "../../api/typesGenerated"

export type EntitlementsContext = {
entitlements?: Entitlements
getEntitlementsError?: Error | unknown
getEntitlementsError?: unknown
}

export const entitlementsMachine = createMachine(
Expand Down
2 changes: 1 addition & 1 deletion site/src/xServices/experiments/experimentsMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createMachine, assign } from "xstate"

export interface ExperimentsContext {
experiments?: Experiment[]
getExperimentsError?: Error | unknown
getExperimentsError?: unknown
}

export const experimentsMachine = createMachine(
Expand Down
2 changes: 1 addition & 1 deletion site/src/xServices/quotas/quotasXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { WorkspaceQuota } from "../../api/typesGenerated"
export type QuotaContext = {
username: string
quota?: WorkspaceQuota
getQuotaError?: Error | unknown
getQuotaError?: unknown
}

export const quotaMachine = createMachine(
Expand Down
2 changes: 1 addition & 1 deletion site/src/xServices/roles/siteRolesXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const Language = {
type SiteRolesContext = {
hasPermission: boolean
roles?: TypesGen.AssignableRoles[]
getRolesError: Error | unknown
getRolesError: unknown
}

export const siteRolesMachine = createMachine(
Expand Down
4 changes: 2 additions & 2 deletions site/src/xServices/template/templateVariablesXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type TemplateVariablesContext = {
createTemplateVersionRequest?: CreateTemplateVersionRequest
newTemplateVersion?: TemplateVersion

getTemplateDataError?: Error | unknown
updateTemplateError?: Error | unknown
getTemplateDataError?: unknown
updateTemplateError?: unknown

jobError?: TemplateVersion["job"]["error"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface TemplateVersionMachineContext {
template?: Template
currentVersion?: TemplateVersion
currentFiles?: TemplateVersionFiles
error?: Error | unknown
error?: unknown
// Get file diffs
previousVersion?: TemplateVersion
previousFiles?: TemplateVersionFiles
Expand Down
2 changes: 1 addition & 1 deletion site/src/xServices/templates/templatesXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface TemplatesContext {
permissions: Permissions
templates?: TypesGen.Template[]
examples?: TypesGen.TemplateExample[]
error?: Error | unknown
error?: unknown
}

export const templatesMachine = createMachine(
Expand Down
8 changes: 4 additions & 4 deletions site/src/xServices/terminal/terminalXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import * as Types from "../../api/types"
import * as TypesGen from "../../api/typesGenerated"

export interface TerminalContext {
workspaceError?: Error | unknown
workspaceError?: unknown
workspace?: TypesGen.Workspace
workspaceAgent?: TypesGen.WorkspaceAgent
workspaceAgentError?: Error | unknown
workspaceAgentError?: unknown
websocket?: WebSocket
websocketError?: Error | unknown
websocketError?: unknown
websocketURL?: string
websocketURLError?: Error | unknown
websocketURLError?: unknown

// Assigned by connecting!
// The workspace agent is entirely optional. If the agent is omitted the
Expand Down
2 changes: 1 addition & 1 deletion site/src/xServices/updateCheck/updateCheckXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { checks, Permissions } from "xServices/auth/authXService"
export interface UpdateCheckContext {
permissions: Permissions
updateCheck?: UpdateCheckResponse
error?: Error | unknown
error?: unknown
}

export type UpdateCheckEvent = { type: "DISMISS" }
Expand Down
12 changes: 6 additions & 6 deletions site/src/xServices/users/usersXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ export interface UsersContext {
// Get users
users?: TypesGen.User[]
filter: string
getUsersError?: Error | unknown
getUsersError?: unknown
// Suspend user
userIdToSuspend?: TypesGen.User["id"]
usernameToSuspend?: TypesGen.User["username"]
suspendUserError?: Error | unknown
suspendUserError?: unknown
// Delete user
userIdToDelete?: TypesGen.User["id"]
usernameToDelete?: TypesGen.User["username"]
deleteUserError?: Error | unknown
deleteUserError?: unknown
// Activate user
userIdToActivate?: TypesGen.User["id"]
usernameToActivate?: TypesGen.User["username"]
activateUserError?: Error | unknown
activateUserError?: unknown
// Reset user password
userIdToResetPassword?: TypesGen.User["id"]
resetUserPasswordError?: Error | unknown
resetUserPasswordError?: unknown
newUserPassword?: string
// Update user roles
userIdToUpdateRoles?: TypesGen.User["id"]
updateUserRolesError?: Error | unknown
updateUserRolesError?: unknown
paginationContext: PaginationContext
paginationRef: PaginationMachineRef
count: number
Expand Down
8 changes: 4 additions & 4 deletions site/src/xServices/workspace/workspaceXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ export interface WorkspaceContext {
build?: TypesGen.WorkspaceBuild
// Builds
builds?: TypesGen.WorkspaceBuild[]
getBuildsError?: Error | unknown
getBuildsError?: unknown
missedParameters?: TypesGen.TemplateVersionParameter[]
// error creating a new WorkspaceBuild
buildError?: Error | unknown
buildError?: unknown
cancellationMessage?: Types.Message
cancellationError?: Error | unknown
cancellationError?: unknown
// debug
createBuildLogLevel?: TypesGen.CreateWorkspaceBuildRequest["log_level"]
// SSH Config
Expand Down Expand Up @@ -92,7 +92,7 @@ export type WorkspaceEvent =
checkRefresh?: boolean
data?: TypesGen.ServerSentEvent["data"]
}
| { type: "EVENT_SOURCE_ERROR"; error: Error | unknown }
| { type: "EVENT_SOURCE_ERROR"; error: unknown }
| { type: "INCREASE_DEADLINE"; hours: number }
| { type: "DECREASE_DEADLINE"; hours: number }
| { type: "RETRY_BUILD" }
Expand Down
Loading