From 11af60a50e8ed801e0cc6677562fd845f797fb7e Mon Sep 17 00:00:00 2001 From: J M Rossy Date: Mon, 25 Nov 2024 16:10:46 -0500 Subject: [PATCH] chore: More cleanup and stricter lint rules (#337) --- eslint.config.mjs | 9 +++++-- src/components/icons/Identicon.tsx | 41 ------------------------------ src/components/icons/types.ts | 6 ----- src/consts/app.ts | 4 +-- src/features/chains/utils.ts | 8 ------ 5 files changed, 9 insertions(+), 59 deletions(-) delete mode 100644 src/components/icons/Identicon.tsx delete mode 100644 src/components/icons/types.ts diff --git a/eslint.config.mjs b/eslint.config.mjs index 7d570005..54c8e85f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -56,12 +56,18 @@ export default [ }, rules: { + 'camelcase': ['error'], + 'guard-for-in': ['error'], + 'import/no-cycle': ['error'], + 'import/no-self-import': ['error'], 'no-console': ['warn'], 'no-eval': ['error'], 'no-ex-assign': ['error'], 'no-extra-boolean-cast': ['error'], 'no-constant-condition': ['off'], - 'guard-for-in': ['error'], + 'no-multiple-empty-lines': ['error'], + 'jsx-a11y/alt-text': ['off'], + '@typescript-eslint/ban-ts-comment': ['off'], '@typescript-eslint/explicit-module-boundary-types': ['off'], '@typescript-eslint/no-explicit-any': ['off'], @@ -77,7 +83,6 @@ export default [ }, ], - 'jsx-a11y/alt-text': ['off'], '@next/next/no-img-element': ['off'], }, }, diff --git a/src/components/icons/Identicon.tsx b/src/components/icons/Identicon.tsx deleted file mode 100644 index 344b7f3c..00000000 --- a/src/components/icons/Identicon.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { isValidAddressEvm, normalizeAddressEvm } from '@hyperlane-xyz/utils'; -import { Circle } from '@hyperlane-xyz/widgets'; -import jazzicon from '@metamask/jazzicon'; -import { memo } from 'react'; - -type Props = { - address?: string; - size?: number; -}; - -// This should match metamask: https://github.com/MetaMask/metamask-extension/blob/master/ui/helpers/utils/icon-factory.js#L84 -function addressToSeed(address: string) { - const addrStub = normalizeAddressEvm(address).slice(2, 10); - return parseInt(addrStub, 16); -} - -// TODO move to widgets lib -function _Identicon({ address, size: _size }: Props) { - const size = _size ?? 34; - - // TODO better handling of non-evm addresses here - if (!address || !isValidAddressEvm(address)) { - return ; - } - - const jazziconResult = jazzicon(size, addressToSeed(address)); - - return ( -
{ - if (nodeElement) { - nodeElement.innerHTML = ''; - nodeElement.appendChild(jazziconResult); - } - }} - >
- ); -} - -export const Identicon = memo(_Identicon); diff --git a/src/components/icons/types.ts b/src/components/icons/types.ts deleted file mode 100644 index 71146814..00000000 --- a/src/components/icons/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { SVGProps } from 'react'; - -// TODO: Replace with DefaultIconProps in widgets lib -export type IconProps = SVGProps & { - color?: string; -}; diff --git a/src/consts/app.ts b/src/consts/app.ts index 8f7b5a56..2f235bdc 100644 --- a/src/consts/app.ts +++ b/src/consts/app.ts @@ -1,7 +1,7 @@ -import { Space_Grotesk } from 'next/font/google'; +import { Space_Grotesk as SpaceGrotesk } from 'next/font/google'; import { Color } from '../styles/Color'; -export const MAIN_FONT = Space_Grotesk({ +export const MAIN_FONT = SpaceGrotesk({ subsets: ['latin'], variable: '--font-main', preload: true, diff --git a/src/features/chains/utils.ts b/src/features/chains/utils.ts index d67f7d0a..be11c771 100644 --- a/src/features/chains/utils.ts +++ b/src/features/chains/utils.ts @@ -25,14 +25,6 @@ export function hasPermissionlessChain(multiProvider: MultiProtocolProvider, ids return !ids.every((c) => !isPermissionlessChain(multiProvider, c)); } -export function getChainByRpcUrl(multiProvider: MultiProtocolProvider, url?: string) { - if (!url) return undefined; - const allMetadata = Object.values(multiProvider.metadata); - return allMetadata.find( - (m) => !!m.rpcUrls.find((rpc) => rpc.http.toLowerCase().includes(url.toLowerCase())), - ); -} - /** * Returns an object that contains the amount of * routes from a single chain to every other chain