From 2465add0dbfb5371ca1847a28d7278c38c6493e1 Mon Sep 17 00:00:00 2001 From: Chidozie DAVID <100468311+Dozie2001@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:12:54 +0100 Subject: [PATCH] feat: iome setup and formatting (#243) Co-authored-by: Rosco Kalis --- .github/workflows/{prettier.yml => biome.yml} | 9 +- .gitignore | 2 + .husky/commit-msg | 1 + .prettierignore | 3 - .prettierrc | 5 - .vscode/settings.json | 10 + app/ThemeScript.tsx | 1 + app/[locale]/[...rest]/page.tsx | 2 +- .../address/[addressOrName]/layout.tsx | 2 +- app/[locale]/blog/[...slug]/layout.tsx | 4 +- app/[locale]/blog/[...slug]/page.tsx | 2 +- app/[locale]/blog/layout.tsx | 2 +- app/[locale]/blog/page.tsx | 2 +- app/[locale]/disclaimer/page.tsx | 2 +- .../exploits/[slug]/ExploitChecker.tsx | 4 +- app/[locale]/exploits/[slug]/page.tsx | 2 +- app/[locale]/exploits/page.tsx | 2 +- app/[locale]/layout.tsx | 2 +- app/[locale]/learn/[...slug]/page.tsx | 2 +- app/[locale]/learn/[category]/page.tsx | 4 +- app/[locale]/learn/page.tsx | 2 +- .../add-network/[slug]/AddNetworkButton.tsx | 2 +- .../learn/wallets/add-network/[slug]/page.tsx | 2 +- .../merchandise/ClaimCodesSection.tsx | 5 +- app/[locale]/not-found.tsx | 2 +- app/[locale]/og.jpg/blog/route.tsx | 4 +- app/[locale]/og.jpg/exploits/[slug]/route.tsx | 19 +- app/[locale]/og.jpg/exploits/route.tsx | 4 +- app/[locale]/og.jpg/learn/faq/route.tsx | 4 +- app/[locale]/og.jpg/learn/route.tsx | 4 +- .../learn/wallets/add-network/route.tsx | 4 +- .../token-approval-checker/[slug]/route.tsx | 4 +- app/[locale]/page.tsx | 1 + app/[locale]/privacy-policy/page.tsx | 2 +- app/[locale]/terms/page.tsx | 2 +- .../[slug]/TokenApprovalCheckerSearchBox.tsx | 2 +- .../token-approval-checker/[slug]/page.tsx | 2 +- .../merchandise/generate-code/route.tsx | 4 +- app/layout.tsx | 2 +- app/layouts/LearnLayout.tsx | 2 +- biome.jsonc | 68 + commitlint.config.js | 16 + components/address/BalanceDisplay.tsx | 2 +- .../allowances/controls/ControlsSection.tsx | 4 +- .../allowances/controls/ControlsWrapper.tsx | 2 +- .../allowances/controls/RevokeButton.tsx | 4 +- .../allowances/controls/UpdateControls.tsx | 2 +- .../batch-revoke/BatchRevokeControls.tsx | 2 +- .../BatchRevokeModalWithButton.tsx | 7 +- .../batch-revoke/BatchRevokeTable.tsx | 4 +- .../dashboard/AllowanceDashboard.tsx | 7 +- .../dashboard/NoAllowancesFound.tsx | 2 +- .../dashboard/cells/AllowanceCell.tsx | 4 +- .../allowances/dashboard/cells/AssetCell.tsx | 7 +- .../dashboard/cells/ControlsCell.tsx | 2 +- .../dashboard/cells/GlobalSelectCell.tsx | 4 +- .../dashboard/cells/LastUpdatedCell.tsx | 2 +- .../allowances/dashboard/cells/SelectCell.tsx | 4 +- .../dashboard/cells/SpenderCell.tsx | 4 +- .../allowances/dashboard/cells/StatusCell.tsx | 2 +- .../dashboard/cells/ValueAtRiskCell.tsx | 2 +- components/allowances/dashboard/columns.tsx | 16 +- .../dashboard/controls/AllowanceSearchBox.tsx | 8 +- .../controls/AllowanceTableControls.tsx | 4 +- .../dashboard/controls/FilterSelect.tsx | 8 +- .../dashboard/controls/SortSelect.tsx | 10 +- .../wallet-health/AllowanceCount.tsx | 4 +- .../wallet-health/RiskFactorDisplay.tsx | 4 +- .../dashboard/wallet-health/RiskTooltip.tsx | 6 +- .../wallet-health/TotalValueAtRisk.tsx | 4 +- .../dashboard/wallet-health/WalletHealth.tsx | 2 +- .../wallet-health/WalletHealthDescription.tsx | 2 +- .../wallet-health/WalletHealthScore.tsx | 16 +- .../wallet-health/WalletHealthSection.tsx | 2 +- components/common/AddressSearchBox.tsx | 4 +- components/common/Button.tsx | 5 +- components/common/Card.tsx | 2 +- components/common/ChainDescription.tsx | 4 +- components/common/Checkbox.tsx | 14 +- components/common/Chevron.tsx | 2 +- components/common/DisabledOverlay.tsx | 2 +- components/common/DropdownMenu.tsx | 2 +- components/common/Error.tsx | 2 +- components/common/FocusTrap.tsx | 2 +- components/common/Href.tsx | 2 +- components/common/ImageWithFallback.tsx | 2 +- components/common/Input.tsx | 2 +- components/common/Label.tsx | 2 +- components/common/Loader.tsx | 2 +- components/common/MarkdownProse.tsx | 12 +- components/common/Modal.tsx | 2 +- components/common/ModalWithButton.tsx | 2 +- components/common/NoSSR.tsx | 6 - components/common/NotFoundLink.tsx | 2 +- components/common/PageNavigation.tsx | 2 +- components/common/PlaceholderIcon.tsx | 2 +- components/common/Prose.tsx | 2 +- components/common/SearchBox.tsx | 2 +- components/common/Spinner.tsx | 6 +- components/common/TableBodyLoader.tsx | 9 +- components/common/ToastifyConfig.tsx | 1 + components/common/donate/DonateButton.tsx | 2 +- components/common/donate/TipSection.tsx | 2 +- components/common/icons/Check.tsx | 8 +- components/common/icons/Minus.tsx | 2 +- components/common/og/OgHeaderText.tsx | 2 +- components/common/select/ChainSelect.tsx | 2 +- components/common/select/SearchableSelect.tsx | 29 +- components/common/select/Select.tsx | 4 +- components/common/table/Table.tsx | 4 +- components/common/table/TableBody.tsx | 2 +- components/common/table/TableFooter.tsx | 2 +- components/common/table/TableHeader.tsx | 2 +- components/exploits/AddressForm.tsx | 2 +- components/exploits/ExploitCard.tsx | 8 +- components/exploits/ExploitChecker.tsx | 2 +- components/exploits/ExploitStatus.tsx | 2 +- components/exploits/ReportExploitButton.tsx | 2 +- components/faq/FaqItem.tsx | 2 +- components/footer/Footer.tsx | 6 +- components/footer/LanguageSelect.tsx | 4 +- components/header/ConnectButton.tsx | 2 +- components/header/MobileMenu.tsx | 1 + .../landing/FullWidthLandingSection.tsx | 2 +- components/landing/LandingPageFaqItem.tsx | 2 +- components/landing/LandingParagraph.tsx | 2 +- components/landing/LandingSection.tsx | 2 +- components/learn/ArticleCard.tsx | 2 +- components/learn/ArticleCardSection.tsx | 2 +- components/learn/ArticleMeta.tsx | 2 +- components/learn/Sidebar.tsx | 2 +- components/learn/SidebarEntry.tsx | 6 +- components/signatures/cells/CancelCell.tsx | 4 +- .../cells/CancelMarketplaceCell.tsx | 2 +- .../signatures/cells/CancelPermitCell.tsx | 4 +- .../signatures/cells/MarketplaceCell.tsx | 2 +- .../marketplace/MarketplaceTable.tsx | 6 +- components/signatures/marketplace/columns.tsx | 4 +- components/signatures/permit/PermitsTable.tsx | 6 +- components/signatures/permit/columns.tsx | 8 +- cypress/e2e/chains.cy.ts | 7 +- cypress/e2e/exploits.cy.ts | 3 +- lib/api/auth.ts | 8 +- lib/api/logs/EtherscanEventGetter.ts | 2 +- lib/chains/Chain.ts | 16 +- lib/databases/blocks.ts | 6 +- lib/databases/events.ts | 8 +- lib/databases/merch-codes.ts | 2 +- lib/hooks/QueryProvider.tsx | 2 +- lib/hooks/ethereum/EthereumProvider.tsx | 16 +- lib/hooks/ethereum/events/useEvents.tsx | 6 +- .../ethereum/events/usePermit2Events.tsx | 4 +- lib/hooks/ethereum/useAllowances.tsx | 10 +- lib/hooks/ethereum/useDonate.tsx | 4 +- lib/hooks/ethereum/useHandleTransaction.tsx | 2 +- lib/hooks/ethereum/useLogs.tsx | 4 +- lib/hooks/ethereum/useLogsFullBlockRange.tsx | 2 +- lib/hooks/ethereum/useMarketplaces.tsx | 8 +- lib/hooks/ethereum/useNameLookup.tsx | 2 +- lib/hooks/ethereum/useOpenSeaProxyAddress.tsx | 2 +- lib/hooks/ethereum/usePermitTokens.tsx | 8 +- lib/hooks/ethereum/useRevoke.tsx | 8 +- lib/hooks/ethereum/useRevokeBatch.tsx | 17 +- lib/hooks/page-context/AddressPageContext.tsx | 7 +- lib/hooks/useColorTheme.tsx | 2 +- lib/i18n/NextIntlClientProvider.tsx | 4 +- lib/i18n/NextIntlClientProviderChild.tsx | 2 +- lib/i18n/config.tsx | 2 +- lib/i18n/csr-navigation.tsx | 8 +- lib/interfaces.ts | 6 +- lib/ky.ts | 2 +- lib/price/AbstractPriceStrategy.ts | 6 +- lib/price/AggregatePriceStrategy.ts | 6 +- lib/price/BackendPriceStrategy.ts | 6 +- lib/price/HardcodedPriceStrategy.ts | 6 +- lib/price/ReservoirNftPriceStrategy.ts | 2 +- lib/price/UniswapV2PriceStrategy.ts | 8 +- lib/price/UniswapV3PriceStrategy.ts | 8 +- lib/price/UniswapV3ReadonlyPriceStrategy.ts | 14 +- lib/price/utils.ts | 4 +- lib/providers.ts | 4 +- lib/stores/transaction-store.ts | 6 +- lib/utils/allowances.ts | 54 +- lib/utils/chains.ts | 8 +- lib/utils/events.ts | 2 +- lib/utils/exploits.ts | 6 +- lib/utils/formatting.ts | 6 +- lib/utils/index.ts | 20 +- lib/utils/markdown-content.ts | 4 +- lib/utils/og.tsx | 10 +- lib/utils/permit.ts | 6 +- lib/utils/permit2.ts | 8 +- lib/utils/risk.tsx | 2 +- lib/utils/table.ts | 4 +- lib/utils/tokens.ts | 13 +- lib/utils/wallet.ts | 6 +- lib/utils/whois.ts | 4 +- .../spender/AggregateSpenderDataSource.ts | 6 +- lib/whois/spender/BackendSpenderDataSource.ts | 6 +- lib/whois/spender/SpenderDataSource.ts | 4 +- .../label/HardcodedSpenderDataSource.ts | 6 +- .../spender/label/HarpieSpenderDataSource.ts | 6 +- .../spender/label/WhoisSpenderDataSource.ts | 6 +- .../risk/HarpieSpenderRiskDataSource.ts | 6 +- .../risk/OnchainSpenderRiskDataSource.ts | 6 +- .../spender/risk/ScamSnifferRiskDataSource.ts | 6 +- .../risk/WebacySpenderRiskDataSource.ts | 6 +- package.json | 14 +- pages/api/[chainId]/floorPrice.ts | 4 +- pages/api/[chainId]/spender/[address].ts | 4 +- pages/api/login.ts | 2 +- scripts/find-likely-exploit-addresses.ts | 2 +- scripts/generate-chainid-lookup.ts | 4 +- scripts/move-cover-images.ts | 2 +- scripts/test-covalent-rate-limits.ts | 35 - scripts/update-exploits.ts | 8 +- test/chains.test.ts | 1 + yarn.lock | 4601 ++++++++--------- 218 files changed, 2777 insertions(+), 2981 deletions(-) rename .github/workflows/{prettier.yml => biome.yml} (75%) create mode 100644 .husky/commit-msg delete mode 100644 .prettierignore delete mode 100644 .prettierrc create mode 100644 .vscode/settings.json create mode 100644 biome.jsonc create mode 100644 commitlint.config.js delete mode 100644 components/common/NoSSR.tsx delete mode 100644 scripts/test-covalent-rate-limits.ts diff --git a/.github/workflows/prettier.yml b/.github/workflows/biome.yml similarity index 75% rename from .github/workflows/prettier.yml rename to .github/workflows/biome.yml index 7527c2305..38e2ea489 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/biome.yml @@ -1,12 +1,11 @@ -name: Prettier Linter check - +name: Biome Format and linter check on: push: pull_request: branches: [master] jobs: - prettier: + biome: runs-on: ubuntu-latest steps: - name: Checkout code @@ -20,5 +19,5 @@ jobs: - name: Install dependencies run: yarn install - - name: Run Prettier - run: yarn prettier --check . + - name: Run Biome + run: yarn lint diff --git a/.gitignore b/.gitignore index 95da2eb34..53b8c62f9 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,5 @@ certificates scripts/chainid-lookup.csv scripts/ledger-live-manifest.json + +!.vscode/settings.json diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 000000000..0a4b97de5 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1 @@ +npx --no -- commitlint --edit $1 diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 65ce02df0..000000000 --- a/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -.next -.yarn -public/assets diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 3342efe7f..000000000 --- a/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "singleQuote": true, - "printWidth": 120, - "plugins": ["prettier-plugin-organize-imports"] -} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..a2e91c34c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "i18n-ally.localesPaths": ["locales", "lib/i18n"], + "i18n-ally.namespace": true, + "i18n-ally.keystyle": "nested", + "biome.enabled": true, + "[typescript][javascript][typescriptreact][javascriptreact][html][css][json][jsonc]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "editor.formatOnSave": true +} diff --git a/app/ThemeScript.tsx b/app/ThemeScript.tsx index 2f022f988..e7691aa80 100644 --- a/app/ThemeScript.tsx +++ b/app/ThemeScript.tsx @@ -10,6 +10,7 @@ const ThemeScript = () => { })() `; + // biome-ignore lint/security/noDangerouslySetInnerHtml: the theme script only works with dangerouslySetInnerHTML return