Browse Source

refactor: fix typescript and eslint errors

as part of a repository clean up
master
DanConwayDev 2 years ago
parent
commit
5084e2f5f3
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 19
      src/lib/components/AlertWarning.svelte
  2. 1
      src/lib/components/events/EventWrapper.svelte
  3. 2
      src/lib/components/proposals/ProposalsList.svelte
  4. 2
      src/lib/components/proposals/ProposalsListItem.svelte
  5. 8
      src/lib/components/repo/RepoHeader.svelte
  6. 4
      src/lib/components/repo/utils.ts
  7. 8
      src/lib/stores/repos.ts
  8. 8
      src/lib/stores/users.ts
  9. 12
      src/lib/wrappers/ComposeIssue.svelte
  10. 10
      src/lib/wrappers/RepoMenu.svelte
  11. 8
      src/lib/wrappers/RepoPageWrapper.svelte
  12. 13
      src/routes/concept/+page.svelte
  13. 7
      src/routes/e/[nostr_ref]/+page.svelte
  14. 13
      tailwind.config.js
  15. 3
      tsconfig.json

19
src/lib/components/AlertWarning.svelte

@ -1,17 +1,18 @@ @@ -1,17 +1,18 @@
<div role="alert" class="m-auto max-w-xl">
<div role="alert" class="alert alert-warning bg-yellow-300 m-auto mt-6">
<div role="alert" class="alert alert-warning m-auto mt-6 bg-yellow-300">
<!-- https://icon-sets.iconify.design/ph/warning-fill/ -->
<svg xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 shrink-0 stroke-current"
viewBox="0 0 256 256">
<path
fill="currentColor"
d="M236.8 188.09L149.35 36.22a24.76 24.76 0 0 0-42.7 0L19.2 188.09a23.51 23.51 0 0 0 0 23.72A24.35 24.35 0 0 0 40.55 224h174.9a24.35 24.35 0 0 0 21.33-12.19a23.51 23.51 0 0 0 .02-23.72M120 104a8 8 0 0 1 16 0v40a8 8 0 0 1-16 0Zm8 88a12 12 0 1 1 12-12a12 12 0 0 1-12 12"
/></svg
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 shrink-0 stroke-current"
viewBox="0 0 256 256"
>
<path
fill="currentColor"
d="M236.8 188.09L149.35 36.22a24.76 24.76 0 0 0-42.7 0L19.2 188.09a23.51 23.51 0 0 0 0 23.72A24.35 24.35 0 0 0 40.55 224h174.9a24.35 24.35 0 0 0 21.33-12.19a23.51 23.51 0 0 0 .02-23.72M120 104a8 8 0 0 1 16 0v40a8 8 0 0 1-16 0Zm8 88a12 12 0 1 1 12-12a12 12 0 0 1-12 12"
/></svg
>
<div>
<slot />
</div>
</div>
</div>

1
src/lib/components/events/EventWrapper.svelte

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
import { logged_in_user } from '$lib/stores/users'
import type { NDKEvent } from '@nostr-dev-kit/ndk'
import CopyField from '../CopyField.svelte'
import { nip19 } from 'nostr-tools'
import { ndkEventToNeventOrNaddr } from '../repo/utils'
export let type: 'proposal' | 'issue' = 'proposal'

2
src/lib/components/proposals/ProposalsList.svelte

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
export let title: string = ''
export let proposals_or_issues: ProposalSummary[] | IssueSummary[] = []
export let repo_naddr_override: string | undefined = undefined;
export let repo_naddr_override: string | undefined = undefined
export let loading: boolean = false
export let show_repo: boolean = false
export let limit: number = 0

2
src/lib/components/proposals/ProposalsListItem.svelte

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
loading,
} = summary_defaults
export let show_repo: boolean = false
export let repo_naddr_override: string | undefined = undefined;
export let repo_naddr_override: string | undefined = undefined
let short_title: string
let created_at_ago: string
$: {

8
src/lib/components/repo/RepoHeader.svelte

@ -48,8 +48,12 @@ @@ -48,8 +48,12 @@
>
{#if created_at === 0 && name.length === 0}
<span class="text-xs text-warning">
cannot find referenced repository event by <div class="badge bg-base-400 text-warning"><UserHeader user={author} inline size='xs'/></div>
</span>
cannot find referenced repository event by <div
class="badge bg-base-400 text-warning"
>
<UserHeader user={author} inline size="xs" />
</div>
</span>
{/if}
{/if}
<RepoMenu {selected_tab} />

4
src/lib/components/repo/utils.ts

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
import type { AddressPointer } from 'nostr-tools/lib/types/nip19'
import type { RepoCollection, RepoEvent } from './type'
import { nip19 } from 'nostr-tools'
import { repo_kind } from '$lib/kinds'
import type { NDKEvent, NDKRelay } from '@nostr-dev-kit/ndk'
import type { NDKEvent } from '@nostr-dev-kit/ndk'
import type { AddressPointer } from 'nostr-tools/nip19'
export const selectRepoFromCollection = (
collection: RepoCollection

8
src/lib/stores/repos.ts

@ -26,7 +26,7 @@ export const repo_collections: { @@ -26,7 +26,7 @@ export const repo_collections: {
export const ensureRepo = (
a: string | NDKEvent,
naddr_relays: string[] | undefined = undefined,
naddr_relays: string[] | undefined = undefined
): Writable<RepoEvent> => {
if (typeof a !== 'string') {
const repo_event = eventToRepoEvent(a)
@ -54,7 +54,7 @@ export const ensureRepo = ( @@ -54,7 +54,7 @@ export const ensureRepo = (
identifier,
author: pubkey,
naddr: aToNaddr(a_ref) || '',
maintainers: [pubkey],
maintainers: [pubkey],
})
const sub = ndk.subscribe(
@ -107,7 +107,7 @@ export const ensureRepo = ( @@ -107,7 +107,7 @@ export const ensureRepo = (
export const returnRepo = async (
a: string,
naddr_relays: string[] | undefined = undefined,
naddr_relays: string[] | undefined = undefined
): Promise<RepoEvent> => {
return new Promise((r) => {
const unsubscriber = ensureRepo(a, naddr_relays).subscribe((c) => {
@ -123,7 +123,7 @@ export const returnRepo = async ( @@ -123,7 +123,7 @@ export const returnRepo = async (
export const ensureRepoCollection = (
a: string,
naddr_relays: string[] | undefined = undefined,
naddr_relays: string[] | undefined = undefined
): Writable<RepoCollection> => {
if (!repo_collections[a]) {
const base: RepoCollection = {

8
src/lib/stores/users.ts

@ -8,14 +8,14 @@ import { ndk } from './ndk' @@ -8,14 +8,14 @@ import { ndk } from './ndk'
export const users: { [hexpubkey: string]: Writable<UserObject> } = {}
let empty_user: Writable<UserObject> = writable({
const empty_user: Writable<UserObject> = writable({
loading: true,
hexpubkey:'',
npub: "npub...",
hexpubkey: '',
npub: 'npub...',
})
export const ensureUser = (hexpubkey: string): Writable<UserObject> => {
if (hexpubkey === '') return empty_user;
if (hexpubkey === '') return empty_user
if (!users[hexpubkey]) {
const u = ndk.getUser({ hexpubkey })

12
src/lib/wrappers/ComposeIssue.svelte

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
edit_mode = !submitted
}
let submit_attempted = false
async function sendIssue(title: string, content: string) {
submit_attempted = true
if (title.length < 10) return
@ -88,7 +88,9 @@ @@ -88,7 +88,9 @@
placeholder="title"
/>
{#if submit_attempted && title.length < 10}
<div class="text-warning pr-3 text-sm align-middle">title must be at least 10 characters</div>
<div class="pr-3 align-middle text-sm text-warning">
title must be at least 10 characters
</div>
{/if}
</label>
<label class="form-control w-full">
@ -105,10 +107,12 @@ @@ -105,10 +107,12 @@
></textarea>
</label>
<div class="flex items-center mt-2">
<div class="mt-2 flex items-center">
<div class="flex-auto"></div>
{#if submit_attempted && title.length < 10}
<div class="text-warning pr-3 text-sm align-middle">title must be at least 10 characters</div>
<div class="pr-3 align-middle text-sm text-warning">
title must be at least 10 characters
</div>
{/if}
<button
on:click={() => sendIssue(title, content)}

10
src/lib/wrappers/RepoMenu.svelte

@ -34,8 +34,9 @@ @@ -34,8 +34,9 @@
<path d={proposal_icon_path.open_pull} />
</svg>
Proposals
{#if $proposal_summaries.loading}
<span class="loading loading-spinner loading-xs ml-2 text-neutral"></span>
{#if $proposal_summaries.loading}
<span class="loading loading-spinner loading-xs ml-2 text-neutral"
></span>
{:else if $proposal_summaries.summaries.filter((s) => s.status === proposal_status_open).length > 0}
<span class="badge badge-neutral badge-sm ml-2">
{$proposal_summaries.summaries.filter(
@ -59,8 +60,9 @@ @@ -59,8 +60,9 @@
{/each}
</svg>
Issues
{#if $issue_summaries.loading}
<span class="loading loading-spinner loading-xs ml-2 text-neutral"></span>
{#if $issue_summaries.loading}
<span class="loading loading-spinner loading-xs ml-2 text-neutral"
></span>
{:else if $issue_summaries.summaries.filter((s) => s.status === proposal_status_open).length > 0}
<span class="badge badge-neutral badge-sm ml-2">
{$issue_summaries.summaries.filter(

8
src/lib/wrappers/RepoPageWrapper.svelte

@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
import RepoDetails from '$lib/wrappers/RepoDetails.svelte'
import {
ensureSelectedRepoCollection,
selected_repo_collection,
selected_repo_event,
} from '$lib/stores/repo'
import RepoHeader from '$lib/components/repo/RepoHeader.svelte'
@ -33,11 +32,6 @@ @@ -33,11 +32,6 @@
invalid_naddr = true
}
}
let waited_5_secs = false
setTimeout(() => {
waited_5_secs = true
}, 5000)
</script>
<RepoHeader {...$selected_repo_event} {selected_tab} />
@ -65,7 +59,7 @@ @@ -65,7 +59,7 @@
<div class="border-b border-base-400 bg-base-300 px-6 py-3 md:hidden">
<h4 class="">Repository Details</h4>
</div>
<div class="prose my-3 px-6 md:ml-2 md:px-0 w-full">
<div class="prose my-3 w-full px-6 md:ml-2 md:px-0">
<RepoDetails {a} />
</div>
</div>

13
src/routes/concept/+page.svelte

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
<script lang="ts">
import AlertError from "$lib/components/AlertError.svelte"
import Container from "$lib/components/Container.svelte"
import AlertError from '$lib/components/AlertError.svelte'
import Container from '$lib/components/Container.svelte'
import SvelteMarkdown from 'svelte-markdown'
async function get_md() {
const res = await fetch("/concept.md");
return await res.text()
const res = await fetch('/concept.md')
return await res.text()
}
</script>
@ -18,10 +18,7 @@ @@ -18,10 +18,7 @@
<p>loading...</p>
{:then md}
<article class="prose prose-sm mt-3">
<SvelteMarkdown
options={{ gfm: true }}
source={md}
/>
<SvelteMarkdown options={{ gfm: true }} source={md} />
</article>
{:catch error}
<AlertError>

7
src/routes/e/[nostr_ref]/+page.svelte

@ -23,10 +23,7 @@ @@ -23,10 +23,7 @@
waited = true
}
let lookupEvent = (
id: string,
relays: string[] | undefined = undefined,
) => {
let lookupEvent = (id: string, relays: string[] | undefined = undefined) => {
let sub = ndk.subscribe(
{
ids: [id],
@ -35,7 +32,7 @@ @@ -35,7 +32,7 @@
{
closeOnEose: false,
},
NDKRelaySet.fromRelayUrls([ ...base_relays, ...(relays || [])], ndk)
NDKRelaySet.fromRelayUrls([...base_relays, ...(relays || [])], ndk)
)
sub.on('event', (event: NDKEvent) => {

13
tailwind.config.js

@ -1,21 +1,18 @@ @@ -1,21 +1,18 @@
/** @type {import('tailwindcss').Config} */
import typography from '@tailwindcss/typography'
import daisyui from 'daisyui'
export default {
content: ['./src/**/*.{svelte,js,ts}'],
theme: {
extend: {
colors: {
"base-400": "#16171e",
'base-400': '#16171e',
},
},
},
plugins: [
require('@tailwindcss/typography'),
require('daisyui'),
],
plugins: [typography, daisyui],
daisyui: {
themes: ['dracula'],
}
},
}

3
tsconfig.json

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"types": ["vitest/globals"],
"types": ["vitest/globals"]
},
"include": ["*.config.*s", "src/**/*"]
}

Loading…
Cancel
Save