diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..98d2168 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +src/pages/de +src/env.d.ts \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index 66ed61f..a1a2d0a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -48,6 +48,15 @@ "semi": [ "error", "always" - ] + ], + "no-console": "error", + "no-debugger": "error", + "no-alert": "error", + "no-undef": "error", + "no-var": "error", + "no-const-assign": "error", + "comma-dangle": ["error", "always-multiline"], + "no-unneeded-ternary": "error", + "multiline-ternary": ["error", "always-multiline"] } } diff --git a/src/components/PostComponent.astro b/src/components/PostComponent.astro index 4ba0e2a..5deaa5d 100644 --- a/src/components/PostComponent.astro +++ b/src/components/PostComponent.astro @@ -15,17 +15,19 @@ const { post } = Astro.props as Props;
- {post.data.image != null ? ( -
- Post Image -
- ) : null} + {post.data.image != null + ? ( +
+ Post Image +
+ ) + : null}

{post.data.title}

{Intl.DateTimeFormat(astroI18n.locale, { day: "numeric", month: "long", - year: "numeric" + year: "numeric", }).format(post.data.created)}

{post.data.description}

diff --git a/src/components/admin/App.svelte b/src/components/admin/App.svelte index 3ef627f..f27672b 100644 --- a/src/components/admin/App.svelte +++ b/src/components/admin/App.svelte @@ -18,31 +18,46 @@ -->
- +
diff --git a/src/components/admin/components/FightEditPart.svelte b/src/components/admin/components/FightEditPart.svelte index 829b8b8..9c99dcf 100644 --- a/src/components/admin/components/FightEditPart.svelte +++ b/src/components/admin/components/FightEditPart.svelte @@ -37,48 +37,48 @@ return { name: player.name, value: player.id.toString() - } + }; }).sort((a, b) => a.name.localeCompare(b.name)); $: selectableTeams = teams.map(team => { return { name: team.name, value: team.id.toString() - } + }; }).sort((a, b) => a.name.localeCompare(b.name)); $: selectableGamemodes = $gamemodes.map(gamemode => { return { name: gamemode, value: gamemode - } + }; }).sort((a, b) => a.name.localeCompare(b.name)); - $: customGamemode = !selectableGamemodes.some((e) => e.name === gamemode) && gamemode !== ''; + $: customGamemode = !selectableGamemodes.some((e) => e.name === gamemode) && gamemode !== ""; $: selectableCustomGamemode = [ ...selectableGamemodes, { - name: gamemode + ' (custom)', + name: gamemode + " (custom)", value: gamemode } - ] + ]; $: mapsStore = maps(gamemode); $: selectableMaps = $mapsStore.map(map => { return { name: map, value: map - } + }; }).sort((a, b) => a.name.localeCompare(b.name)); - $: customMap = !selectableMaps.some((e) => e.name === map) && map !== '' + $: customMap = !selectableMaps.some((e) => e.name === map) && map !== ""; $: selectableCustomMaps = [ ...selectableMaps, { - name: map + ' (custom)', + name: map + " (custom)", value: map } - ] + ]; $: selectableGroups = [{ - name: 'None', - value: '' + name: "None", + value: "" }, { value: groupSearch, name: `Create: '${groupSearch}'` @@ -86,7 +86,7 @@ return { name: group, value: group - } + }; }).sort((a, b) => a.name.localeCompare(b.name))]; @@ -106,11 +106,13 @@
- +
- +
@@ -118,5 +120,6 @@
- +
diff --git a/src/components/admin/components/TypeAheadSearch.svelte b/src/components/admin/components/TypeAheadSearch.svelte index 27ad50c..a2c8f82 100644 --- a/src/components/admin/components/TypeAheadSearch.svelte +++ b/src/components/admin/components/TypeAheadSearch.svelte @@ -18,32 +18,35 @@ --> - +
open = true} on:keydown={() => open = true}/>
{#each filteredItems as item (item)} - {/each} diff --git a/src/components/admin/pages/Edit.svelte b/src/components/admin/pages/Edit.svelte index 98346e2..c54fbda 100644 --- a/src/components/admin/pages/Edit.svelte +++ b/src/components/admin/pages/Edit.svelte @@ -40,68 +40,69 @@ $: availableBranches = $branches.map((branch) => ({ name: branch, value: branch - })) + })); async function createBranch() { - const name = prompt("Branch name:") + const name = prompt("Branch name:"); if (name) { - selected = null - await $pageRepo.createBranch(name) + selected = null; + await $pageRepo.createBranch(name); let inter = setInterval(() => { - branches.reload() + branches.reload(); if ($branches.includes(name)) { - selectedBranch = name - searchValue = "" - clearInterval(inter) + selectedBranch = name; + searchValue = ""; + clearInterval(inter); } - }, 1000) + }, 1000); } } function changePage(id: number) { if (dirty) { if (confirm("You have unsaved changes. Are you sure you want to change the page?")) { - selected = id - dirty = false + selected = id; + dirty = false; } } else { - selected = id + selected = id; } } async function deleteBranch(con: boolean) { if (selectedBranch !== "master") { - let conf = con || confirm("Are you sure you want to delete this branch?") - if(conf) { - await $pageRepo.deleteBranch(selectedBranch) + let conf = con || confirm("Are you sure you want to delete this branch?"); + if (conf) { + await $pageRepo.deleteBranch(selectedBranch); let inter = setInterval(() => { - branches.reload() + branches.reload(); if (!$branches.includes(selectedBranch)) { - selectedBranch = "master" - searchValue = "" - clearInterval(inter) + selectedBranch = "master"; + searchValue = ""; + clearInterval(inter); } - }, 1000) + }, 1000); } } else { - alert("You can't delete the master branch") + alert("You can't delete the master branch"); } } async function createFile() { - let name = prompt("File name:", "[Name].md") + let name = prompt("File name:", "[Name].md"); if (name) { - await $pageRepo.createFile(`${selectedPath}${name}`, selectedBranch) - reload() + await $pageRepo.createFile(`${selectedPath}${name}`, selectedBranch); + reload(); } } function reload() { - const w = selectedBranch - selectedBranch = "###!" - selectedBranch = w + const w = selectedBranch; + selectedBranch = "###!"; + selectedBranch = w; } +
@@ -115,17 +116,20 @@
{#await pagesFuture} - + {:then pages} {@const pagesMap = mapToMap(pages)}
- - ({value, name: value}))} bind:selected={selectedPath} bind:searchValue={pathSearchValue} maxItems={Number.MAX_VALUE} leftText={true} /> + + ({value, name: value}))} + bind:selected={selectedPath} bind:searchValue={pathSearchValue} + maxItems={Number.MAX_VALUE} leftText={true}/>
{#if selectedBranch !== "master"} - + {:else} @@ -140,8 +144,12 @@ {@const match = nameRegexExec ? nameRegexExec[0] : ""} {@const startIndex = page.path.indexOf(match)} {@const endIndex = startIndex + match.length} -
  • changePage(page.id)}> - {page.path.substring(0, startIndex)}{match}{page.path.substring(endIndex, page.path.length)} +
  • changePage(page.id)}> + {page.path.substring(0, startIndex)}{match}{page.path.substring(endIndex, page.path.length)}
  • {/each} {/if} @@ -152,7 +160,7 @@ {#if selected} - + {/if}
    diff --git a/src/components/admin/pages/Event.svelte b/src/components/admin/pages/Event.svelte index 1e31ec9..ba30f28 100644 --- a/src/components/admin/pages/Event.svelte +++ b/src/components/admin/pages/Event.svelte @@ -48,7 +48,7 @@ Event - + Teams diff --git a/src/components/admin/pages/Home.svelte b/src/components/admin/pages/Home.svelte index 567ebcb..7989ce8 100644 --- a/src/components/admin/pages/Home.svelte +++ b/src/components/admin/pages/Home.svelte @@ -26,18 +26,18 @@ import {eventRepo} from "@repo/event.ts"; import {tokenStore} from "@repo/repo.ts"; - let events = $eventRepo.listEvents() - let showAdd = false - let millis = Date.now() + let events = $eventRepo.listEvents(); + let showAdd = false; + let millis = Date.now(); - Admin-Tool + Mod-Tool - + Edit Pages Permissions @@ -58,13 +58,13 @@

    Upcoming

    {#each data.filter((e) => e.start > millis) as event} - + {/each}

    Past

    {#each data.filter((e) => e.start < millis).reverse() as event} - + {/each}
    {:catch error} diff --git a/src/components/admin/pages/Login.svelte b/src/components/admin/pages/Login.svelte index 7a48852..8932665 100644 --- a/src/components/admin/pages/Login.svelte +++ b/src/components/admin/pages/Login.svelte @@ -31,9 +31,9 @@ async function handleSubmit() { loading = true; - let res = await fetchWithToken(value, "/data") + let res = await fetchWithToken(value, "/data"); loading = false; - if(res.ok) { + if (res.ok) { $tokenStore = value; await replace("/"); } else { @@ -41,7 +41,7 @@ value = ""; setTimeout(() => { error = false; - }, 5000) + }, 5000); } } @@ -51,12 +51,13 @@
    - + @@ -64,7 +65,8 @@
    +
    - {:catch error} + {:catch error}

    {error.toString()}

    {/await} {:catch error} diff --git a/src/components/admin/pages/edit/Editor.svelte b/src/components/admin/pages/edit/Editor.svelte index c421ca7..f6a549f 100644 --- a/src/components/admin/pages/edit/Editor.svelte +++ b/src/components/admin/pages/edit/Editor.svelte @@ -23,7 +23,7 @@ import CodeMirror from "svelte-codemirror-editor"; import {base64ToBytes} from "../../util.ts"; import type {Page} from "@type/page.ts"; - import {materialDark} from '@ddietr/codemirror-themes/material-dark.js' + import {materialDark} from "@ddietr/codemirror-themes/material-dark.js"; import {createEventDispatcher} from "svelte"; import MDEMarkdownEditor from "./MDEMarkdownEditor.svelte"; import {pageRepo} from "@repo/page.ts"; @@ -40,24 +40,30 @@ function getPage(value: Page): Page { page = value; - pageContent = new TextDecoder().decode(base64ToBytes(value.content)); + + if (!dirty || confirm("You have unchanged Changes! Discard them? ")) { + navigator.clipboard.writeText(pageContent); + dirty = false; + pageContent = new TextDecoder().decode(base64ToBytes(value.content)); + } + return value; } function savePage() { - let message = window.prompt("Commit message:", "Update " + page!.name) + let message = window.prompt("Commit message:", "Update " + page!.name); if (message) { - $pageRepo.updatePage(pageId, pageContent, page!.sha, message, branch) + $pageRepo.updatePage(pageId, pageContent, page!.sha, message, branch); dirty = false; } } async function deletePage() { - let message = window.prompt("Commit message:", "Delete " + page!.name) + let message = window.prompt("Commit message:", "Delete " + page!.name); if (message) { - await $pageRepo.deletePage(pageId, message, page!.sha, branch) + await $pageRepo.deletePage(pageId, message, page!.sha, branch); dirty = false; - dispatcher("reload") + dispatcher("reload"); } } @@ -65,9 +71,9 @@ if (dirty) { return "You have unsaved changes. Are you sure you want to leave?"; } -}} /> +}}/> {#await pageFuture} - + {:then p}
    @@ -83,9 +89,9 @@
    {#if page?.name.endsWith("md")} - + {:else} - dirty = true} /> + dirty = true}/> {/if}
    {:catch error} diff --git a/src/components/admin/pages/edit/MDEMarkdownEditor.svelte b/src/components/admin/pages/edit/MDEMarkdownEditor.svelte index 2a8b663..6d4f4d5 100644 --- a/src/components/admin/pages/edit/MDEMarkdownEditor.svelte +++ b/src/components/admin/pages/edit/MDEMarkdownEditor.svelte @@ -20,7 +20,7 @@