From 5791a73e75b630db3cade3e606c45eb8d8a641cb Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 7 Jul 2024 17:32:30 +0200 Subject: [PATCH] Convert frontend code to typescript (#31559) None of the frontend js/ts files was touched besides these two commands (edit: no longer true, I touched one file in https://github.com/go-gitea/gitea/pull/31559/commits/61105d0618e285d97e95044bfb64415f364a4526 because of a deprecation that was not showing before the rename). `tsc` currently reports 778 errors, so I have disabled it in CI as planned. Everything appears to work fine. --- .eslintrc.yaml | 10 +- Makefile | 6 +- package-lock.json | 157 ++++++++++++++++++ package.json | 10 ++ tsconfig.json | 5 + types.d.ts | 4 + vitest.config.ts | 4 +- .../{bootstrap.test.js => bootstrap.test.ts} | 2 +- web_src/js/{bootstrap.js => bootstrap.ts} | 0 web_src/js/components/ActionRunStatus.vue | 4 +- web_src/js/components/ActivityHeatmap.vue | 2 +- web_src/js/components/ContextPopup.vue | 6 +- web_src/js/components/DashboardRepoList.vue | 6 +- web_src/js/components/DiffCommitSelector.vue | 6 +- web_src/js/components/DiffFileList.vue | 6 +- web_src/js/components/DiffFileTree.vue | 10 +- web_src/js/components/DiffFileTreeItem.vue | 6 +- .../js/components/PullRequestMergeForm.vue | 6 +- web_src/js/components/RepoActionView.vue | 12 +- .../js/components/RepoActivityTopAuthors.vue | 2 +- .../js/components/RepoBranchTagSelector.vue | 10 +- web_src/js/components/RepoCodeFrequency.vue | 12 +- web_src/js/components/RepoContributors.vue | 12 +- web_src/js/components/RepoRecentCommits.vue | 12 +- .../components/ScopedAccessTokenSelector.vue | 4 +- .../features/admin/{common.js => common.ts} | 6 +- .../features/admin/{config.js => config.ts} | 4 +- .../features/admin/{emails.js => emails.ts} | 0 .../admin/{selfcheck.js => selfcheck.ts} | 4 +- .../js/features/admin/{users.js => users.ts} | 0 .../{autofocus-end.js => autofocus-end.ts} | 0 .../js/features/{captcha.js => captcha.ts} | 2 +- .../js/features/{citation.js => citation.ts} | 2 +- .../features/{clipboard.js => clipboard.ts} | 4 +- .../{code-frequency.js => code-frequency.ts} | 0 .../features/{codeeditor.js => codeeditor.ts} | 4 +- .../{colorpicker.js => colorpicker.ts} | 2 +- .../{common-button.js => common-button.ts} | 6 +- ...fetch-action.js => common-fetch-action.ts} | 8 +- .../{common-form.js => common-form.ts} | 4 +- ...list.test.js => common-issue-list.test.ts} | 2 +- ...mon-issue-list.js => common-issue-list.ts} | 4 +- ...organization.js => common-organization.ts} | 4 +- .../{common-page.js => common-page.ts} | 4 +- ...rkdownEditor.js => ComboMarkdownEditor.ts} | 22 +-- .../comp/{ConfirmModal.js => ConfirmModal.ts} | 4 +- ...barActions.js => EasyMDEToolbarActions.ts} | 2 +- .../{EditorMarkdown.js => EditorMarkdown.ts} | 0 ...torUpload.test.js => EditorUpload.test.ts} | 2 +- .../comp/{EditorUpload.js => EditorUpload.ts} | 10 +- .../comp/{LabelEdit.js => LabelEdit.ts} | 0 .../comp/{QuickSubmit.js => QuickSubmit.ts} | 0 ...eactionSelector.js => ReactionSelector.ts} | 2 +- .../{SearchUserBox.js => SearchUserBox.ts} | 0 .../comp/{TextExpander.js => TextExpander.ts} | 4 +- .../{WebHookEditor.js => WebHookEditor.ts} | 4 +- .../{contextpopup.js => contextpopup.ts} | 4 +- .../{contributors.js => contributors.ts} | 0 .../{copycontent.js => copycontent.ts} | 6 +- .../js/features/{dropzone.js => dropzone.ts} | 12 +- web_src/js/features/{emoji.js => emoji.ts} | 0 ...dworker.js => eventsource.sharedworker.ts} | 0 .../features/{file-fold.js => file-fold.ts} | 2 +- .../js/features/{heatmap.js => heatmap.ts} | 2 +- .../features/{imagediff.js => imagediff.ts} | 6 +- .../js/features/{install.js => install.ts} | 4 +- .../{notification.js => notification.ts} | 6 +- .../js/features/{org-team.js => org-team.ts} | 2 +- .../{pull-view-file.js => pull-view-file.ts} | 6 +- .../{recent-commits.js => recent-commits.ts} | 0 .../{repo-branch.js => repo-branch.ts} | 2 +- .../{repo-code.test.js => repo-code.test.ts} | 2 +- .../features/{repo-code.js => repo-code.ts} | 8 +- .../{repo-commit.js => repo-commit.ts} | 4 +- .../{repo-common.js => repo-common.ts} | 8 +- ...epo-diff-commit.js => repo-diff-commit.ts} | 4 +- ...mitselect.js => repo-diff-commitselect.ts} | 0 ...diff-filetree.js => repo-diff-filetree.ts} | 0 .../features/{repo-diff.js => repo-diff.ts} | 20 +-- .../{repo-editor.js => repo-editor.ts} | 12 +- ...findfile.test.js => repo-findfile.test.ts} | 2 +- .../{repo-findfile.js => repo-findfile.ts} | 8 +- .../features/{repo-graph.js => repo-graph.ts} | 4 +- .../features/{repo-home.js => repo-home.ts} | 8 +- ...issue-content.js => repo-issue-content.ts} | 8 +- ...{repo-issue-edit.js => repo-issue-edit.ts} | 14 +- ...{repo-issue-list.js => repo-issue-list.ts} | 14 +- ...issue-pr-form.js => repo-issue-pr-form.ts} | 0 ...e-pr-status.js => repo-issue-pr-status.ts} | 0 .../features/{repo-issue.js => repo-issue.ts} | 18 +- .../{repo-legacy.js => repo-legacy.ts} | 28 ++-- .../{repo-migrate.js => repo-migrate.ts} | 4 +- .../{repo-migration.js => repo-migration.ts} | 2 +- .../{repo-projects.js => repo-projects.ts} | 6 +- .../{repo-release.js => repo-release.ts} | 4 +- .../{repo-search.js => repo-search.ts} | 0 .../{repo-settings.js => repo-settings.ts} | 6 +- .../{repo-template.js => repo-template.ts} | 2 +- ...icode-escape.js => repo-unicode-escape.ts} | 2 +- .../features/{repo-wiki.js => repo-wiki.ts} | 8 +- .../{sshkey-helper.js => sshkey-helper.ts} | 0 .../features/{stopwatch.js => stopwatch.ts} | 8 +- .../features/{tablesort.js => tablesort.ts} | 0 .../js/features/{tribute.js => tribute.ts} | 2 +- ...auth-webauthn.js => user-auth-webauthn.ts} | 6 +- .../features/{user-auth.js => user-auth.ts} | 2 +- .../{user-settings.js => user-settings.ts} | 2 +- web_src/js/{globals.js => globals.ts} | 0 web_src/js/{htmx.js => htmx.ts} | 2 +- web_src/js/{index.js => index.ts} | 128 +++++++------- web_src/js/markup/{anchors.js => anchors.ts} | 2 +- .../js/markup/{asciicast.js => asciicast.ts} | 0 .../js/markup/{codecopy.js => codecopy.ts} | 2 +- web_src/js/markup/{common.js => common.ts} | 0 web_src/js/markup/{content.js => content.ts} | 10 +- web_src/js/markup/{math.js => math.ts} | 2 +- web_src/js/markup/{mermaid.js => mermaid.ts} | 6 +- .../js/markup/{tasklist.js => tasklist.ts} | 4 +- web_src/js/modules/{dirauto.js => dirauto.ts} | 2 +- .../modules/{fetch.test.js => fetch.test.ts} | 2 +- web_src/js/modules/{fetch.js => fetch.ts} | 2 +- .../js/modules/{fomantic.js => fomantic.ts} | 16 +- .../js/modules/fomantic/{api.js => api.ts} | 0 .../js/modules/fomantic/{base.js => base.ts} | 0 .../fomantic/{checkbox.js => checkbox.ts} | 2 +- .../modules/fomantic/{dimmer.js => dimmer.ts} | 2 +- .../fomantic/{dropdown.js => dropdown.ts} | 2 +- .../js/modules/fomantic/{form.js => form.ts} | 2 +- .../modules/fomantic/{modal.js => modal.ts} | 0 .../fomantic/{transition.js => transition.ts} | 0 .../js/modules/{sortable.js => sortable.ts} | 0 web_src/js/modules/{stores.js => stores.ts} | 0 web_src/js/modules/{tippy.js => tippy.ts} | 4 +- .../modules/{toast.test.js => toast.test.ts} | 2 +- web_src/js/modules/{toast.js => toast.ts} | 4 +- web_src/js/modules/{worker.js => worker.ts} | 2 +- .../js/render/{ansi.test.js => ansi.test.ts} | 2 +- web_src/js/render/{ansi.js => ansi.ts} | 0 web_src/js/render/{pdf.js => pdf.ts} | 0 .../js/standalone/{devtest.js => devtest.ts} | 2 +- .../js/standalone/{swagger.js => swagger.ts} | 0 web_src/js/{svg.test.js => svg.test.ts} | 2 +- web_src/js/{svg.js => svg.ts} | 2 +- web_src/js/{utils.test.js => utils.test.ts} | 2 +- web_src/js/{utils.js => utils.ts} | 0 .../js/utils/{color.test.js => color.test.ts} | 2 +- web_src/js/utils/{color.js => color.ts} | 0 web_src/js/utils/{dom.test.js => dom.test.ts} | 2 +- web_src/js/utils/{dom.js => dom.ts} | 0 .../js/utils/{image.test.js => image.test.ts} | 2 +- web_src/js/utils/{image.js => image.ts} | 0 .../js/utils/{match.test.js => match.test.ts} | 2 +- web_src/js/utils/{match.js => match.ts} | 0 .../js/utils/{time.test.js => time.test.ts} | 2 +- web_src/js/utils/{time.js => time.ts} | 2 +- web_src/js/utils/{url.test.js => url.test.ts} | 2 +- web_src/js/utils/{url.js => url.ts} | 0 ...are-you-sure.js => jquery.are-you-sure.ts} | 0 .../js/{vitest.setup.js => vitest.setup.ts} | 0 ...ute-date.test.js => absolute-date.test.ts} | 2 +- .../{absolute-date.js => absolute-date.ts} | 0 web_src/js/webcomponents/index.js | 5 - web_src/js/webcomponents/index.ts | 5 + ...{origin-url.test.js => origin-url.test.ts} | 2 +- .../{origin-url.js => origin-url.ts} | 0 .../{overflow-menu.js => overflow-menu.ts} | 4 +- .../{polyfills.js => polyfills.ts} | 0 webpack.config.js | 16 +- 168 files changed, 562 insertions(+), 386 deletions(-) create mode 100644 types.d.ts rename web_src/js/{bootstrap.test.js => bootstrap.test.ts} (88%) rename web_src/js/{bootstrap.js => bootstrap.ts} (100%) rename web_src/js/features/admin/{common.js => common.ts} (98%) rename web_src/js/features/admin/{config.js => config.ts} (87%) rename web_src/js/features/admin/{emails.js => emails.ts} (100%) rename web_src/js/features/admin/{selfcheck.js => selfcheck.ts} (92%) rename web_src/js/features/admin/{users.js => users.ts} (100%) rename web_src/js/features/{autofocus-end.js => autofocus-end.ts} (100%) rename web_src/js/features/{captcha.js => captcha.ts} (96%) rename web_src/js/features/{citation.js => citation.ts} (98%) rename web_src/js/features/{clipboard.js => clipboard.ts} (91%) rename web_src/js/features/{code-frequency.js => code-frequency.ts} (100%) rename web_src/js/features/{codeeditor.js => codeeditor.ts} (99%) rename web_src/js/features/{colorpicker.js => colorpicker.ts} (97%) rename web_src/js/features/{common-button.js => common-button.ts} (97%) rename web_src/js/features/{common-fetch-action.js => common-fetch-action.ts} (95%) rename web_src/js/features/{common-form.js => common-form.ts} (88%) rename web_src/js/features/{common-issue-list.test.js => common-issue-list.test.ts} (92%) rename web_src/js/features/{common-issue-list.js => common-issue-list.ts} (97%) rename web_src/js/features/{common-organization.js => common-organization.ts} (82%) rename web_src/js/features/{common-page.js => common-page.ts} (97%) rename web_src/js/features/comp/{ComboMarkdownEditor.js => ComboMarkdownEditor.ts} (96%) rename web_src/js/features/comp/{ConfirmModal.js => ConfirmModal.ts} (90%) rename web_src/js/features/comp/{EasyMDEToolbarActions.js => EasyMDEToolbarActions.ts} (99%) rename web_src/js/features/comp/{EditorMarkdown.js => EditorMarkdown.ts} (100%) rename web_src/js/features/comp/{EditorUpload.test.js => EditorUpload.test.ts} (99%) rename web_src/js/features/comp/{EditorUpload.js => EditorUpload.ts} (96%) rename web_src/js/features/comp/{LabelEdit.js => LabelEdit.ts} (100%) rename web_src/js/features/comp/{QuickSubmit.js => QuickSubmit.ts} (100%) rename web_src/js/features/comp/{ReactionSelector.js => ReactionSelector.ts} (97%) rename web_src/js/features/comp/{SearchUserBox.js => SearchUserBox.ts} (100%) rename web_src/js/features/comp/{TextExpander.js => TextExpander.ts} (95%) rename web_src/js/features/comp/{WebHookEditor.js => WebHookEditor.ts} (92%) rename web_src/js/features/{contextpopup.js => contextpopup.ts} (92%) rename web_src/js/features/{contributors.js => contributors.ts} (100%) rename web_src/js/features/{copycontent.js => copycontent.ts} (93%) rename web_src/js/features/{dropzone.js => dropzone.ts} (96%) rename web_src/js/features/{emoji.js => emoji.ts} (100%) rename web_src/js/features/{eventsource.sharedworker.js => eventsource.sharedworker.ts} (100%) rename web_src/js/features/{file-fold.js => file-fold.ts} (96%) rename web_src/js/features/{heatmap.js => heatmap.ts} (96%) rename web_src/js/features/{imagediff.js => imagediff.ts} (99%) rename web_src/js/features/{install.js => install.ts} (97%) rename web_src/js/features/{notification.js => notification.ts} (97%) rename web_src/js/features/{org-team.js => org-team.ts} (95%) rename web_src/js/features/{pull-view-file.js => pull-view-file.ts} (96%) rename web_src/js/features/{recent-commits.js => recent-commits.ts} (100%) rename web_src/js/features/{repo-branch.js => repo-branch.ts} (97%) rename web_src/js/features/{repo-code.test.js => repo-code.test.ts} (91%) rename web_src/js/features/{repo-code.js => repo-code.ts} (97%) rename web_src/js/features/{repo-commit.js => repo-commit.ts} (90%) rename web_src/js/features/{repo-common.js => repo-common.ts} (92%) rename web_src/js/features/{repo-diff-commit.js => repo-diff-commit.ts} (94%) rename web_src/js/features/{repo-diff-commitselect.js => repo-diff-commitselect.ts} (100%) rename web_src/js/features/{repo-diff-filetree.js => repo-diff-filetree.ts} (100%) rename web_src/js/features/{repo-diff.js => repo-diff.ts} (95%) rename web_src/js/features/{repo-editor.js => repo-editor.ts} (94%) rename web_src/js/features/{repo-findfile.test.js => repo-findfile.test.ts} (98%) rename web_src/js/features/{repo-findfile.js => repo-findfile.ts} (96%) rename web_src/js/features/{repo-graph.js => repo-graph.ts} (98%) rename web_src/js/features/{repo-home.js => repo-home.ts} (97%) rename web_src/js/features/{repo-issue-content.js => repo-issue-content.ts} (96%) rename web_src/js/features/{repo-issue-edit.js => repo-issue-edit.ts} (94%) rename web_src/js/features/{repo-issue-list.js => repo-issue-list.ts} (95%) rename web_src/js/features/{repo-issue-pr-form.js => repo-issue-pr-form.ts} (100%) rename web_src/js/features/{repo-issue-pr-status.js => repo-issue-pr-status.ts} (100%) rename web_src/js/features/{repo-issue.js => repo-issue.ts} (98%) rename web_src/js/features/{repo-legacy.js => repo-legacy.ts} (96%) rename web_src/js/features/{repo-migrate.js => repo-migrate.ts} (94%) rename web_src/js/features/{repo-migration.js => repo-migration.ts} (97%) rename web_src/js/features/{repo-projects.js => repo-projects.ts} (97%) rename web_src/js/features/{repo-release.js => repo-release.ts} (97%) rename web_src/js/features/{repo-search.js => repo-search.ts} (100%) rename web_src/js/features/{repo-settings.js => repo-settings.ts} (97%) rename web_src/js/features/{repo-template.js => repo-template.ts} (96%) rename web_src/js/features/{repo-unicode-escape.js => repo-unicode-escape.ts} (98%) rename web_src/js/features/{repo-wiki.js => repo-wiki.ts} (94%) rename web_src/js/features/{sshkey-helper.js => sshkey-helper.ts} (100%) rename web_src/js/features/{stopwatch.js => stopwatch.ts} (96%) rename web_src/js/features/{tablesort.js => tablesort.ts} (100%) rename web_src/js/features/{tribute.js => tribute.ts} (96%) rename web_src/js/features/{user-auth-webauthn.js => user-auth-webauthn.ts} (98%) rename web_src/js/features/{user-auth.js => user-auth.ts} (93%) rename web_src/js/features/{user-settings.js => user-settings.ts} (92%) rename web_src/js/{globals.js => globals.ts} (100%) rename web_src/js/{htmx.js => htmx.ts} (93%) rename web_src/js/{index.js => index.ts} (66%) rename web_src/js/markup/{anchors.js => anchors.ts} (98%) rename web_src/js/markup/{asciicast.js => asciicast.ts} (100%) rename web_src/js/markup/{codecopy.js => codecopy.ts} (95%) rename web_src/js/markup/{common.js => common.ts} (100%) rename web_src/js/markup/{content.js => content.ts} (53%) rename web_src/js/markup/{math.js => math.ts} (97%) rename web_src/js/markup/{mermaid.js => mermaid.ts} (94%) rename web_src/js/markup/{tasklist.js => tasklist.ts} (97%) rename web_src/js/modules/{dirauto.js => dirauto.ts} (95%) rename web_src/js/modules/{fetch.test.js => fetch.test.ts} (80%) rename web_src/js/modules/{fetch.js => fetch.ts} (97%) rename web_src/js/modules/{fomantic.js => fomantic.ts} (71%) rename web_src/js/modules/fomantic/{api.js => api.ts} (100%) rename web_src/js/modules/fomantic/{base.js => base.ts} (100%) rename web_src/js/modules/fomantic/{checkbox.js => checkbox.ts} (91%) rename web_src/js/modules/fomantic/{dimmer.js => dimmer.ts} (95%) rename web_src/js/modules/fomantic/{dropdown.js => dropdown.ts} (99%) rename web_src/js/modules/fomantic/{form.js => form.ts} (91%) rename web_src/js/modules/fomantic/{modal.js => modal.ts} (100%) rename web_src/js/modules/fomantic/{transition.js => transition.ts} (100%) rename web_src/js/modules/{sortable.js => sortable.ts} (100%) rename web_src/js/modules/{stores.js => stores.ts} (100%) rename web_src/js/modules/{tippy.js => tippy.ts} (98%) rename web_src/js/modules/{toast.test.js => toast.test.ts} (97%) rename web_src/js/modules/{toast.js => toast.ts} (96%) rename web_src/js/modules/{worker.js => worker.ts} (86%) rename web_src/js/render/{ansi.test.js => ansi.test.ts} (96%) rename web_src/js/render/{ansi.js => ansi.ts} (100%) rename web_src/js/render/{pdf.js => pdf.ts} (100%) rename web_src/js/standalone/{devtest.js => devtest.ts} (95%) rename web_src/js/standalone/{swagger.js => swagger.ts} (100%) rename web_src/js/{svg.test.js => svg.test.ts} (94%) rename web_src/js/{svg.js => svg.ts} (99%) rename web_src/js/{utils.test.js => utils.test.ts} (99%) rename web_src/js/{utils.js => utils.ts} (100%) rename web_src/js/utils/{color.test.js => color.test.ts} (95%) rename web_src/js/utils/{color.js => color.ts} (100%) rename web_src/js/utils/{dom.test.js => dom.test.ts} (98%) rename web_src/js/utils/{dom.js => dom.ts} (100%) rename web_src/js/utils/{image.test.js => image.test.ts} (96%) rename web_src/js/utils/{image.js => image.ts} (100%) rename web_src/js/utils/{match.test.js => match.test.ts} (94%) rename web_src/js/utils/{match.js => match.ts} (100%) rename web_src/js/utils/{time.test.js => time.test.ts} (87%) rename web_src/js/utils/{time.js => time.ts} (97%) rename web_src/js/utils/{url.test.js => url.test.ts} (88%) rename web_src/js/utils/{url.js => url.ts} (100%) rename web_src/js/vendor/{jquery.are-you-sure.js => jquery.are-you-sure.ts} (100%) rename web_src/js/{vitest.setup.js => vitest.setup.ts} (100%) rename web_src/js/webcomponents/{absolute-date.test.js => absolute-date.test.ts} (85%) rename web_src/js/webcomponents/{absolute-date.js => absolute-date.ts} (100%) delete mode 100644 web_src/js/webcomponents/index.js create mode 100644 web_src/js/webcomponents/index.ts rename web_src/js/webcomponents/{origin-url.test.js => origin-url.test.ts} (94%) rename web_src/js/webcomponents/{origin-url.js => origin-url.ts} (100%) rename web_src/js/webcomponents/{overflow-menu.js => overflow-menu.ts} (98%) rename web_src/js/webcomponents/{polyfills.js => polyfills.ts} (100%) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 293d435b11..59eff85dc3 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -58,10 +58,10 @@ overrides: worker: true rules: no-restricted-globals: [2, addEventListener, blur, close, closed, confirm, defaultStatus, defaultstatus, error, event, external, find, focus, frameElement, frames, history, innerHeight, innerWidth, isFinite, isNaN, length, locationbar, menubar, moveBy, moveTo, name, onblur, onerror, onfocus, onload, onresize, onunload, open, opener, opera, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, print, removeEventListener, resizeBy, resizeTo, screen, screenLeft, screenTop, screenX, screenY, scroll, scrollbars, scrollBy, scrollTo, scrollX, scrollY, status, statusbar, stop, toolbar, top] - - files: ["*.config.*"] + - files: ["*.config.*", "**/*.d.ts"] rules: i/no-unused-modules: [0] - - files: ["**/*.test.*", "web_src/js/test/setup.js"] + - files: ["**/*.test.*", "web_src/js/test/setup.ts"] env: vitest-globals/env: true rules: @@ -114,7 +114,7 @@ overrides: vitest/valid-describe-callback: [2] vitest/valid-expect: [2] vitest/valid-title: [2] - - files: ["web_src/js/modules/fetch.js", "web_src/js/standalone/**/*"] + - files: ["web_src/js/modules/fetch.ts", "web_src/js/standalone/**/*"] rules: no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression] - files: ["**/*.vue"] @@ -467,7 +467,7 @@ rules: no-dupe-else-if: [2] no-dupe-keys: [2] no-duplicate-case: [2] - no-duplicate-imports: [2] + no-duplicate-imports: [0] no-else-return: [2] no-empty-character-class: [2] no-empty-function: [0] @@ -619,7 +619,7 @@ rules: no-restricted-exports: [0] no-restricted-globals: [2, addEventListener, blur, close, closed, confirm, defaultStatus, defaultstatus, error, event, external, find, focus, frameElement, frames, history, innerHeight, innerWidth, isFinite, isNaN, length, location, locationbar, menubar, moveBy, moveTo, name, onblur, onerror, onfocus, onload, onresize, onunload, open, opener, opera, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, print, removeEventListener, resizeBy, resizeTo, screen, screenLeft, screenTop, screenX, screenY, scroll, scrollbars, scrollBy, scrollTo, scrollX, scrollY, self, status, statusbar, stop, toolbar, top, __dirname, __filename] no-restricted-imports: [0] - no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression, {selector: "CallExpression[callee.name='fetch']", message: "use modules/fetch.js instead"}] + no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression, {selector: "CallExpression[callee.name='fetch']", message: "use modules/fetch.ts instead"}] no-return-assign: [0] no-script-url: [2] no-self-assign: [2, {props: true}] diff --git a/Makefile b/Makefile index d329a4ac3b..1432467bcc 100644 --- a/Makefile +++ b/Makefile @@ -144,7 +144,7 @@ TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMAN GO_DIRS := build cmd models modules routers services tests WEB_DIRS := web_src/js web_src/css -ESLINT_FILES := web_src/js tools *.js tests/e2e +ESLINT_FILES := web_src/js tools *.js *.ts tests/e2e STYLELINT_FILES := web_src/css web_src/js/components/*.vue SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github $(filter-out CHANGELOG.md, $(wildcard *.go *.js *.md *.yml *.yaml *.toml)) EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini @@ -376,12 +376,12 @@ lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig .PHONY: lint-js lint-js: node_modules npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) - npx tsc +# npx tsc .PHONY: lint-js-fix lint-js-fix: node_modules npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) --fix - npx tsc +# npx tsc .PHONY: lint-css lint-css: node_modules diff --git a/package-lock.json b/package-lock.json index 502489e726..3b84ebaa88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -69,6 +69,16 @@ "@stoplight/spectral-cli": "6.11.1", "@stylistic/eslint-plugin-js": "2.2.1", "@stylistic/stylelint-plugin": "2.1.2", + "@types/dropzone": "5.7.8", + "@types/jquery": "3.5.30", + "@types/katex": "0.16.7", + "@types/license-checker-webpack-plugin": "0.2.4", + "@types/pdfobject": "2.2.5", + "@types/sortablejs": "1.15.8", + "@types/swagger-ui-dist": "3.30.5", + "@types/throttle-debounce": "5.0.2", + "@types/tinycolor2": "1.4.6", + "@types/toastify-js": "1.12.3", "@typescript-eslint/eslint-plugin": "7.14.1", "@typescript-eslint/parser": "7.14.1", "@vitejs/plugin-vue": "5.0.5", @@ -2271,6 +2281,16 @@ "@types/ms": "*" } }, + "node_modules/@types/dropzone": { + "version": "5.7.8", + "resolved": "https://registry.npmjs.org/@types/dropzone/-/dropzone-5.7.8.tgz", + "integrity": "sha512-+L0/KRMuB8cIiCe5AfF448nGMpY+gHiSakqsqT3plEIfgqSV+gcVs1AkngM9zZG8hi6lgMxy4iYEuGXXmqjYvg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/jquery": "*" + } + }, "node_modules/@types/es-aggregate-error": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/es-aggregate-error/-/es-aggregate-error-1.0.6.tgz", @@ -2303,6 +2323,16 @@ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==" }, + "node_modules/@types/jquery": { + "version": "3.5.30", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.30.tgz", + "integrity": "sha512-nbWKkkyb919DOUxjmRVk8vwtDb0/k8FKncmUKFi+NY+QXqWltooxTrswvz4LspQwxvLdvzBN1TImr6cw3aQx2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/sizzle": "*" + } + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -2314,6 +2344,23 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/katex": { + "version": "0.16.7", + "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz", + "integrity": "sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/license-checker-webpack-plugin": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@types/license-checker-webpack-plugin/-/license-checker-webpack-plugin-0.2.4.tgz", + "integrity": "sha512-QTWqHJ5T9lgm3vPwWSZnBwAB+15zl4QBfGoNDcjnthHQEP8VTV87fYfp1HVeCtrDip73xWMtasQeA4QHQ0nFLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/webpack": "^4" + } + }, "node_modules/@types/marked": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.3.2.tgz", @@ -2346,12 +2393,54 @@ "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==", "dev": true }, + "node_modules/@types/pdfobject": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@types/pdfobject/-/pdfobject-2.2.5.tgz", + "integrity": "sha512-7gD5tqc/RUDq0PyoLemL0vEHxBYi+zY0WVaFAx/Y0jBsXFgot1vB9No1GhDZGwRGJMCIZbgAb74QG9MTyTNU/g==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/sarif": { "version": "2.1.7", "resolved": "https://registry.npmjs.org/@types/sarif/-/sarif-2.1.7.tgz", "integrity": "sha512-kRz0VEkJqWLf1LLVN4pT1cg1Z9wAuvI6L97V3m2f5B76Tg8d413ddvLBPTEHAZJlnn4XSvu0FkZtViCQGVyrXQ==", "dev": true }, + "node_modules/@types/sizzle": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.8.tgz", + "integrity": "sha512-0vWLNK2D5MT9dg0iOo8GlKguPAU02QjmZitPEsXRuJXU/OGIOt9vT9Fc26wtYuavLxtO45v9PGleoL9Z0k1LHg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/sortablejs": { + "version": "1.15.8", + "resolved": "https://registry.npmjs.org/@types/sortablejs/-/sortablejs-1.15.8.tgz", + "integrity": "sha512-b79830lW+RZfwaztgs1aVPgbasJ8e7AXtZYHTELNXZPsERt4ymJdjV4OccDbHQAvHrCcFpbF78jkm0R6h/pZVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/source-list-map": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.6.tgz", + "integrity": "sha512-5JcVt1u5HDmlXkwOD2nslZVllBBc7HDuOICfiZah2Z0is8M8g+ddAEawbmd3VjedfDHBzxCaXLs07QEmb7y54g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/swagger-ui-dist": { + "version": "3.30.5", + "resolved": "https://registry.npmjs.org/@types/swagger-ui-dist/-/swagger-ui-dist-3.30.5.tgz", + "integrity": "sha512-SrXhD9L8qeIxJzN+o1kmf3wXeVf/+Km3jIdRM1+Yq3I5b/dlF5TcGr5WCVM7I/cBYpgf43/gCPIucQ13AhICiw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/tapable": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.12.tgz", + "integrity": "sha512-bTHG8fcxEqv1M9+TD14P8ok8hjxoOCkfKc8XXLaaD05kI7ohpeI956jtDOD3XHKBQrlyPughUtzm1jtVhHpA5Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/tern": { "version": "0.23.9", "resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.9.tgz", @@ -2360,6 +2449,37 @@ "@types/estree": "*" } }, + "node_modules/@types/throttle-debounce": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@types/throttle-debounce/-/throttle-debounce-5.0.2.tgz", + "integrity": "sha512-pDzSNulqooSKvSNcksnV72nk8p7gRqN8As71Sp28nov1IgmPKWbOEIwAWvBME5pPTtaXJAvG3O4oc76HlQ4kqQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/tinycolor2": { + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/@types/tinycolor2/-/tinycolor2-1.4.6.tgz", + "integrity": "sha512-iEN8J0BoMnsWBqjVbWH/c0G0Hh7O21lpR2/+PrvAVgWdzL7eexIFm4JN/Wn10PTcmNdtS6U67r499mlWMXOxNw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/toastify-js": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/@types/toastify-js/-/toastify-js-1.12.3.tgz", + "integrity": "sha512-9RjLlbAHMSaae/KZNHGv19VG4gcLIm3YjvacCXBtfMfYn26h76YP5oxXI8k26q4iKXCB9LNfv18lsoS0JnFPTg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/uglify-js": { + "version": "3.17.5", + "resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.17.5.tgz", + "integrity": "sha512-TU+fZFBTBcXj/GpDpDaBmgWk/gn96kMZ+uocaFUlV2f8a6WdMzzI44QBCmGcCiYR0Y6ZlNRiyUyKKt5nl/lbzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "source-map": "^0.6.1" + } + }, "node_modules/@types/unist": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz", @@ -2371,6 +2491,43 @@ "integrity": "sha512-XOfUup9r3Y06nFAZh3WvO0rBU4OtlfPB/vgxpjg+NRdGU6CN6djdc6OEiH+PcqHCY6eFLo9Ista73uarf4gnBg==", "dev": true }, + "node_modules/@types/webpack": { + "version": "4.41.38", + "resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.38.tgz", + "integrity": "sha512-oOW7E931XJU1mVfCnxCVgv8GLFL768pDO5u2Gzk82i8yTIgX6i7cntyZOkZYb/JtYM8252SN9bQp9tgkVDSsRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/tapable": "^1", + "@types/uglify-js": "*", + "@types/webpack-sources": "*", + "anymatch": "^3.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/@types/webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-4nZOdMwSPHZ4pTEZzSp0AsTM4K7Qmu40UKW4tJDiOVs20UzYF9l+qUe4s0ftfN0pin06n+5cWWDJXH+sbhAiDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/source-list-map": "*", + "source-map": "^0.7.3" + } + }, + "node_modules/@types/webpack-sources/node_modules/source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 8" + } + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "7.14.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.14.1.tgz", diff --git a/package.json b/package.json index e44415ee32..4ad52d368e 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,16 @@ "@stoplight/spectral-cli": "6.11.1", "@stylistic/eslint-plugin-js": "2.2.1", "@stylistic/stylelint-plugin": "2.1.2", + "@types/dropzone": "5.7.8", + "@types/jquery": "3.5.30", + "@types/katex": "0.16.7", + "@types/license-checker-webpack-plugin": "0.2.4", + "@types/pdfobject": "2.2.5", + "@types/sortablejs": "1.15.8", + "@types/swagger-ui-dist": "3.30.5", + "@types/throttle-debounce": "5.0.2", + "@types/tinycolor2": "1.4.6", + "@types/toastify-js": "1.12.3", "@typescript-eslint/eslint-plugin": "7.14.1", "@typescript-eslint/parser": "7.14.1", "@vitejs/plugin-vue": "5.0.5", diff --git a/tsconfig.json b/tsconfig.json index 7ddbada765..5640c8e741 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,5 +26,10 @@ "noUnusedParameters": true, "noPropertyAccessFromIndexSignature": false, "exactOptionalPropertyTypes": false, + "sourceMap": true, + "types": [ + "vitest/globals", + "./types.d.ts", + ], } } diff --git a/types.d.ts b/types.d.ts new file mode 100644 index 0000000000..9348424371 --- /dev/null +++ b/types.d.ts @@ -0,0 +1,4 @@ +declare module '*.svg' { + const value: string; + export default value; +} diff --git a/vitest.config.ts b/vitest.config.ts index ea0fafeee8..da61450764 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -4,8 +4,8 @@ import {stringPlugin} from 'vite-string-plugin'; export default defineConfig({ test: { - include: ['web_src/**/*.test.js'], - setupFiles: ['web_src/js/vitest.setup.js'], + include: ['web_src/**/*.test.ts'], + setupFiles: ['web_src/js/vitest.setup.ts'], environment: 'happy-dom', testTimeout: 20000, open: false, diff --git a/web_src/js/bootstrap.test.js b/web_src/js/bootstrap.test.ts similarity index 88% rename from web_src/js/bootstrap.test.js rename to web_src/js/bootstrap.test.ts index a6b901b92c..2938678027 100644 --- a/web_src/js/bootstrap.test.js +++ b/web_src/js/bootstrap.test.ts @@ -1,4 +1,4 @@ -import {showGlobalErrorMessage} from './bootstrap.js'; +import {showGlobalErrorMessage} from './bootstrap.ts'; test('showGlobalErrorMessage', () => { document.body.innerHTML = '
'; diff --git a/web_src/js/bootstrap.js b/web_src/js/bootstrap.ts similarity index 100% rename from web_src/js/bootstrap.js rename to web_src/js/bootstrap.ts diff --git a/web_src/js/components/ActionRunStatus.vue b/web_src/js/components/ActionRunStatus.vue index 7ada543fea..5181c2c475 100644 --- a/web_src/js/components/ActionRunStatus.vue +++ b/web_src/js/components/ActionRunStatus.vue @@ -2,8 +2,8 @@ Please also update the template file above if this vue is modified. action status accepted: success, skipped, waiting, blocked, running, failure, cancelled, unknown --> -