diff --git a/.eslintrc.json b/.eslintrc.json index 3069218..b192418 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -38,6 +38,11 @@ "allowedNames": [], "allowHigherOrderFunctions": true, "allowTypedFunctionExpressions": true + }], + "@typescript-eslint/consistent-type-definitions": ["error", "interface"], + "@typescript-eslint/member-delimiter-style": ["error", { + "multiline": {"delimiter": "semi", "requireLast": true}, + "singleline": {"delimiter": "semi", "requireLast": false} }] }, "extends": [ diff --git a/.vscode/settings.json b/.vscode/settings.json index 7561189..c89e1c9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,6 +16,8 @@ "keepalive", "mixins", "motd", + "multiline", + "singleline", "tsdoc" ], } \ No newline at end of file diff --git a/src/app/App.tsx b/src/app/App.tsx index d87434c..f4f1a99 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -13,8 +13,8 @@ kristService().connect(packageJson.defaultSyncNode) // TODO .catch(console.error); -type AppState = { - walletManager: WalletManager +interface AppState { + walletManager: WalletManager; } export class App extends Component { diff --git a/src/krist/KristConnectionService.ts b/src/krist/KristConnectionService.ts index 3f66adc..a796a48 100644 --- a/src/krist/KristConnectionService.ts +++ b/src/krist/KristConnectionService.ts @@ -18,7 +18,7 @@ /** Silly typing for an object containing a promise's resolve and reject * functions. */ -type PromiseResponseHandler = { +interface PromiseResponseHandler { resolve: (value?: T | PromiseLike) => void; // eslint-disable-next-line @typescript-eslint/no-explicit-any reject: (reason?: any) => void; diff --git a/src/krist/types/KristApiTypes.ts b/src/krist/types/KristApiTypes.ts index dbdcf57..44bd589 100644 --- a/src/krist/types/KristApiTypes.ts +++ b/src/krist/types/KristApiTypes.ts @@ -1,5 +1,5 @@ -export type KristApiWsResponse = { - ok?: boolean, - url?: string, - expires?: number +export interface KristApiWsResponse { + ok?: boolean; + url?: string; + expires?: number; }; diff --git a/src/layouts/credits/index.tsx b/src/layouts/credits/index.tsx index eb62234..eb06694 100644 --- a/src/layouts/credits/index.tsx +++ b/src/layouts/credits/index.tsx @@ -7,19 +7,20 @@ import packageJson from "@/package.json"; -type Supporter = { - name: string, - url?: string +interface Supporter { + name: string; + url?: string; }; -type CreditsData = { - isLoaded: boolean, - supporters: Supporter[] | null +interface CreditsState { + isLoaded: boolean; + supporters: Supporter[] | null; }; -export class Credits extends Component { +export class Credits extends Component { constructor(props: unknown) { super(props); + this.state = { isLoaded: false, supporters: null @@ -82,12 +83,13 @@ } } -export class Supporters extends Component<{supporters: Supporter[]}> { - render(): ReactNode { - return this.props.supporters.map(supporter => - (supporter.url - ? {supporter.name} - : {supporter.name} - )); - } +interface SupportersProps { + supporters: Supporter[]; } + +export const Supporters: React.FC = ({ supporters }: SupportersProps) => + (<>{supporters.map(({ url, name }) => ( + url + ? {name} + : {name} + ))}); diff --git a/src/layouts/dialogs/HelpWalletStorageDialog.tsx b/src/layouts/dialogs/HelpWalletStorageDialog.tsx index baa2d20..efc259e 100644 --- a/src/layouts/dialogs/HelpWalletStorageDialog.tsx +++ b/src/layouts/dialogs/HelpWalletStorageDialog.tsx @@ -26,7 +26,7 @@ ); }; -type Props = { +interface Props { show: boolean; handleClose: () => void; } diff --git a/src/layouts/dialogs/ModalDialog.tsx b/src/layouts/dialogs/ModalDialog.tsx index cc71347..fa0596a 100644 --- a/src/layouts/dialogs/ModalDialog.tsx +++ b/src/layouts/dialogs/ModalDialog.tsx @@ -5,7 +5,7 @@ import { noop } from "@utils"; -type Props = { +interface Props { show: boolean; title: string; diff --git a/src/layouts/dialogs/utils/CloseButton.tsx b/src/layouts/dialogs/utils/CloseButton.tsx index 38b4a2f..4d1dbae 100644 --- a/src/layouts/dialogs/utils/CloseButton.tsx +++ b/src/layouts/dialogs/utils/CloseButton.tsx @@ -2,7 +2,7 @@ import Button from "react-bootstrap/Button"; -type Props = { +interface Props { handleClose: () => void; alignRight?: boolean; } diff --git a/src/layouts/main/components/nav/index.tsx b/src/layouts/main/components/nav/index.tsx index 90bb8ac..c2e2715 100644 --- a/src/layouts/main/components/nav/index.tsx +++ b/src/layouts/main/components/nav/index.tsx @@ -11,13 +11,17 @@ import "./index.scss"; -export const MainNav = (): JSX.Element => ( +interface Props { + isGuest: boolean; +} + +export const MainNav: React.FC = ({ isGuest }: Props): JSX.Element => ( - {/* Main nav buttons */} - } diff --git a/src/layouts/main/components/sidebar/SidebarItem.tsx b/src/layouts/main/components/sidebar/SidebarItem.tsx index d5562ef..79c8134 100644 --- a/src/layouts/main/components/sidebar/SidebarItem.tsx +++ b/src/layouts/main/components/sidebar/SidebarItem.tsx @@ -5,10 +5,10 @@ import Nav from "react-bootstrap/Nav"; import { LinkContainer } from "react-router-bootstrap"; -type Props = { - url: string, - text: string, - icon: string +interface Props { + url: string; + text: string; + icon: string; }; export const SidebarItem: React.FC = ({ url, text, icon }: Props) => ( diff --git a/src/layouts/main/components/sidebar/TotalBalance.tsx b/src/layouts/main/components/sidebar/TotalBalance.tsx index 5600c9c..7d152a8 100644 --- a/src/layouts/main/components/sidebar/TotalBalance.tsx +++ b/src/layouts/main/components/sidebar/TotalBalance.tsx @@ -3,8 +3,8 @@ import "./TotalBalance.scss"; -type Props = { - balance: number +interface Props { + balance: number; }; export const TotalBalance: React.FC = ({ balance }: Props) => ( diff --git a/src/layouts/main/index.tsx b/src/layouts/main/index.tsx index d77cb6f..4a4fb93 100644 --- a/src/layouts/main/index.tsx +++ b/src/layouts/main/index.tsx @@ -21,7 +21,7 @@ export const MainLayout: React.FC = (props: Props): JSX.Element => ( - + diff --git a/src/shared-components/krist-value/index.tsx b/src/shared-components/krist-value/index.tsx index 948ec0a..a3e9699 100644 --- a/src/shared-components/krist-value/index.tsx +++ b/src/shared-components/krist-value/index.tsx @@ -2,12 +2,12 @@ import "./index.scss"; -export type KristValueProps = { - value: number, - long?: boolean +interface Props { + value: number; + long?: boolean; }; -export const KristValue = ({ value, long }: KristValueProps): JSX.Element => ( +export const KristValue = ({ value, long }: Props): JSX.Element => ( {value.toLocaleString()} diff --git a/src/utils/serviceWorker.ts b/src/utils/serviceWorker.ts index 49eedf4..576f571 100644 --- a/src/utils/serviceWorker.ts +++ b/src/utils/serviceWorker.ts @@ -20,7 +20,7 @@ ) ); -type Config = { +interface Config { onSuccess?: (registration: ServiceWorkerRegistration) => void; onUpdate?: (registration: ServiceWorkerRegistration) => void; };