From 0f0cf183f99d5fc84a1abacff9a29cc71cb84c28 Mon Sep 17 00:00:00 2001 From: ThaUnknown <6506529+ThaUnknown@users.noreply.github.com> Date: Sat, 26 Apr 2025 04:25:45 +0200 Subject: [PATCH] feat: proper liting support --- eslint.config.js | 23 +++++++++++++++++-- package.json | 4 ++-- .../ui/extensions/extensions.svelte | 2 +- .../ui/select/select-content.svelte | 4 ++-- .../components/ui/select/select-item.svelte | 8 +++---- .../components/ui/sheet/sheet-content.svelte | 2 +- .../ui/sheet/sheet-description.svelte | 2 +- .../components/ui/sheet/sheet-footer.svelte | 2 +- .../components/ui/sheet/sheet-header.svelte | 2 +- .../components/ui/sheet/sheet-title.svelte | 2 +- .../ui/sidebar/SidebarButton.svelte | 3 ++- .../components/ui/table/table-header.svelte | 1 - src/lib/modules/irc.ts | 16 ++++++------- src/routes/app/settings/app/+page.svelte | 2 +- tailwind.config.ts | 16 ++++++------- tsconfig.json | 3 +++ 16 files changed, 56 insertions(+), 36 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 5e63f6a..443ad6f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -23,8 +23,27 @@ export default tseslint.config( 'newlines-between': 'always', groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'] }], - '@typescript-eslint/no-unnecessary-condition': 'warn', - '@typescript-eslint/no-unused-vars': 'off' + '@typescript-eslint/no-unnecessary-condition': 'warn' + // '@typescript-eslint/no-unused-vars': 'off' + } + }, + { + files: ['**/*.svelte'], + rules: { + 'no-unused-vars': ['error', { + varsIgnorePattern: '.{2}(Events|Props)', + args: 'none', + caughtErrors: 'none', + ignoreRestSiblings: true, + vars: 'all' + }], + '@typescript-eslint/no-unused-vars': ['error', { + varsIgnorePattern: '.{2}(Events|Props)', + args: 'none', + caughtErrors: 'none', + ignoreRestSiblings: true, + vars: 'all' + }] } } ) diff --git a/package.json b/package.json index 136d523..6c587d1 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "lint": "eslint -c eslint.config.js", - "lint:fix": "eslint -c eslint.config.js --fix", + "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:generate": "node --experimental-strip-types ./generateALIntrospection.ts" diff --git a/src/lib/components/ui/extensions/extensions.svelte b/src/lib/components/ui/extensions/extensions.svelte index d8d0e90..7f11c7a 100644 --- a/src/lib/components/ui/extensions/extensions.svelte +++ b/src/lib/components/ui/extensions/extensions.svelte @@ -23,7 +23,7 @@ function filterSearch > (repositories: T, input: string): T { if (!input) return repositories - return repositories.filter(([id, _]) => id.toLowerCase().includes(input.toLowerCase())) as T + return repositories.filter(([id]) => id.toLowerCase().includes(input.toLowerCase())) as T } let extensionInput = '' diff --git a/src/lib/components/ui/select/select-content.svelte b/src/lib/components/ui/select/select-content.svelte index 8f35ae0..68e3b67 100644 --- a/src/lib/components/ui/select/select-content.svelte +++ b/src/lib/components/ui/select/select-content.svelte @@ -6,10 +6,10 @@ type $$Props = SelectPrimitive.ContentProps - let className: $$Props['class'] = '' + let className: $$Props['class'] = undefined export let sideOffset: $$Props['sideOffset'] = 4 export let inTransition: $$Props['inTransition'] = flyAndScale - export let inTransitionConfig: $$Props['inTransitionConfig'] + export let inTransitionConfig: $$Props['inTransitionConfig'] = undefined export let outTransition: $$Props['outTransition'] = scale export let outTransitionConfig: $$Props['outTransitionConfig'] = { start: 0.95, diff --git a/src/lib/components/ui/select/select-item.svelte b/src/lib/components/ui/select/select-item.svelte index d5160c8..e8b40a3 100644 --- a/src/lib/components/ui/select/select-item.svelte +++ b/src/lib/components/ui/select/select-item.svelte @@ -7,10 +7,10 @@ type $$Props = SelectPrimitive.ItemProps type $$Events = Required - let className: $$Props['class'] = '' - export let value: $$Props['value'] - export let label: $$Props['label'] - export let disabled: $$Props['disabled'] + let className: $$Props['class'] = undefined + export let value: $$Props['value'] = undefined + export let label: $$Props['label'] = undefined + export let disabled: $$Props['disabled'] = undefined export { className as class } diff --git a/src/lib/components/ui/sheet/sheet-content.svelte b/src/lib/components/ui/sheet/sheet-content.svelte index 4e21d88..dd05ccf 100644 --- a/src/lib/components/ui/sheet/sheet-content.svelte +++ b/src/lib/components/ui/sheet/sheet-content.svelte @@ -17,7 +17,7 @@ side?: Side } - let className: $$Props['class'] + let className: $$Props['class'] = undefined export let side: $$Props['side'] = 'right' export { className as class } export let inTransition: $$Props['inTransition'] = fly diff --git a/src/lib/components/ui/sheet/sheet-description.svelte b/src/lib/components/ui/sheet/sheet-description.svelte index 0576a50..079e2d9 100644 --- a/src/lib/components/ui/sheet/sheet-description.svelte +++ b/src/lib/components/ui/sheet/sheet-description.svelte @@ -5,7 +5,7 @@ type $$Props = SheetPrimitive.DescriptionProps - let className: $$Props['class'] + let className: $$Props['class'] = undefined export { className as class } diff --git a/src/lib/components/ui/sheet/sheet-footer.svelte b/src/lib/components/ui/sheet/sheet-footer.svelte index 9234ce3..80a3454 100644 --- a/src/lib/components/ui/sheet/sheet-footer.svelte +++ b/src/lib/components/ui/sheet/sheet-footer.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/sheet/sheet-header.svelte b/src/lib/components/ui/sheet/sheet-header.svelte index 3cd5b3c..93179ca 100644 --- a/src/lib/components/ui/sheet/sheet-header.svelte +++ b/src/lib/components/ui/sheet/sheet-header.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/sheet/sheet-title.svelte b/src/lib/components/ui/sheet/sheet-title.svelte index 804e137..07fe68d 100644 --- a/src/lib/components/ui/sheet/sheet-title.svelte +++ b/src/lib/components/ui/sheet/sheet-title.svelte @@ -5,7 +5,7 @@ type $$Props = SheetPrimitive.TitleProps - let className: $$Props['class'] + let className: $$Props['class'] = undefined export { className as class } diff --git a/src/lib/components/ui/sidebar/SidebarButton.svelte b/src/lib/components/ui/sidebar/SidebarButton.svelte index 34a3df5..b5dd119 100644 --- a/src/lib/components/ui/sidebar/SidebarButton.svelte +++ b/src/lib/components/ui/sidebar/SidebarButton.svelte @@ -15,8 +15,9 @@ import { Button, type Props } from '$lib/components/ui/button' import { cn } from '$lib/utils.js' - type $$Props = Props & { href: string | null | undefined } + type $$Props = Props & { disabled?: boolean | undefined | null } export let href: string | null | undefined = undefined + export let disabled: $$Props['disabled'] = undefined function matchPath (path: string, page: { url: URL }) { return page.url.pathname.startsWith(path) diff --git a/src/lib/components/ui/table/table-header.svelte b/src/lib/components/ui/table/table-header.svelte index 7564d6e..5ab9b97 100644 --- a/src/lib/components/ui/table/table-header.svelte +++ b/src/lib/components/ui/table/table-header.svelte @@ -9,7 +9,6 @@ export { className as class } - diff --git a/src/lib/modules/irc.ts b/src/lib/modules/irc.ts index 85adbda..2a8f424 100644 --- a/src/lib/modules/irc.ts +++ b/src/lib/modules/irc.ts @@ -8,8 +8,6 @@ import { decryptMessage, encryptMessage } from './crypt' import type IrcChannel from '@thaunknown/web-irc/channel' import type { ChatMessage, ChatUser } from '$lib/components/ui/chat' -import { dev } from '$app/environment' - export interface IRCUser { nick: string, ident: string, hostname: string, modes: string[], tags: object } export interface PrivMessage { from_server: boolean @@ -38,18 +36,18 @@ export default class MessageClient extends EventEmitter { this.ident = ident this.irc.on('userlist', async ({ users }: { users: IRCUser[] }) => { this.users.value = users.reduce((acc, user) => { - const [nick, pfpid, pfpex] = user.nick.split('_') - const [type, id] = user.ident.split('_') - acc[user.ident] = { nick, id, pfpid: `${pfpid}.${pfpex}`, type: type as 'al' | 'guest' } + const [nick, pfpid, pfpex] = user.nick.split('_') as [string, string, string] + const [type, id] = user.ident.split('_') as ['al' | 'guest', string] + acc[user.ident] = { nick, id, pfpid: `${pfpid}.${pfpex}`, type } return acc }, this.users.value) }) this.irc.on('join', async (user: IRCUser) => { try { - const [nick, pfpid, pfpex] = user.nick.split('_') - const [type, id] = user.ident.split('_') - this.users.value[user.ident] = { nick, id, pfpid: `${pfpid}.${pfpex}`, type: type as 'al' | 'guest' } + const [nick, pfpid, pfpex] = user.nick.split('_') as [string, string, string] + const [type, id] = user.ident.split('_') as ['al' | 'guest', string] + this.users.value[user.ident] = { nick, id, pfpid: `${pfpid}.${pfpex}`, type } this.users.update(users => users) } catch (error) { console.error(error) @@ -70,7 +68,7 @@ export default class MessageClient extends EventEmitter { try { this.messages.update(messages => [...messages, { message, - user: this.users.value[priv.ident], + user: this.users.value[priv.ident]!, type: 'incoming', date: new Date(priv.time) }]) diff --git a/src/routes/app/settings/app/+page.svelte b/src/routes/app/settings/app/+page.svelte index 28c57bb..9aee281 100644 --- a/src/routes/app/settings/app/+page.svelte +++ b/src/routes/app/settings/app/+page.svelte @@ -44,7 +44,7 @@ const imported = JSON.parse(await navigator.clipboard.readText()) $settings = imported native.restart() - } catch (error) { + } catch (err) { toast.error('Failed to import settings', { description: 'Failed to import settings from clipboard, make sure the copied data is valid JSON.', duration: 5000 diff --git a/tailwind.config.ts b/tailwind.config.ts index 3e127a3..0c06482 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -5,12 +5,12 @@ import type { Config } from 'tailwindcss' const config: Config = { plugins: [ - plugin(({ addVariant, matchVariant }) => { - addVariant('select', ['&:hover', '&:focus-visible', '&:active']) - addVariant('group-select', [':merge(.group):hover &', ':merge(.group):focus-visible &', ':merge(.group):active &']) - addVariant('fullscreen', '&:fullscreen') - addVariant('group-fullscreen', ':merge(.group):fullscreen &') - matchVariant( + plugin((api) => { + api.addVariant('select', ['&:hover', '&:focus-visible', '&:active']) + api.addVariant('group-select', [':merge(.group):hover &', ':merge(.group):focus-visible &', ':merge(.group):active &']) + api.addVariant('fullscreen', '&:fullscreen') + api.addVariant('group-fullscreen', ':merge(.group):fullscreen &') + api.matchVariant( 'group-fullscreen', (value, { modifier }) => [ ':merge(.group):fullscreen &', @@ -18,7 +18,7 @@ const config: Config = { ], { values: { DEFAULT: undefined } } ) - matchVariant( + api.matchVariant( 'group-select', (value, { modifier }) => [ ':merge(.group):hover &', @@ -30,7 +30,7 @@ const config: Config = { ], { values: { DEFAULT: undefined } } ) - addVariant('mobile', '@media (pointer: none), (pointer: coarse)') + api.addVariant('mobile', '@media (pointer: none), (pointer: coarse)') }) ], darkMode: ['class'], diff --git a/tsconfig.json b/tsconfig.json index 4b95154..c4a67a1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,6 +37,9 @@ "src/**/*.svelte", "src/global.d.tsd.ts", "src/global.d.tsd.ts" + ], + "exclude": [ + "../node_modules/**" ] // 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