From b985a265b0591ca9d669c956c25c415b52f7a114 Mon Sep 17 00:00:00 2001 From: ThaUnknown <6506529+ThaUnknown@users.noreply.github.com> Date: Sun, 8 Jun 2025 22:43:41 +0200 Subject: [PATCH] feat: add tests [just strict static analysis] --- .github/workflows/check.yml | 39 +++++++++++ eslint.config.js | 9 --- generateALIntrospection.ts | 1 - package.json | 15 +++-- pnpm-lock.yaml | 20 +++--- src/lib/components/EpisodesList.svelte | 3 +- src/lib/components/ui/chat/index.ts | 2 +- .../components/ui/checkbox/checkbox.svelte | 2 +- .../context-menu-checkbox-item.svelte | 4 +- .../context-menu/context-menu-content.svelte | 4 +- .../ui/context-menu/context-menu-item.svelte | 4 +- .../ui/context-menu/context-menu-label.svelte | 4 +- .../context-menu-radio-group.svelte | 2 +- .../context-menu-radio-item.svelte | 2 +- .../context-menu-separator.svelte | 2 +- .../context-menu/context-menu-shortcut.svelte | 2 +- .../context-menu-sub-content.svelte | 4 +- .../context-menu-sub-trigger.svelte | 4 +- src/lib/components/ui/drawer/index.ts | 2 +- .../ui/extensions/ExtensionSettings.svelte | 8 +-- src/lib/components/ui/label/label.svelte | 2 +- .../ui/toggle-group/toggle-group.svelte | 1 + src/lib/modules/extensions/storage.ts | 15 ++++- src/lib/modules/irc.ts | 2 +- src/types/fs.d.ts | 13 ++++ src/types/module.d.ts | 34 ++++++++++ src/types/path.d.ts | 9 +++ src/types/process.d.ts | 9 +++ svelte.config.js | 3 +- tsconfig.json | 61 +++-------------- tsconfig.node.json | 50 ++++++++++++++ tsconfig.web.json | 65 +++++++++++++++++++ vite.config.ts | 14 ++-- 33 files changed, 296 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/check.yml create mode 100644 src/types/fs.d.ts create mode 100644 src/types/module.d.ts create mode 100644 src/types/path.d.ts create mode 100644 src/types/process.d.ts create mode 100644 tsconfig.node.json create mode 100644 tsconfig.web.json diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..538b3a2 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,39 @@ +name: Check + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + name: Install pnpm + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.9 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Sync + run: pnpm run sync + + - name: Lint + run: pnpm run lint + + - name: Check GQL + run: pnpm run gql:check + + - name: Check Svelte and TypeScript + run: pnpm run check \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js index d2b01b1..2f86e50 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -11,15 +11,6 @@ export default tseslint.config( tsconfigRootDir: import.meta.dirname, svelteConfig } - }, - rules: { - "svelte/no-useless-mustaches": [ - "error", - { - "ignoreIncludesComment": false, - "ignoreStringEscape": true - } - ] } } ) diff --git a/generateALIntrospection.ts b/generateALIntrospection.ts index 82882a8..9a41446 100644 --- a/generateALIntrospection.ts +++ b/generateALIntrospection.ts @@ -1,4 +1,3 @@ -// @ts-expect-error no types for this, that's fine import { writeFileSync } from 'node:fs' import { getIntrospectedSchema, minifyIntrospectionQuery } from '@urql/introspection' diff --git a/package.json b/package.json index 41cd84d..9bb8649 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "6.3.50", + "version": "6.3.51", "license": "BUSL-1.1", "private": true, "packageManager": "pnpm@9.14.4", @@ -8,12 +8,13 @@ "dev": "vite dev --open", "build": "vite build", "preview": "vite preview", - "check": "svelte-kit sync && svelte-check --threshold error --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check -threshold error --tsconfig ./tsconfig.json --watch", + "sync": "svelte-kit sync", + "check": "svelte-check --threshold error --tsconfig ./tsconfig.web.json", + "check:watch": "svelte-check -threshold error --tsconfig ./tsconfig.web.json --watch", "lint": "eslint --quiet -c eslint.config.js", "lint:fix": "eslint --quiet -c eslint.config.js --fix", - "gql:turbo": "node ./node_modules/gql.tada/bin/cli.js turbo", - "gql:check": "node ./node_modules/gql.tada/bin/cli.js check", + "gql:turbo": "node ./node_modules/gql.tada/bin/cli.js turbo -c ./tsconfig.web.json", + "gql:check": "node ./node_modules/gql.tada/bin/cli.js check -c ./tsconfig.web.json", "gql:generate": "node --experimental-strip-types ./generateALIntrospection.ts" }, "devDependencies": { @@ -27,7 +28,7 @@ "autoprefixer": "^10.4.21", "bits-ui": "^0.22.0", "cmdk-sv": "^0.0.19", - "eslint-config-standard-universal": "^1.0.6", + "eslint-config-standard-universal": "^1.0.8", "gql.tada": "^1.8.10", "hayase-extensions": "github:hayase-app/extensions", "jassub": "^1.8.6", @@ -45,7 +46,7 @@ "@cloudflare/speedtest": "^1.4.1", "@fontsource-variable/nunito": "^5.2.5", "@prgm/sveltekit-progress-bar": "2.0.0", - "@thaunknown/web-irc": "^1.0.1", + "@thaunknown/web-irc": "^1.0.3", "@urql/exchange-auth": "^2.2.1", "@urql/exchange-graphcache": "^7.2.3", "@urql/exchange-refocus": "^1.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0091bb1..9e5790c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ importers: specifier: 2.0.0 version: 2.0.0(@sveltejs/kit@2.21.0(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.19(terser@5.39.0)))(svelte@4.2.19)(vite@5.4.19(terser@5.39.0)))(svelte@4.2.19) '@thaunknown/web-irc': - specifier: ^1.0.1 - version: 1.0.1 + specifier: ^1.0.3 + version: 1.0.3 '@urql/exchange-auth': specifier: ^2.2.1 version: 2.2.1(@urql/core@5.1.0(graphql@16.10.0)) @@ -148,8 +148,8 @@ importers: specifier: ^0.0.19 version: 0.0.19(svelte@4.2.19) eslint-config-standard-universal: - specifier: ^1.0.6 - version: 1.0.6(@typescript-eslint/parser@8.32.1(eslint@9.27.0(jiti@1.21.6))(typescript@5.8.3))(jiti@1.21.6) + specifier: ^1.0.8 + version: 1.0.8(@typescript-eslint/parser@8.32.1(eslint@9.27.0(jiti@1.21.6))(typescript@5.8.3))(jiti@1.21.6) gql.tada: specifier: ^1.8.10 version: 1.8.10(@gql.tada/svelte-support@1.0.1(svelte@4.2.19)(typescript@5.8.3))(graphql@16.10.0)(typescript@5.8.3) @@ -656,8 +656,8 @@ packages: '@thaunknown/simple-websocket@9.1.3': resolution: {integrity: sha512-pf/FCJsgWtLJiJmIpiSI7acOZVq3bIQCpnNo222UFc8Ph1lOUOTpe6LoYhhiOSKB9GUaWJEVUtZ+sK1/aBgU5Q==} - '@thaunknown/web-irc@1.0.1': - resolution: {integrity: sha512-oP+mrvD2U7gSXHTfT77+A+i2YVT5jp4qCbCXLrNU9aFzXdJ0iRsBbdhdT/AgeB7Nf4O+SC/wVCnwhnAfUoo0Fg==} + '@thaunknown/web-irc@1.0.3': + resolution: {integrity: sha512-gzTDs6+sAfkpuEB1IbVwBfu5btEt2D/0RGP+PwUPITIOZjZOpZLjs3d4ipvzl9eq+76otuudopmIlSD0pUT4Mw==} '@types/cookie@0.6.0': resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} @@ -1207,8 +1207,8 @@ packages: peerDependencies: eslint: '>=6.0.0' - eslint-config-standard-universal@1.0.6: - resolution: {integrity: sha512-QNyO5eC69udu7grO+INuGPETVmhodA5vg0u5WXX4tdesh7n6BpdMHUjXJnsW6N6466i6l7jFYrDyCn7nfN83nw==} + eslint-config-standard-universal@1.0.8: + resolution: {integrity: sha512-GYuMkU93hqkoYCsA+sRR0RlLTKCSuB2Yuzois/uWdaRq9Vu9U69gfvNlQLWU7Pkqcaw56Vwll9tTINVWTjl5Jg==} eslint-import-resolver-node@0.3.9: resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==} @@ -3012,7 +3012,7 @@ snapshots: - supports-color - utf-8-validate - '@thaunknown/web-irc@1.0.1': + '@thaunknown/web-irc@1.0.3': dependencies: grapheme-splitter: 1.0.4 streamx: 2.22.0 @@ -3695,7 +3695,7 @@ snapshots: eslint: 9.27.0(jiti@1.21.6) semver: 7.7.2 - eslint-config-standard-universal@1.0.6(@typescript-eslint/parser@8.32.1(eslint@9.27.0(jiti@1.21.6))(typescript@5.8.3))(jiti@1.21.6): + eslint-config-standard-universal@1.0.8(@typescript-eslint/parser@8.32.1(eslint@9.27.0(jiti@1.21.6))(typescript@5.8.3))(jiti@1.21.6): dependencies: '@stylistic/eslint-plugin': 4.2.0(eslint@9.27.0(jiti@1.21.6))(typescript@5.8.3) eslint: 9.27.0(jiti@1.21.6) diff --git a/src/lib/components/EpisodesList.svelte b/src/lib/components/EpisodesList.svelte index 244f7c7..71b2340 100644 --- a/src/lib/components/EpisodesList.svelte +++ b/src/lib/components/EpisodesList.svelte @@ -10,7 +10,6 @@ import ChevronLeft from 'lucide-svelte/icons/chevron-left' import ChevronRight from 'lucide-svelte/icons/chevron-right' import Play from 'lucide-svelte/icons/play' - import { readable } from 'svelte/store' import Pagination from './Pagination.svelte' import { Button } from './ui/button' @@ -72,7 +71,7 @@ searchStore.set({ media, episode }) } - export let following = authAggregator.following(media.id) ?? readable(null) + export let following = authAggregator.following(media.id) $: followerEntries = $following?.data?.Page?.mediaList?.filter(e => e?.user?.id !== authAggregator.id()) ?? [] diff --git a/src/lib/components/ui/chat/index.ts b/src/lib/components/ui/chat/index.ts index 81d6b12..693062a 100644 --- a/src/lib/components/ui/chat/index.ts +++ b/src/lib/components/ui/chat/index.ts @@ -1,7 +1,7 @@ import type { Viewer } from '$lib/modules/anilist/queries' import type { ResultOf } from 'gql.tada' -export type ChatUser = Omit['Viewer']>, 'id'> & { id: string | number } +export type ChatUser = Omit['Viewer']>, 'id' | 'bannerImage' | 'about' | 'isFollowing' | 'isFollower' | 'donatorBadge' | 'options' | 'createdAt' | 'statistics'> & { id: string | number } export interface ChatMessage { message: string diff --git a/src/lib/components/ui/checkbox/checkbox.svelte b/src/lib/components/ui/checkbox/checkbox.svelte index 1b13677..1f8c568 100644 --- a/src/lib/components/ui/checkbox/checkbox.svelte +++ b/src/lib/components/ui/checkbox/checkbox.svelte @@ -8,7 +8,7 @@ type $$Props = CheckboxPrimitive.Props type $$Events = CheckboxPrimitive.Events - let className: $$Props['class'] + let className: $$Props['class'] = undefined export let checked: $$Props['checked'] = false export { className as class } diff --git a/src/lib/components/ui/context-menu/context-menu-checkbox-item.svelte b/src/lib/components/ui/context-menu/context-menu-checkbox-item.svelte index 6c7f57c..8118c01 100644 --- a/src/lib/components/ui/context-menu/context-menu-checkbox-item.svelte +++ b/src/lib/components/ui/context-menu/context-menu-checkbox-item.svelte @@ -7,9 +7,9 @@ type $$Props = ContextMenuPrimitive.CheckboxItemProps type $$Events = ContextMenuPrimitive.CheckboxItemEvents - let className: $$Props['class'] + let className: $$Props['class'] = undefined export { className as class } - export let checked: $$Props['checked'] + export let checked: $$Props['checked'] = false diff --git a/src/lib/components/ui/context-menu/context-menu-item.svelte b/src/lib/components/ui/context-menu/context-menu-item.svelte index 1a9cf2e..7f9030e 100644 --- a/src/lib/components/ui/context-menu/context-menu-item.svelte +++ b/src/lib/components/ui/context-menu/context-menu-item.svelte @@ -8,8 +8,8 @@ } type $$Events = ContextMenuPrimitive.ItemEvents - let className: $$Props['class'] - export let inset: $$Props['inset'] + let className: $$Props['class'] = undefined + export let inset: $$Props['inset'] = undefined export { className as class } diff --git a/src/lib/components/ui/context-menu/context-menu-label.svelte b/src/lib/components/ui/context-menu/context-menu-label.svelte index f55d799..d68bcc6 100644 --- a/src/lib/components/ui/context-menu/context-menu-label.svelte +++ b/src/lib/components/ui/context-menu/context-menu-label.svelte @@ -7,8 +7,8 @@ inset?: boolean } - let className: $$Props['class'] - export let inset: $$Props['inset'] + let className: $$Props['class'] = undefined + export let inset: $$Props['inset'] = undefined export { className as class } diff --git a/src/lib/components/ui/context-menu/context-menu-radio-group.svelte b/src/lib/components/ui/context-menu/context-menu-radio-group.svelte index be281ae..8ea4d72 100644 --- a/src/lib/components/ui/context-menu/context-menu-radio-group.svelte +++ b/src/lib/components/ui/context-menu/context-menu-radio-group.svelte @@ -3,7 +3,7 @@ type $$Props = ContextMenuPrimitive.RadioGroupProps - export let value: $$Props['value'] + export let value: $$Props['value'] = undefined diff --git a/src/lib/components/ui/context-menu/context-menu-radio-item.svelte b/src/lib/components/ui/context-menu/context-menu-radio-item.svelte index aa9e3d8..86f7c42 100644 --- a/src/lib/components/ui/context-menu/context-menu-radio-item.svelte +++ b/src/lib/components/ui/context-menu/context-menu-radio-item.svelte @@ -7,7 +7,7 @@ type $$Props = ContextMenuPrimitive.RadioItemProps type $$Events = ContextMenuPrimitive.RadioItemEvents - let className: $$Props['class'] + let className: $$Props['class'] = undefined export let value: $$Props['value'] export { className as class } diff --git a/src/lib/components/ui/context-menu/context-menu-separator.svelte b/src/lib/components/ui/context-menu/context-menu-separator.svelte index 34369cc..38099e7 100644 --- a/src/lib/components/ui/context-menu/context-menu-separator.svelte +++ b/src/lib/components/ui/context-menu/context-menu-separator.svelte @@ -5,7 +5,7 @@ type $$Props = ContextMenuPrimitive.SeparatorProps - let className: $$Props['class'] + let className: $$Props['class'] = undefined export { className as class } diff --git a/src/lib/components/ui/context-menu/context-menu-shortcut.svelte b/src/lib/components/ui/context-menu/context-menu-shortcut.svelte index 1700cfb..445475b 100644 --- a/src/lib/components/ui/context-menu/context-menu-shortcut.svelte +++ b/src/lib/components/ui/context-menu/context-menu-shortcut.svelte @@ -5,7 +5,7 @@ type $$Props = HTMLAttributes - let className: $$Props['class'] + let className: $$Props['class'] = undefined export { className as class } diff --git a/src/lib/components/ui/context-menu/context-menu-sub-content.svelte b/src/lib/components/ui/context-menu/context-menu-sub-content.svelte index bd34d5b..3a8eb39 100644 --- a/src/lib/components/ui/context-menu/context-menu-sub-content.svelte +++ b/src/lib/components/ui/context-menu/context-menu-sub-content.svelte @@ -5,9 +5,9 @@ type $$Props = ContextMenuPrimitive.SubContentProps - let className: $$Props['class'] + let className: $$Props['class'] = undefined export let transition: $$Props['transition'] = flyAndScale - export let transitionConfig: $$Props['transitionConfig'] + export let transitionConfig: $$Props['transitionConfig'] = undefined export { className as class } diff --git a/src/lib/components/ui/context-menu/context-menu-sub-trigger.svelte b/src/lib/components/ui/context-menu/context-menu-sub-trigger.svelte index ec0bdeb..00fccaf 100644 --- a/src/lib/components/ui/context-menu/context-menu-sub-trigger.svelte +++ b/src/lib/components/ui/context-menu/context-menu-sub-trigger.svelte @@ -9,8 +9,8 @@ } type $$Events = ContextMenuPrimitive.SubTriggerEvents - let className: $$Props['class'] - export let inset: $$Props['inset'] + let className: $$Props['class'] = undefined + export let inset: $$Props['inset'] = undefined export { className as class } diff --git a/src/lib/components/ui/drawer/index.ts b/src/lib/components/ui/drawer/index.ts index c7b16d2..35f9421 100644 --- a/src/lib/components/ui/drawer/index.ts +++ b/src/lib/components/ui/drawer/index.ts @@ -10,7 +10,7 @@ import Title from './drawer-title.svelte' import Root from './drawer.svelte' const Trigger = DrawerPrimitive.Trigger -const Portal = DrawerPrimitive.Portal +const Portal: typeof DrawerPrimitive.Portal = DrawerPrimitive.Portal const Close = DrawerPrimitive.Close export { diff --git a/src/lib/components/ui/extensions/ExtensionSettings.svelte b/src/lib/components/ui/extensions/ExtensionSettings.svelte index 16ad150..2c0bfa0 100644 --- a/src/lib/components/ui/extensions/ExtensionSettings.svelte +++ b/src/lib/components/ui/extensions/ExtensionSettings.svelte @@ -30,17 +30,17 @@ {#if options.type === 'string'}
- +
{:else if options.type === 'number'}
- +
{:else if options.type === 'boolean'}
- +
{/if} {/each} @@ -55,6 +55,6 @@ {#if $exopts[config.id]} - + {/if} diff --git a/src/lib/components/ui/label/label.svelte b/src/lib/components/ui/label/label.svelte index 310b643..d6f39cd 100644 --- a/src/lib/components/ui/label/label.svelte +++ b/src/lib/components/ui/label/label.svelte @@ -5,7 +5,7 @@ type $$Props = LabelPrimitive.Props - let className: $$Props['class'] + let className: $$Props['class'] = undefined export { className as class } diff --git a/src/lib/components/ui/toggle-group/toggle-group.svelte b/src/lib/components/ui/toggle-group/toggle-group.svelte index 2aee832..678d12a 100644 --- a/src/lib/components/ui/toggle-group/toggle-group.svelte +++ b/src/lib/components/ui/toggle-group/toggle-group.svelte @@ -9,6 +9,7 @@ import { cn } from '$lib/utils.js' + // eslint-disable-next-line no-undef type T = $$Generic<'single' | 'multiple'> type $$Props = ToggleGroupPrimitive.Props & VariantProps diff --git a/src/lib/modules/extensions/storage.ts b/src/lib/modules/extensions/storage.ts index 02639e2..8421615 100644 --- a/src/lib/modules/extensions/storage.ts +++ b/src/lib/modules/extensions/storage.ts @@ -10,8 +10,19 @@ import Worker from './worker?worker' import type extensionLoader from './worker' import type { ExtensionConfig } from 'hayase-extensions' -export const saved = persisted>('extensions', {}) -export const options = persisted, enabled: boolean}>>('extensionoptions', {}) +type SavedExtensions = Record + +type ExtensionsOptions = { + [K in keyof SavedExtensions]: { + // this is bad, but w/e + options: Record + enabled: boolean + } +} + +// Usage: +export const saved = persisted('extensions', {}) +export const options = persisted('extensionoptions', {}) // `http${string}` | `gh:${string}` | `npm:${string}` // http[s]://[url] -> http[s]://[url] diff --git a/src/lib/modules/irc.ts b/src/lib/modules/irc.ts index a299705..fcf1415 100644 --- a/src/lib/modules/irc.ts +++ b/src/lib/modules/irc.ts @@ -51,7 +51,7 @@ type IRCEvents = { } function ircUserToChatUser ({ id, pfpid, type, nick }: IRCChatUser): ChatUser { - return { id, avatar: { medium: getPFP({ id, pfpid, type }) }, name: nick, mediaListOptions: null } + return { id, avatar: { large: getPFP({ id, pfpid, type }) }, name: nick, mediaListOptions: null } } function ircIdentToChatUser (user: IRCUser): ChatUser { diff --git a/src/types/fs.d.ts b/src/types/fs.d.ts new file mode 100644 index 0000000..f402c31 --- /dev/null +++ b/src/types/fs.d.ts @@ -0,0 +1,13 @@ +declare module 'fs' { + export const writeFileSync: ( + file: string | URL, + data: string | Uint8Array, + options?: { encoding?: string, mode?: number, flag?: string } + ) => void +} + +declare module 'node:fs' { + // eslint-disable-next-line @typescript-eslint/no-require-imports + import path = require('fs') + export = path +} diff --git a/src/types/module.d.ts b/src/types/module.d.ts new file mode 100644 index 0000000..21ef596 --- /dev/null +++ b/src/types/module.d.ts @@ -0,0 +1,34 @@ +/* eslint-disable @typescript-eslint/method-signature-style */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable no-var */ +declare module 'module' { + var __dirname: string + var __filename: string + + global { + interface ImportMeta { + dirname: string + filename: string + url: string + resolve(specifier: string, parent?: string | URL): string + } + } +} + +declare global { + var __dirname: string + var __filename: string + + interface ImportMeta { + dirname: string + filename: string + url: string + resolve(specifier: string, parent?: string | URL): string + } +} + +declare module 'node:module' { + // eslint-disable-next-line @typescript-eslint/no-require-imports + import module = require('module') + export = module +} diff --git a/src/types/path.d.ts b/src/types/path.d.ts new file mode 100644 index 0000000..8c95d1b --- /dev/null +++ b/src/types/path.d.ts @@ -0,0 +1,9 @@ +declare module 'path' { + export function resolve(...paths: string[]): string +} + +declare module 'node:path' { + // eslint-disable-next-line @typescript-eslint/no-require-imports + import path = require('path') + export = path +} diff --git a/src/types/process.d.ts b/src/types/process.d.ts new file mode 100644 index 0000000..94e8ade --- /dev/null +++ b/src/types/process.d.ts @@ -0,0 +1,9 @@ +declare module 'process' { + export const env: Record +} + +declare module 'node:process' { + // eslint-disable-next-line @typescript-eslint/no-require-imports + import path = require('process') + export = path +} diff --git a/svelte.config.js b/svelte.config.js index 84a82a5..a50a686 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -5,6 +5,7 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' /** @type {import('@sveltejs/kit').Config} */ const config = { + // @ts-expect-error no typedef for this onwarn: (warning, handler) => { if (warning.code === 'a11y_media_has_caption') return if (warning.code === 'element_invalid_self_closing_tag') return @@ -17,7 +18,7 @@ const config = { name: process.env.npm_package_version }, alias: { - "lucide-svelte/dist/Icon.svelte": "./node_modules/lucide-svelte/dist/Icon.svelte" + 'lucide-svelte/dist/Icon.svelte': './node_modules/lucide-svelte/dist/Icon.svelte' } }, runtime: '' diff --git a/tsconfig.json b/tsconfig.json index 5b4cc20..8cfc52f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,63 +1,22 @@ { - "extends": "./.svelte-kit/tsconfig.json", "compilerOptions": { - "target": "ESNext", - "module": "esnext", - "lib": [ - "esnext", - "DOM", - "DOM.Iterable" - ], - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "rewriteRelativeImportExtensions": true, - "emitDeclarationOnly": false, - "noImplicitAny": true, - "strictNullChecks": true, - "verbatimModuleSyntax": true, - "isolatedModules": true, - "noEmit": true, - "noUncheckedIndexedAccess": true, - "declaration": true, - "alwaysStrict": true, - "strict": true, - "maxNodeModuleJsDepth": 3, - "allowSyntheticDefaultImports": true, - "plugins": [ - { - "name": "gql.tada/ts-plugin", - "schema": "https://graphql.anilist.co", - "tadaOutputLocation": "./src/lib/modules/anilist/graphql-env.d.ts", - "tadaTurboLocation": "./src/lib/modules/anilist/graphql-turbo.d.ts" - } - ], "typeRoots": [ + // these overrides are required, because we want a custom typed eventemitter, importing node types in any fashion will fully override the typed event emitter, making life a pain + // disabling type acquisition does NOT prevent type acquisition from working, WE LOVE TYPESCRIPT, INDUSTRY LEADING TECHNOLOGY "./src/types" ] }, "typeAcquisition": { "enable": false }, - "files": [ - "src/service-worker/index.ts" - ], - "include": [ - "src/service-worker/index.ts", - "src/**/*.js", - "src/**/*.cjs", - "src/**/*.ts", - "src/**/*.d.ts", - "src/**/*.svelte" - ], - "exclude": [ - "../node_modules/**" + "files": [], + "references": [ + { + "path": "./tsconfig.node.json" + }, + { + "path": "./tsconfig.web.json" + } ] // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 0000000..981de4e --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,50 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "esnext", + "lib": [ + "esnext", + "DOM", + "DOM.Iterable" + ], + "allowJs": true, + "checkJs": true, + "composite": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "rewriteRelativeImportExtensions": true, + "emitDeclarationOnly": false, + "noImplicitAny": true, + "strictNullChecks": true, + "verbatimModuleSyntax": true, + "isolatedModules": true, + "declaration": true, + "noUncheckedIndexedAccess": true, + "alwaysStrict": true, + "strict": true, + "outDir": "./dist", + "maxNodeModuleJsDepth": 3, + "allowSyntheticDefaultImports": true + }, + "typeAcquisition": { + "enable": false + }, + "include": [ + "eslint.config.js", + "vite.config.ts", + "svelte.config.js", + "tailwind.config.ts", + "generateALIntrospection.ts", + "src/types/**/*.d.ts", + "postcss.config.js", + "tsconfig.web.json" + ], + "exclude": [ + "../node_modules/**" + ] +} \ No newline at end of file diff --git a/tsconfig.web.json b/tsconfig.web.json new file mode 100644 index 0000000..7f9e4dc --- /dev/null +++ b/tsconfig.web.json @@ -0,0 +1,65 @@ +{ + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "target": "ESNext", + "module": "esnext", + "lib": [ + "esnext", + "DOM", + "DOM.Iterable" + ], + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "rewriteRelativeImportExtensions": true, + "emitDeclarationOnly": false, + "noImplicitAny": true, + "strictNullChecks": true, + "verbatimModuleSyntax": true, + "isolatedModules": true, + "noUncheckedIndexedAccess": true, + "declaration": true, + "alwaysStrict": true, + "strict": true, + "noEmit": false, + "outDir": "./dist", + "maxNodeModuleJsDepth": 3, + "allowSyntheticDefaultImports": true, + "composite": true, + "plugins": [ + { + "name": "gql.tada/ts-plugin", + "schema": "https://graphql.anilist.co", + "tadaOutputLocation": "./src/lib/modules/anilist/graphql-env.d.ts", + "tadaTurboLocation": "./src/lib/modules/anilist/graphql-turbo.d.ts" + } + ], + "typeRoots": [ + "./src/types" + ] + }, + "typeAcquisition": { + "enable": false + }, + "files": [ + "src/service-worker/index.ts" + ], + "include": [ + "src/service-worker/index.ts", + "src/**/*.js", + "src/**/*.cjs", + "src/**/*.ts", + "src/**/*.d.ts", + "src/**/*.json", + "src/**/*.svelte" + ], + "exclude": [ + "../node_modules/**" + ] +} \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index c6c0da1..d61a4e3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ license({ thirdParty: { allow: '(MIT OR Apache-2.0 OR ISC OR BSD-3-Clause OR BSD-2-Clause)', - output: resolve(__dirname, './build/LICENSE.txt'), + output: resolve(import.meta.dirname, './build/LICENSE.txt'), includeSelf: true } }) @@ -18,13 +18,13 @@ export default defineConfig({ resolve: { alias: { // thank you bottleneck for importing useless modules - './RedisConnection': resolve(__dirname, 'src/patches/empty.cjs'), - './RedisConnection.js': resolve(__dirname, 'src/patches/empty.cjs'), - './RedisDatastore': resolve(__dirname, 'src/patches/empty.cjs'), - './IORedisConnection': resolve(__dirname, 'src/patches/empty.cjs'), - './Scripts': resolve(__dirname, 'src/patches/empty.cjs'), + './RedisConnection': resolve(import.meta.dirname, 'src/patches/empty.cjs'), + './RedisConnection.js': resolve(import.meta.dirname, 'src/patches/empty.cjs'), + './RedisDatastore': resolve(import.meta.dirname, 'src/patches/empty.cjs'), + './IORedisConnection': resolve(import.meta.dirname, 'src/patches/empty.cjs'), + './Scripts': resolve(import.meta.dirname, 'src/patches/empty.cjs'), // no exports :/ - 'bittorrent-tracker/lib/client/websocket-tracker.js': resolve(__dirname, 'node_modules/bittorrent-tracker/lib/client/websocket-tracker.js'), + 'bittorrent-tracker/lib/client/websocket-tracker.js': resolve(import.meta.dirname, 'node_modules/bittorrent-tracker/lib/client/websocket-tracker.js') } }, server: { port: 7344 },