Fix ESLint issues

This commit is contained in:
Sidharth Vinod
2021-06-02 12:27:22 +05:30
parent c0b353dbfd
commit 1d25499b86
6 changed files with 28 additions and 16 deletions
+4 -4
View File
@@ -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})`;
+1 -1
View File
@@ -42,7 +42,7 @@
initEditor(Monaco);
editor = Monaco.editor.create(divEl, editorOptions);
editor.onDidChangeModelContent(async () => {
editor.onDidChangeModelContent(() => {
text = editor.getValue();
dispatch('update', {
text
+1 -1
View File
@@ -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)) {
+6 -2
View File
@@ -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);
+7 -7
View File
@@ -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
View File
@@ -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"
]
}