1
0
Fork 0

Add more @type packages.

This commit is contained in:
Kitteh 2021-05-10 12:07:19 +01:00
parent a347939896
commit 799931f31a
6 changed files with 17 additions and 15 deletions

View file

@ -1,6 +1,8 @@
{ {
"devDependencies": { "devDependencies": {
"@babel/eslint-parser": "^7.13.14", "@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/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1", "@typescript-eslint/parser": "^4.22.1",
"clipboard": "^2.0.8", "clipboard": "^2.0.8",
@ -15,7 +17,7 @@
"html-webpack-plugin": "^5.3.1", "html-webpack-plugin": "^5.3.1",
"i18next": "^20.2.2", "i18next": "^20.2.2",
"mini-css-extract-plugin": "^1.6.0", "mini-css-extract-plugin": "^1.6.0",
"node-sass": "^6.0.0", "node-sass": "^5.0.0",
"prismjs": "^1.23.0", "prismjs": "^1.23.0",
"qr-scanner": "^1.2.0", "qr-scanner": "^1.2.0",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
npx eslint -c .eslintrc.json "$@" --fix --ext .js,.ts npx eslint -c .eslintrc.json "$@" --ext .js,.ts

View file

@ -2,7 +2,7 @@ import { addClipboardNotifications } from "../pageUtils";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import ClipboardJS from "clipboard"; import ClipboardJS from "clipboard";
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import UIkit from 'uikit/dist/js/uikit.min.js'; import UIkit from 'uikit';
import i18next from 'i18next'; import i18next from 'i18next';
type FileSaverType = { type FileSaverType = {
@ -93,7 +93,7 @@ export function CopyableModal(name: string, contentString: string): ModalType {
}) })
}) as ModalType; }) as ModalType;
modal.show = () => { modal.show = () => {
(UIkit as { modal: (ModalType) => { show: () => void } }).modal(modal).show(); UIkit.modal(modal).show();
} }
return modal; return modal;
} }

View file

@ -4,14 +4,13 @@
/* eslint-disable */ /* eslint-disable */
import "./scss/main.scss"; import "./scss/main.scss";
import Icons from 'uikit/dist/js/uikit-icons.min.js'; import UIkit from 'uikit';
import UIkit from 'uikit/dist/js/uikit.min.js'; import Icons from 'uikit/dist/js/uikit-icons';
// @ts-ignore // @ts-ignore
UIkit.use(Icons); UIkit.use(Icons);
import Prism from "prismjs"; import Prism from "prismjs";
import "prismjs/components/prism-json"; import "prismjs/components/prism-json";
// @ts-ignore
Prism.highlightAll(); Prism.highlightAll();
/* eslint-enable */ /* eslint-enable */

View file

@ -5,7 +5,7 @@ import { lookupSelf } from "./api/sys/lookupSelf";
import { makeElement } from "./htmlUtils"; import { makeElement } from "./htmlUtils";
import { pageState } from "./globalPageState"; import { pageState } from "./globalPageState";
import ClipboardJS from "clipboard"; import ClipboardJS from "clipboard";
import UIkit from 'uikit/dist/js/uikit.min.js'; import UIkit from 'uikit';
import i18next from 'i18next'; import i18next from 'i18next';
async function prePageChecksReal() { async function prePageChecksReal() {
@ -42,17 +42,15 @@ export async function prePageChecks(): Promise<boolean> {
return true; return true;
} }
export function addClipboardNotifications(clipboard: ClipboardJS, timeout = 1000): void { export function addClipboardNotifications(clipboard: ClipboardJS, timeout = 1000): void {
clipboard.on('success', () => { 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', status: 'success',
timeout: timeout timeout: timeout
}); });
}); });
clipboard.on('error', function (e: Error) { 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 "error": e.message
}), { }), {
status: 'danger', status: 'danger',
@ -64,9 +62,12 @@ export function addClipboardNotifications(clipboard: ClipboardJS, timeout = 1000
export function setErrorText(text: string): void { export function setErrorText(text: string): void {
const errorTextElement = document.querySelector("#errorText"); const errorTextElement = document.querySelector("#errorText");
if (errorTextElement) { 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}`, message: `Error: ${text}`,
status: 'danger', status: 'danger',
pos: 'top-center', pos: 'top-center',

View file

@ -141,7 +141,7 @@ export class KeyValueSecretPage extends Page {
kvList.appendChild(makeElement({ kvList.appendChild(makeElement({
tag: "pre", tag: "pre",
class: ["code-block", "language-json", "line-numbers"], 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 { } else {
secretsMap.forEach((value: string, key: string) => { secretsMap.forEach((value: string, key: string) => {