add some linting config

This commit is contained in:
Kiril Videlov 2023-02-12 21:14:41 +01:00
parent 2843be38a7
commit fbb7a93564
9 changed files with 1175 additions and 162 deletions

21
.eslintrc.json Normal file
View File

@ -0,0 +1,21 @@
{
"env": {
"es2022": true
},
"extends": [
"plugin:unicorn/recommended",
"plugin:prettier/recommended",
"plugin:svelte/recommended",
],
"plugins": [
"unicorn",
"prettier",
],
"overrides": [
{
"files": ["*.svelte"],
"processor": "svelte3/svelte3"
}
],
"root": true
}

8
.prettierrc.json Normal file
View File

@ -0,0 +1,8 @@
{
"tabWidth": 4,
"plugins": [
"prettier-plugin-svelte",
"prettier-plugin-tailwindcss"
],
"pluginSearchDirs": false
}

View File

@ -28,9 +28,17 @@
"@tauri-apps/cli": "^1.2.2",
"@types/diff": "^5.0.2",
"autoprefixer": "^10.4.7",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-svelte": "^2.18.0",
"eslint-plugin-unicorn": "^45.0.2",
"postcss": "^8.4.14",
"postcss-load-config": "^4.0.1",
"svelte": "^3.54.0",
"prettier": "^2.8.4",
"prettier-plugin-svelte": "^2.9.0",
"prettier-plugin-tailwindcss": "^0.2.2",
"svelte": "^3.55.1",
"svelte-check": "^3.0.0",
"svelte-preprocess": "^4.10.7",
"tailwindcss": "^3.1.5",

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,21 @@
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
<style>
body {
position: fixed;
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
</head>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
<style>
body {
position: fixed;
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
</head>
<body>
<div>%sveltekit.body%</div>
</body>
<body>
<div>%sveltekit.body%</div>
</body>
</html>

View File

@ -1,144 +1,147 @@
<script lang="ts">
import "../app.postcss";
import "../app.postcss";
import { open } from "@tauri-apps/api/dialog";
import type { LayoutData } from "./$types";
import { log } from "$lib";
import { onMount } from "svelte";
import { BackForwardButtons } from "$lib/components";
import DropDown from "$lib/components/DropDown.svelte";
import { open } from "@tauri-apps/api/dialog";
import type { LayoutData } from "./$types";
import { log } from "$lib";
import { onMount } from "svelte";
import { BackForwardButtons } from "$lib/components";
import DropDown from "$lib/components/DropDown.svelte";
onMount(log.setup);
onMount(log.setup);
export let data: LayoutData;
const { projects } = data;
export let data: LayoutData;
const { projects } = data;
const onSelectProjectClick = async () => {
const selectedPath = await open({
directory: true,
recursive: true,
});
if (selectedPath === null) return;
if (Array.isArray(selectedPath) && selectedPath.length !== 1) return;
const projectPath = Array.isArray(selectedPath)
? selectedPath[0]
: selectedPath;
const onSelectProjectClick = async () => {
const selectedPath = await open({
directory: true,
recursive: true,
});
if (selectedPath === null) return;
if (Array.isArray(selectedPath) && selectedPath.length !== 1) return;
const projectPath = Array.isArray(selectedPath)
? selectedPath[0]
: selectedPath;
const projectExists = $projects.some((p) => p.path === projectPath);
if (projectExists) return;
const projectExists = $projects.some((p) => p.path === projectPath);
if (projectExists) return;
await projects.add({ path: projectPath });
};
await projects.add({ path: projectPath });
};
</script>
<div class="flex flex-col">
<header
data-tauri-drag-region
class="h-8 sticky top-0 z-50
overflow-hidden
border-b
bg-zinc-50 dark:bg-zinc-900 dark:border-zinc-700
flex flex-row
items-center
justify-between
text-zinc-400 text-sm
<header
data-tauri-drag-region
class="sticky top-0 z-50 flex
h-8
flex-row
items-center justify-between overflow-hidden
border-b bg-zinc-50
text-sm
text-zinc-400
dark:border-zinc-700 dark:bg-zinc-900
"
>
<div class="ml-24">
<BackForwardButtons />
</div>
<div
class="
border rounded-md
hover:border-zinc-200
dark:bg-zinc-800 dark:border-zinc-700
dark:hover:border-zinc-600
text-zinc-400 text-sm
outline-none
w-1/3
>
<div class="ml-24">
<BackForwardButtons />
</div>
<div
class="
invisible w-1/3
max-w-[40rem]
text-center
cursor-default
invisible
cursor-default rounded-md
border
text-center text-sm
text-zinc-400
outline-none
hover:border-zinc-200
dark:border-zinc-700
dark:bg-zinc-800
dark:hover:border-zinc-600
min-[320px]:visible
"
>
<div class="center">Search GitButler</div>
</div>
<div class="mr-4 font-bold cursor-default">User</div>
</header>
<main class="text-zinc-400 flex flex-row flex-grow h-screen">
<div
id="sidebar"
class="
bg-zinc-50 dark:bg-zinc-900
flex flex-col h-screen
w-1/4"
>
<div
class="flex-none relative flex border-b border-zinc-700 h-10 items-center hover:bg-zinc-800"
>
<div
class="
flex-grow"
>
<DropDown projects={$projects} />
<div class="center">Search GitButler</div>
</div>
<button class="flex-shrink" on:click={onSelectProjectClick}>
<div
class="absolute -my-2 -mx-8 rounded-full select-none cursor-default w-5 h-5
text-sm
bg-zinc-600 hover:bg-zinc-300 hover:text-zinc-600 flex items-center justify-center font-bold"
title="Add new repository"
>
+
</div>
</button>
</div>
<div class="flex-grow flex flex-col space-y-4 w-full">
<div class="border-b border-zinc-700 py-4 space-y-2">
<div class="px-4 cursor-default select-none">Timeline</div>
<div class="">
<span class="px-8 cursor-default select-none">Week</span>
</div>
<div class="hover:bg-zinc-800">
<span class="px-8 cursor-default select-none">Day</span>
</div>
<div class="hover:bg-zinc-800">
<span class="px-8 cursor-default select-none">Session</span>
</div>
</div>
<div class="px-4 my-4 cursor-default select-none">Branches</div>
</div>
<div class="mr-4 cursor-default font-bold">User</div>
</header>
<footer
class="h-8
border-t
text-zinc-400 text-sm fixed bottom-0
bg-zinc-50 dark:bg-zinc-900 dark:border-zinc-700
flex
w-full
flex-grow
z-50
<main class="flex h-screen flex-grow flex-row text-zinc-400">
<div
id="sidebar"
class="
flex h-screen
w-1/4 flex-col bg-zinc-50
dark:bg-zinc-900"
>
<div
class="relative flex h-10 flex-none items-center border-b border-zinc-700 hover:bg-zinc-800"
>
<div
class="
flex-grow"
>
<DropDown projects={$projects} />
</div>
<button class="flex-shrink" on:click={onSelectProjectClick}>
<div
class="absolute -my-2 -mx-8 flex h-5 w-5 cursor-default select-none
items-center
justify-center rounded-full bg-zinc-600 text-sm font-bold hover:bg-zinc-300 hover:text-zinc-600"
title="Add new repository"
>
+
</div>
</button>
</div>
<div class="flex w-full flex-grow flex-col space-y-4">
<div class="space-y-2 border-b border-zinc-700 py-4">
<div class="cursor-default select-none px-4">Timeline</div>
<div class="">
<span class="cursor-default select-none px-8">Week</span
>
</div>
<div class="hover:bg-zinc-800">
<span class="cursor-default select-none px-8">Day</span>
</div>
<div class="hover:bg-zinc-800">
<span class="cursor-default select-none px-8"
>Session</span
>
</div>
</div>
<div class="my-4 cursor-default select-none px-4">Branches</div>
</div>
<footer
class="fixed
bottom-0
z-50 flex h-8 w-full
flex-grow border-t bg-zinc-50
text-sm
text-zinc-400
dark:border-zinc-700
dark:bg-zinc-900
"
>
<div class="ml-4 text-sm flex flex-row items-center space-x-2">
<div class="rounded-full h-2 w-2 bg-green-700" />
<div>Up to date</div>
>
<div class="ml-4 flex flex-row items-center space-x-2 text-sm">
<div class="h-2 w-2 rounded-full bg-green-700" />
<div>Up to date</div>
</div>
</footer>
</div>
</footer>
</div>
<div
id="main"
class="
border-l
<div
id="main"
class="
flex-grow
dark:bg-zinc-800 dark:border-zinc-700
border-l
dark:border-zinc-700 dark:bg-zinc-800
"
>
<slot />
</div>
</main>
>
<slot />
</div>
</main>
</div>

View File

@ -13,7 +13,9 @@ export const load: LayoutLoad = async ({ parent, params }) => {
: await (await import("$lib/deltas")).default({ projectId: params.id });
const sessions = building
? readable<Session[]>([])
: await (await import("$lib/sessions")).default({ projectId: params.id });
: await (
await import("$lib/sessions")
).default({ projectId: params.id });
return {
project: derived(projects, (projects) =>
projects.find((project) => project.id === params.id)

View File

@ -8,7 +8,7 @@
export let data: PageData;
const { deltas, files } = data;
const value = writable(new Date().getTime());
const value = writable(new Date().getTime());
const docs = derived(value, (value) =>
Object.fromEntries(
@ -43,18 +43,17 @@
const showTimeline = isFinite(min) && isFinite(max);
</script>
<ul class="flex flex-col gap-2">
{#if showTimeline}
<Timeline min={min} max={max} on:value={(e) => value.set(e.detail)} />
{/if}
{#if showTimeline}
<Timeline {min} {max} on:value={(e) => value.set(e.detail)} />
{/if}
{#each Object.entries($docs) as [filepath, value]}
<li>
<details open>
<summary>{filepath}</summary>
<CodeViewer {value} />
</details>
</li>
{/each}
{#each Object.entries($docs) as [filepath, value]}
<li>
<details open>
<summary>{filepath}</summary>
<CodeViewer {value} />
</details>
</li>
{/each}
</ul>

View File

@ -8,15 +8,15 @@ export const load: PageLoad = async ({ parent, params }) => {
const deltas = building
? []
: (await import("$lib/deltas")).list({
projectId: params.id,
sessionId: params.hash,
});
projectId: params.id,
sessionId: params.hash,
});
const files = building
? ({} as Record<string, string>)
: (await import("$lib/sessions")).listFiles({
projectId: params.id,
sessionId: params.hash,
});
projectId: params.id,
sessionId: params.hash,
});
return {
session: derived(sessions, (sessions) =>
sessions.find((session) => session.hash === params.hash)