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