diff --git a/package.json b/package.json index 547cdf8..cc67c34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,8 @@ { "devDependencies": { "@babel/eslint-parser": "^7.13.14", + "@types/prismjs": "^1.16.5", + "@types/uikit": "^3.3.1", "@typescript-eslint/eslint-plugin": "^4.22.1", "@typescript-eslint/parser": "^4.22.1", "clipboard": "^2.0.8", @@ -15,7 +17,7 @@ "html-webpack-plugin": "^5.3.1", "i18next": "^20.2.2", "mini-css-extract-plugin": "^1.6.0", - "node-sass": "^6.0.0", + "node-sass": "^5.0.0", "prismjs": "^1.23.0", "qr-scanner": "^1.2.0", "raw-loader": "^4.0.2", diff --git a/runLinter.sh b/runLinter.sh index b9a40f7..8eab877 100755 --- a/runLinter.sh +++ b/runLinter.sh @@ -1,3 +1,3 @@ #!/bin/bash -npx eslint -c .eslintrc.json "$@" --fix --ext .js,.ts \ No newline at end of file +npx eslint -c .eslintrc.json "$@" --ext .js,.ts \ No newline at end of file diff --git a/src/elements/CopyableModal.ts b/src/elements/CopyableModal.ts index fa5ec71..1bf6cdc 100644 --- a/src/elements/CopyableModal.ts +++ b/src/elements/CopyableModal.ts @@ -2,7 +2,7 @@ import { addClipboardNotifications } from "../pageUtils"; import { makeElement } from "../htmlUtils"; import ClipboardJS from "clipboard"; import FileSaver from 'file-saver'; -import UIkit from 'uikit/dist/js/uikit.min.js'; +import UIkit from 'uikit'; import i18next from 'i18next'; type FileSaverType = { @@ -93,7 +93,7 @@ export function CopyableModal(name: string, contentString: string): ModalType { }) }) as ModalType; modal.show = () => { - (UIkit as { modal: (ModalType) => { show: () => void } }).modal(modal).show(); + UIkit.modal(modal).show(); } return modal; } diff --git a/src/main.ts b/src/main.ts index c282e3d..87fa24c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,14 +4,13 @@ /* eslint-disable */ import "./scss/main.scss"; -import Icons from 'uikit/dist/js/uikit-icons.min.js'; -import UIkit from 'uikit/dist/js/uikit.min.js'; +import UIkit from 'uikit'; +import Icons from 'uikit/dist/js/uikit-icons'; // @ts-ignore UIkit.use(Icons); import Prism from "prismjs"; import "prismjs/components/prism-json"; -// @ts-ignore Prism.highlightAll(); /* eslint-enable */ diff --git a/src/pageUtils.ts b/src/pageUtils.ts index 2a20b8d..fbabdc8 100644 --- a/src/pageUtils.ts +++ b/src/pageUtils.ts @@ -5,7 +5,7 @@ import { lookupSelf } from "./api/sys/lookupSelf"; import { makeElement } from "./htmlUtils"; import { pageState } from "./globalPageState"; import ClipboardJS from "clipboard"; -import UIkit from 'uikit/dist/js/uikit.min.js'; +import UIkit from 'uikit'; import i18next from 'i18next'; async function prePageChecksReal() { @@ -42,17 +42,15 @@ export async function prePageChecks(): Promise { return true; } - - export function addClipboardNotifications(clipboard: ClipboardJS, timeout = 1000): void { clipboard.on('success', () => { - (UIkit as {notification: (title: unknown, options: unknown) => void}).notification(i18next.t("notification_copy_success"), { + UIkit.notification(i18next.t("notification_copy_success"), { status: 'success', timeout: timeout }); }); clipboard.on('error', function (e: Error) { - (UIkit as {notification: (title: unknown, options: unknown) => void}).notification(i18next.t("notification_copy_error", { + UIkit.notification(i18next.t("notification_copy_error", { "error": e.message }), { status: 'danger', @@ -64,9 +62,12 @@ export function addClipboardNotifications(clipboard: ClipboardJS, timeout = 1000 export function setErrorText(text: string): void { const errorTextElement = document.querySelector("#errorText"); if (errorTextElement) { - (document.querySelector("#errorText") as HTMLParagraphElement).innerText = `Error: ${text}`; + /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ + const p = document.querySelector("#errorText") as HTMLParagraphElement; + p.innerText = `Error: ${text}`; + /* eslint-enable @typescript-eslint/no-unnecessary-type-assertion */ } - (UIkit as {notification: (options: unknown) => void}).notification({ + UIkit.notification({ message: `Error: ${text}`, status: 'danger', pos: 'top-center', diff --git a/src/pages/KeyValue/KeyValueSecret.ts b/src/pages/KeyValue/KeyValueSecret.ts index 37004b4..d3ae64c 100644 --- a/src/pages/KeyValue/KeyValueSecret.ts +++ b/src/pages/KeyValue/KeyValueSecret.ts @@ -141,7 +141,7 @@ export class KeyValueSecretPage extends Page { kvList.appendChild(makeElement({ tag: "pre", class: ["code-block", "language-json", "line-numbers"], - html: (Prism as { highlight: (text: string, language: null, languageStr: string) => string }).highlight(jsonText, null, 'json') + html: Prism.highlight(jsonText, Prism.languages.json, 'json') })); } else { secretsMap.forEach((value: string, key: string) => {