From b49d54caa7b87974c00e4f762c22f112dd4e8b9f Mon Sep 17 00:00:00 2001 From: Vojtech Simetka Date: Fri, 29 Dec 2023 18:52:03 +0100 Subject: [PATCH] chore: resolve lint issues --- .eslintignore | 1 + .eslintrc.cjs | 28 +++++++---- src/lib/components/data-display/badge.svelte | 7 +-- .../components/data-display/typography.svelte | 10 ++-- src/lib/components/inputs/button.svelte | 48 +++++++++---------- src/lib/components/inputs/input-text.svelte | 14 +++--- src/lib/icons/add-comment.svelte | 2 +- src/lib/icons/add.svelte | 2 +- src/lib/icons/arrow-down-right.svelte | 2 +- src/lib/icons/arrow-right.svelte | 2 +- src/lib/icons/arrow-up-right.svelte | 2 +- src/lib/icons/arrow-up.svelte | 2 +- src/lib/icons/arrows-vertical.svelte | 2 +- src/lib/icons/asleep.svelte | 2 +- src/lib/icons/bullhorn.svelte | 2 +- src/lib/icons/camera.svelte | 2 +- src/lib/icons/caret-down.svelte | 2 +- src/lib/icons/chat-bot.svelte | 2 +- src/lib/icons/chat-launch.svelte | 2 +- src/lib/icons/checkmark-filled.svelte | 2 +- src/lib/icons/checkmark.svelte | 2 +- src/lib/icons/chevron-down.svelte | 2 +- src/lib/icons/chevron-left.svelte | 2 +- src/lib/icons/chevron-right.svelte | 2 +- src/lib/icons/chevron-up.svelte | 2 +- src/lib/icons/close.svelte | 2 +- src/lib/icons/copy-link.svelte | 2 +- src/lib/icons/copy.svelte | 2 +- src/lib/icons/data-view-alt.svelte | 2 +- src/lib/icons/document-signed.svelte | 2 +- src/lib/icons/edit.svelte | 2 +- src/lib/icons/events.svelte | 2 +- src/lib/icons/launch.svelte | 2 +- src/lib/icons/light.svelte | 2 +- src/lib/icons/login.svelte | 2 +- src/lib/icons/logout.svelte | 2 +- src/lib/icons/paint-palette.svelte | 2 +- src/lib/icons/pending.svelte | 2 +- src/lib/icons/qr-code.svelte | 2 +- src/lib/icons/receipt.svelte | 2 +- src/lib/icons/renew.svelte | 2 +- src/lib/icons/settings-adjust.svelte | 2 +- src/lib/icons/settings-view.svelte | 2 +- src/lib/icons/settings.svelte | 2 +- src/lib/icons/show-data-cards.svelte | 2 +- src/lib/icons/trash-can.svelte | 2 +- src/lib/icons/user-follow.svelte | 2 +- src/lib/icons/user.svelte | 2 +- src/lib/icons/wallet.svelte | 2 +- src/lib/icons/warning-alt-filled.svelte | 2 +- 50 files changed, 103 insertions(+), 93 deletions(-) diff --git a/.eslintignore b/.eslintignore index 3897265..33affff 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,7 @@ .DS_Store node_modules /build +/dist /.svelte-kit /package .env diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 500021e..2fa6fac 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,23 +1,31 @@ +/** @type { import("eslint").Linter.Config } */ module.exports = { root: true, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:svelte/recommended', + 'prettier', + ], parser: '@typescript-eslint/parser', - extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], - plugins: ['svelte3', '@typescript-eslint'], - ignorePatterns: ['*.cjs'], - overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], - settings: { - 'svelte3/typescript': () => require('typescript'), - }, + plugins: ['@typescript-eslint'], parserOptions: { sourceType: 'module', ecmaVersion: 2020, + extraFileExtensions: ['.svelte'], }, env: { browser: true, es2017: true, node: true, }, - globals: { - svelte: true, - }, + overrides: [ + { + files: ['*.svelte'], + parser: 'svelte-eslint-parser', + parserOptions: { + parser: '@typescript-eslint/parser', + }, + }, + ], } diff --git a/src/lib/components/data-display/badge.svelte b/src/lib/components/data-display/badge.svelte index 9e67ed9..99a4dad 100644 --- a/src/lib/components/data-display/badge.svelte +++ b/src/lib/components/data-display/badge.svelte @@ -2,9 +2,6 @@ import type { HTMLAttributes } from 'svelte/elements' type Variant = 'primary' | 'secondary' | 'overlay' - let className: string | undefined | null = undefined - export { className as class } - export let variant: Variant = 'primary' interface Props extends HTMLAttributes { variant?: Variant @@ -12,6 +9,10 @@ } type $$Props = Props + + export let variant: $$Props['variant'] = 'primary' + let className: $$Props['class'] = undefined + export { className as class } diff --git a/src/lib/components/data-display/typography.svelte b/src/lib/components/data-display/typography.svelte index 0509cfa..9955547 100644 --- a/src/lib/components/data-display/typography.svelte +++ b/src/lib/components/data-display/typography.svelte @@ -16,11 +16,6 @@ | 'serif-italic' type Element = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' - let className: string | undefined | null = undefined - export { className as class } - export let variant: Variant = 'serif' - export let element: Element = 'span' - type Props = { class?: string | null variant?: Variant @@ -28,6 +23,11 @@ } type $$Props = (HTMLAttributes | HTMLAttributes) & Props + + let className: $$Props['class'] = undefined + export { className as class } + export let variant: $$Props['variant'] = 'serif' + export let element: $$Props['element'] = 'span' diff --git a/src/lib/components/inputs/button.svelte b/src/lib/components/inputs/button.svelte index 27aeba2..4bad37d 100644 --- a/src/lib/components/inputs/button.svelte +++ b/src/lib/components/inputs/button.svelte @@ -4,13 +4,31 @@ type Variant = 'primary' | 'secondary' | 'overlay' - let className: string | undefined | null = undefined + type Props = { + class?: string | null + variant?: Variant + active?: boolean + } + + interface AnchorElement extends Props, HTMLAnchorAttributes { + href?: HTMLAnchorAttributes['href'] + type?: never + } + + interface ButtonElement extends Props, HTMLButtonAttributes { + type?: HTMLButtonAttributes['type'] + href?: never + } + + type $$Props = AnchorElement | ButtonElement + + let className: $$Props['class'] = undefined export { className as class } - export let href: HTMLAnchorAttributes['href'] = undefined - export let type: HTMLButtonAttributes['type'] = undefined - export let role: HTMLButtonAttributes['role'] = undefined - export let variant: Variant = 'secondary' - export let active: boolean = false + export let href: $$Props['href'] = undefined + export let type: $$Props['type'] = undefined + export let role: $$Props['role'] = undefined + export let variant: $$Props['variant'] = 'secondary' + export let active: $$Props['active'] = false let buttonElement: HTMLButtonElement | HTMLAnchorElement let singleSVG = false @@ -33,24 +51,6 @@ singleSVG = true } }) - - type Props = { - class?: string | null - variant?: Variant - active?: boolean - } - - interface AnchorElement extends Props, HTMLAnchorAttributes { - href?: HTMLAnchorAttributes['href'] - type?: never - } - - interface ButtonElement extends Props, HTMLButtonAttributes { - type?: HTMLButtonAttributes['type'] - href?: never - } - - type $$Props = AnchorElement | ButtonElement import type { HTMLInputAttributes } from 'svelte/elements' - export let value = '' - export let placeholder: string | undefined | null = undefined - export let autofocus: boolean | undefined | null = false - export let disabled: boolean | undefined | null = false - export let label: string | undefined | null = undefined - export let unit: string | undefined | null = undefined - interface Props extends HTMLInputAttributes { disabled?: boolean | null label?: string | null @@ -16,6 +9,13 @@ } type $$Props = Props + + export let value = '' + export let placeholder: $$Props['placeholder'] = undefined + export let autofocus: $$Props['autofocus'] = false + export let disabled: $$Props['disabled'] = false + export let label: $$Props['label'] = undefined + export let unit: $$Props['unit'] = undefined