Fix ESLint issues
This commit is contained in:
@@ -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 = `[](${window.location.protocol}//${window.location.host}${window.location.pathname}/edit#${b64Code})`;
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
initEditor(Monaco);
|
||||
|
||||
editor = Monaco.editor.create(divEl, editorOptions);
|
||||
editor.onDidChangeModelContent(async () => {
|
||||
editor.onDidChangeModelContent(() => {
|
||||
text = editor.getValue();
|
||||
dispatch('update', {
|
||||
text
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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<void> => {
|
||||
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);
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
}
|
||||
];
|
||||
|
||||
const handleCodeUpdate = async (code: string): Promise<void> => {
|
||||
const handleCodeUpdate = (code: string): void => {
|
||||
mermaid.parse(code);
|
||||
updateCode(code, false);
|
||||
};
|
||||
@@ -66,10 +66,10 @@
|
||||
updateConfig(config, false);
|
||||
};
|
||||
|
||||
const updateHandler = async (message: CustomEvent<EditorUpdateEvent>) => {
|
||||
const updateHandler = (message: CustomEvent<EditorUpdateEvent>) => {
|
||||
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`;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+9
-1
@@ -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"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user