diff --git a/src/lib/components/actions.svelte b/src/lib/components/actions.svelte index bb758118..d1564b1f 100644 --- a/src/lib/components/actions.svelte +++ b/src/lib/components/actions.svelte @@ -62,8 +62,8 @@ }; }; - const isClipboardAvailable = () => { - return Object.prototype.hasOwnProperty.call(window, 'ClipboardItem'); + const isClipboardAvailable = (): boolean => { + return Object.prototype.hasOwnProperty.call(window, 'ClipboardItem') as boolean; }; const clipboardCopy: Exporter = (context, image) => { @@ -102,7 +102,7 @@ ); }; - const onCopyMarkdown = (event) => { + const onCopyMarkdown = (event: Event) => { event.target.select(); document.execCommand('Copy'); }; @@ -113,7 +113,7 @@ let imagemodeselected = 'auto'; let userimagesize = 1080; - base64State.subscribe((b64Code) => { + base64State.subscribe((b64Code: string) => { iUrl = `https://mermaid.ink/img/${b64Code}`; svgUrl = `https://mermaid.ink/svg/${b64Code}`; mdCode = `[![](${iUrl})](${window.location.protocol}//${window.location.host}${window.location.pathname}/edit#${b64Code})`; diff --git a/src/lib/components/editor/editor.svelte b/src/lib/components/editor/editor.svelte index 15a6ac0a..fba5e70c 100644 --- a/src/lib/components/editor/editor.svelte +++ b/src/lib/components/editor/editor.svelte @@ -42,7 +42,7 @@ initEditor(Monaco); editor = Monaco.editor.create(divEl, editorOptions); - editor.onDidChangeModelContent(async () => { + editor.onDidChangeModelContent(() => { text = editor.getValue(); dispatch('update', { text diff --git a/src/lib/components/view.svelte b/src/lib/components/view.svelte index 20f349e1..326a6fb8 100644 --- a/src/lib/components/view.svelte +++ b/src/lib/components/view.svelte @@ -11,7 +11,7 @@ let error = false; let outOfSync = false; let manualUpdate = true; - onMount(async () => { + onMount(() => { codeStore.subscribe((state) => { try { if (container && state && (state.updateDiagram || state.autoSync)) { diff --git a/src/lib/util/stats.ts b/src/lib/util/stats.ts index 4eafc781..0a8ae69e 100644 --- a/src/lib/util/stats.ts +++ b/src/lib/util/stats.ts @@ -1,15 +1,19 @@ import { browser } from '$app/env'; +import type { AnalyticsInstance } from 'analytics'; -export let analytics; +export let analytics: AnalyticsInstance; export const initAnalytics = async (): Promise => { if (browser && !analytics) { try { const { Analytics } = await import('analytics'); + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const googleAnalytics = await import('@analytics/google-analytics'); analytics = Analytics({ app: 'mermaid-live-editor', + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment plugins: [ + // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access googleAnalytics.init({ trackingId: 'UA-153180559-1' }) @@ -37,7 +41,7 @@ export const saveStatistcs = (graph: string): void => { timeout = setTimeout(function () { const graphType = detectType(graph); console.debug('ga:', 'send', 'event', 'render', graphType); - analytics.track('render', { + void analytics.track('render', { graphType }); }, 5000); diff --git a/src/routes/edit.svelte b/src/routes/edit.svelte index 17be8061..8f065c10 100644 --- a/src/routes/edit.svelte +++ b/src/routes/edit.svelte @@ -56,7 +56,7 @@ } ]; - const handleCodeUpdate = async (code: string): Promise => { + const handleCodeUpdate = (code: string): void => { mermaid.parse(code); updateCode(code, false); }; @@ -66,10 +66,10 @@ updateConfig(config, false); }; - const updateHandler = async (message: CustomEvent) => { + const updateHandler = (message: CustomEvent) => { try { if (selectedMode === 'code') { - await handleCodeUpdate(message.detail.text); + handleCodeUpdate(message.detail.text); } else { handleConfigUpdate(message.detail.text); } @@ -96,18 +96,18 @@ } }; - const viewDiagram = async () => { + const viewDiagram = () => { window.open(`${base}/view#${$base64State}`, '_blank').focus(); }; - onMount(() => { - initHandler(); + onMount(async () => { + await initHandler(); const resizer = document.getElementById('resizeHandler'); const element = document.getElementById('editorPane'); const resize = (e) => { const newWidth = e.pageX - element.getBoundingClientRect().left; if (newWidth > 50) { - element.style.width = newWidth + 'px'; + element.style.width = `${newWidth}px`; } }; diff --git a/tsconfig.json b/tsconfig.json index 89ac8bd0..975f193c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,5 +26,13 @@ "$lib/*": ["src/lib/*"] } }, - "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"] + "include": [ + "src/**/*.d.ts", + "src/**/*.js", + "src/**/*.ts", + "src/**/*.svelte", + "cypress/**/*.ts", + "cypress/**/*.js", + "static/**/*.js" + ] }