Skip to content

chore(site): Add type checking #7441

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 5 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ site/e2e/test-results/*
site/e2e/states/*.json
site/playwright-report/*
site/.swc
site/dist/

# Make target for updating golden files (any dir).
.gen-golden
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ site/e2e/test-results/*
site/e2e/states/*.json
site/playwright-report/*
site/.swc
site/dist/

# Make target for updating golden files (any dir).
.gen-golden
Expand Down
1 change: 1 addition & 0 deletions site/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ e2e/test-results/*
e2e/states/*.json
playwright-report/*
.swc
dist/

# Make target for updating golden files (any dir).
.gen-golden
Expand Down
1 change: 1 addition & 0 deletions site/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ e2e/test-results/*
e2e/states/*.json
playwright-report/*
.swc
dist/

# Make target for updating golden files (any dir).
.gen-golden
Expand Down
7 changes: 4 additions & 3 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@
"react": "18.2.0",
"react-chartjs-2": "4.3.1",
"react-color": "2.19.3",
"react-confetti": "^6.1.0",
"react-confetti": "6.1.0",
"react-dom": "18.2.0",
"react-headless-tabs": "6.0.3",
"react-helmet-async": "1.3.0",
"react-i18next": "12.1.1",
"react-markdown": "8.0.3",
"react-router-dom": "6.4.1",
"react-syntax-highlighter": "15.5.0",
"react-use": "^17.4.0",
"react-use": "17.4.0",
"react-virtualized-auto-sizer": "1.0.7",
"react-window": "1.8.8",
"remark-gfm": "3.0.1",
Expand Down Expand Up @@ -145,7 +145,8 @@
"semver": "7.3.7",
"storybook": "7.0.4",
"storybook-react-context": "0.6.0",
"typescript": "4.8.2"
"typescript": "4.8.2",
"vite-plugin-checker": "0.6.0"
},
"browserslist": [
"chrome 66",
Expand Down
3 changes: 3 additions & 0 deletions site/src/__mocks__/monaco-editor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable eslint-comments/disable-enable-pair -- make the line below works */
/* eslint-disable @typescript-eslint/ban-ts-comment -- it is a mjs module */
// @ts-nocheck
const editor = {
defineTheme: () => {
//
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Stack } from "../../Stack/Stack"
type Icon = typeof HelpIcon

type Size = "small" | "medium"
interface HelpTooltipProps {
export interface HelpTooltipProps {
// Useful to test on storybook
open?: boolean
size?: Size
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Button from "@material-ui/core/Button"
import TextField from "@material-ui/core/TextField"
import { makeStyles } from "@material-ui/core/styles"
import { ApiErrorResponse } from "api/errors"
import { AlertBanner } from "components/AlertBanner/AlertBanner"
import { Fieldset } from "components/DeploySettingsLayout/Fieldset"
import { Header } from "components/DeploySettingsLayout/Header"
Expand All @@ -15,7 +14,7 @@ import { Link as RouterLink } from "react-router-dom"
type AddNewLicenseProps = {
onSaveLicenseKey: (license: string) => void
isSavingLicense: boolean
savingLicenseError?: ApiErrorResponse
savingLicenseError?: unknown
}

export const AddNewLicensePageView: FC<AddNewLicenseProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Example.args = {
activeVersion: MockTemplateVersion,
data: {
resources: [MockWorkspaceResource, MockWorkspaceResource2],
versions: [MockTemplateVersion],
daus: MockTemplateDAUResponse,
},
}
Expand All @@ -37,7 +36,6 @@ NoIcon.args = {
activeVersion: MockTemplateVersion,
data: {
resources: [MockWorkspaceResource, MockWorkspaceResource2],
versions: [MockTemplateVersion],
daus: MockTemplateDAUResponse,
},
}
Expand All @@ -61,7 +59,6 @@ SmallViewport.args = {
},
data: {
resources: [MockWorkspaceResource, MockWorkspaceResource2],
versions: [MockTemplateVersion],
daus: MockTemplateDAUResponse,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ import i18next from "i18next"

const { t } = i18next

const validFormValues = {
type FormValues = Required<
Omit<UpdateTemplateMeta, "default_ttl_ms" | "max_ttl_ms">
>

const validFormValues: FormValues = {
name: "Name",
display_name: "A display name",
description: "A description",
icon: "vscode.png",
allow_user_cancel_workspace_jobs: false,
allow_user_autostart: false,
allow_user_autostop: false,
failure_ttl_ms: 0,
inactivity_ttl_ms: 0,
}

const renderTemplateSettingsPage = async () => {
Expand All @@ -36,7 +44,7 @@ const fillAndSubmitForm = async ({
description,
icon,
allow_user_cancel_workspace_jobs,
}: Required<Omit<UpdateTemplateMeta, "default_ttl_ms" | "max_ttl_ms">>) => {
}: FormValues) => {
const label = t("nameLabel", { ns: "templateSettingsPage" })
const nameField = await screen.findByLabelText(label)
await userEvent.clear(nameField)
Expand Down
17 changes: 9 additions & 8 deletions site/src/pages/TemplateSettingsPage/TemplateSettingsLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import { checkAuthorization, getTemplateByName } from "api/api"
import { useQuery } from "@tanstack/react-query"
import { useOrganizationId } from "hooks/useOrganizationId"

const templatePermissions = (templateId: string) => ({
canUpdateTemplate: {
object: {
resource_type: "template",
resource_id: templateId,
const templatePermissions = (templateId: string) =>
({
canUpdateTemplate: {
object: {
resource_type: "template",
resource_id: templateId,
},
action: "update",
},
action: "update",
},
})
} as const)

const fetchTemplateSettings = async (orgId: string, name: string) => {
const template = await getTemplateByName(orgId, name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const defaultArgs: TemplateVersionPageViewProps = {
tab,
templateName: MockTemplate.name,
versionName: MockTemplateVersion.name,
canEdit: true,
context: {
templateName: MockTemplate.name,
orgId: MockOrganization.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const createWorkspaceMachine =
},
action: "create",
},
}
} as const

return checkAuthorization({
checks: permissionsToCheck,
Expand Down
19 changes: 10 additions & 9 deletions site/src/xServices/workspaceSchedule/workspaceScheduleXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ export const checks = {
updateWorkspace: "updateWorkspace",
} as const

const permissionsToCheck = (workspace: TypesGen.Workspace) => ({
[checks.updateWorkspace]: {
object: {
resource_type: "workspace",
resource_id: workspace.id,
owner_id: workspace.owner_id,
const permissionsToCheck = (workspace: TypesGen.Workspace) =>
({
[checks.updateWorkspace]: {
object: {
resource_type: "workspace",
resource_id: workspace.id,
owner_id: workspace.owner_id,
},
action: "update",
},
action: "update",
},
})
} as const)

export type WorkspaceScheduleEvent =
| {
Expand Down
8 changes: 7 additions & 1 deletion site/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ import react from "@vitejs/plugin-react"
import path from "path"
import { defineConfig, PluginOption } from "vite"
import { visualizer } from "rollup-plugin-visualizer"
import checker from "vite-plugin-checker"

const plugins: PluginOption[] = [react()]
const plugins: PluginOption[] = [
react(),
checker({
typescript: true,
}),
]

if (process.env.STATS !== undefined) {
plugins.push(
Expand Down
92 changes: 88 additions & 4 deletions site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4011,7 +4011,7 @@ ansi-align@^3.0.0:
dependencies:
string-width "^4.1.0"

ansi-escapes@^4.2.1:
ansi-escapes@^4.2.1, ansi-escapes@^4.3.0:
version "4.3.2"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e"
integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==
Expand Down Expand Up @@ -4644,7 +4644,7 @@ chartjs-adapter-date-fns@3.0.0:
resolved "https://registry.yarnpkg.com/chartjs-adapter-date-fns/-/chartjs-adapter-date-fns-3.0.0.tgz#c25f63c7f317c1f96f9a7c44bd45eeedb8a478e5"
integrity sha512-Rs3iEB3Q5pJ973J93OBTpnP7qoGwvq3nUnoMdtxO+9aoJof7UFcRbWcIDteXuYd1fgAvct/32T9qaLyLuZVwCg==

chokidar@^3.4.2, chokidar@^3.5.3:
chokidar@^3.4.2, chokidar@^3.5.1, chokidar@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd"
integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
Expand Down Expand Up @@ -8347,6 +8347,11 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

lodash.pick@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3"
integrity sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==

lodash.reduce@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b"
Expand Down Expand Up @@ -10009,7 +10014,7 @@ react-colorful@^5.1.2:
resolved "https://registry.yarnpkg.com/react-colorful/-/react-colorful-5.6.1.tgz#7dc2aed2d7c72fac89694e834d179e32f3da563b"
integrity sha512-1exovf0uGTGyq5mXQT0zgQ80uvj2PCwvF8zY1RN9/vbJVSjSo3fsB/4L3ObbF7u70NduSiK4xu4Y6q1MHoUGEw==

react-confetti@^6.1.0:
react-confetti@6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/react-confetti/-/react-confetti-6.1.0.tgz#03dc4340d955acd10b174dbf301f374a06e29ce6"
integrity sha512-7Ypx4vz0+g8ECVxr88W9zhcQpbeujJAVqL14ZnXJ3I23mOI9/oBVTQ3dkJhUmB0D6XOtCZEM6N0Gm9PMngkORw==
Expand Down Expand Up @@ -10187,7 +10192,7 @@ react-universal-interface@^0.6.2:
resolved "https://registry.yarnpkg.com/react-universal-interface/-/react-universal-interface-0.6.2.tgz#5e8d438a01729a4dbbcbeeceb0b86be146fe2b3b"
integrity sha512-dg8yXdcQmvgR13RIlZbTRQOoUrDciFVoSBZILwjE2LFISxZZ8loVJKAkuzswl5js8BHda79bIb2b84ehU8IjXw==

react-use@^17.4.0:
react-use@17.4.0:
version "17.4.0"
resolved "https://registry.yarnpkg.com/react-use/-/react-use-17.4.0.tgz#cefef258b0a6c534a5c8021c2528ac6e1a4cdc6d"
integrity sha512-TgbNTCA33Wl7xzIJegn1HndB4qTS9u03QUwyNycUnXaweZkE4Kq2SB+Yoxx8qbshkZGYBDvUXbXWRUmQDcZZ/Q==
Expand Down Expand Up @@ -10709,6 +10714,13 @@ semver@^7.0.0, semver@^7.1.2, semver@^7.3.5, semver@^7.3.7:
dependencies:
lru-cache "^6.0.0"

semver@^7.3.4, semver@^7.5.0:
version "7.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.0.tgz#ed8c5dc8efb6c629c88b23d41dc9bf40c1d96cd0"
integrity sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==
dependencies:
lru-cache "^6.0.0"

semver@~7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
Expand Down Expand Up @@ -11368,6 +11380,11 @@ tiny-glob@^0.2.9:
globalyzer "0.1.0"
globrex "^0.1.2"

tiny-invariant@^1.1.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.3.1.tgz#8560808c916ef02ecfd55e66090df23a4b7aa642"
integrity sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==

tiny-warning@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
Expand Down Expand Up @@ -11894,6 +11911,29 @@ vfile@^5.0.0:
unist-util-stringify-position "^3.0.0"
vfile-message "^3.0.0"

vite-plugin-checker@0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/vite-plugin-checker/-/vite-plugin-checker-0.6.0.tgz#f8d09c5f6af427787c657249f7ac775d63cff7e8"
integrity sha512-DWZ9Hv2TkpjviPxAelNUt4Q3IhSGrx7xrwdM64NI+Q4dt8PaMWJJh4qGNtSrfEuiuIzWWo00Ksvh5It4Y3L9xQ==
dependencies:
"@babel/code-frame" "^7.12.13"
ansi-escapes "^4.3.0"
chalk "^4.1.1"
chokidar "^3.5.1"
commander "^8.0.0"
fast-glob "^3.2.7"
fs-extra "^11.1.0"
lodash.debounce "^4.0.8"
lodash.pick "^4.4.0"
npm-run-path "^4.0.1"
semver "^7.5.0"
strip-ansi "^6.0.0"
tiny-invariant "^1.1.0"
vscode-languageclient "^7.0.0"
vscode-languageserver "^7.0.0"
vscode-languageserver-textdocument "^1.0.1"
vscode-uri "^3.0.2"

vite@4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/vite/-/vite-4.3.0.tgz#1fb9432e1980cf254e1ae1b7b8981fd262c6aa49"
Expand All @@ -11910,6 +11950,50 @@ void-elements@3.1.0:
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09"
integrity sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==

vscode-jsonrpc@6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-6.0.0.tgz#108bdb09b4400705176b957ceca9e0880e9b6d4e"
integrity sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg==

vscode-languageclient@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-7.0.0.tgz#b505c22c21ffcf96e167799757fca07a6bad0fb2"
integrity sha512-P9AXdAPlsCgslpP9pRxYPqkNYV7Xq8300/aZDpO35j1fJm/ncize8iGswzYlcvFw5DQUx4eVk+KvfXdL0rehNg==
dependencies:
minimatch "^3.0.4"
semver "^7.3.4"
vscode-languageserver-protocol "3.16.0"

vscode-languageserver-protocol@3.16.0:
version "3.16.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.16.0.tgz#34135b61a9091db972188a07d337406a3cdbe821"
integrity sha512-sdeUoAawceQdgIfTI+sdcwkiK2KU+2cbEYA0agzM2uqaUy2UpnnGHtWTHVEtS0ES4zHU0eMFRGN+oQgDxlD66A==
dependencies:
vscode-jsonrpc "6.0.0"
vscode-languageserver-types "3.16.0"

vscode-languageserver-textdocument@^1.0.1:
version "1.0.8"
resolved "https://registry.yarnpkg.com/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.8.tgz#9eae94509cbd945ea44bca8dcfe4bb0c15bb3ac0"
integrity sha512-1bonkGqQs5/fxGT5UchTgjGVnfysL0O8v1AYMBjqTbWQTFn721zaPGDYFkOKtfDgFiSgXM3KwaG3FMGfW4Ed9Q==

vscode-languageserver-types@3.16.0:
version "3.16.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz#ecf393fc121ec6974b2da3efb3155644c514e247"
integrity sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA==

vscode-languageserver@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-7.0.0.tgz#49b068c87cfcca93a356969d20f5d9bdd501c6b0"
integrity sha512-60HTx5ID+fLRcgdHfmz0LDZAXYEV68fzwG0JWwEPBode9NuMYTIxuYXPg4ngO8i8+Ou0lM7y6GzaYWbiDL0drw==
dependencies:
vscode-languageserver-protocol "3.16.0"

vscode-uri@^3.0.2:
version "3.0.7"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.7.tgz#6d19fef387ee6b46c479e5fb00870e15e58c1eb8"
integrity sha512-eOpPHogvorZRobNqJGhapa0JdwaxpjVvyBp0QIUMRMSf8ZAlqOdEquKuRmw9Qwu0qXtJIWqFtMkmvJjUZmMjVA==

w3c-xmlserializer@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz#aebdc84920d806222936e3cdce408e32488a3073"
Expand Down