Skip to content

Commit

Permalink
Hardening and fix furo compilation
Browse files Browse the repository at this point in the history
- Fixed numerous type errors across the board
- Added pre-commit hook which will run type checking on commit
- Removed dojo for now
- Hoisted config for it's own workspace
- Fixed inconsistency with prettier config on apps vs pkgs
  • Loading branch information
matthewlilley committed Dec 30, 2022
1 parent 1bdb629 commit 927545b
Show file tree
Hide file tree
Showing 291 changed files with 14,669 additions and 14,636 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"furo",
"internal",
"partner",
"dojo",
"swap",
"swap13",
"xswap",
"node-16-example",
"node-18-esm-example",
"farm-api",
"@sushiswap/tokens-api",
"@sushiswap/tines-api",
Expand Down
4 changes: 1 addition & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ soljson-v0.8.11+commit.d7f03943.js
storybook-static

# Playwright
playwright-report

.eslintrc.js
playwright-report
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
root: true,
extends: ['@sushiswap/eslint-config'],
}
extends: ["@sushiswap/eslint-config"],
};
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ artifacts
**/public/workbox-*.js.map
**/public/worker-*.js.map

# prisma
# prisma

# screenshots
Expand All @@ -83,4 +82,8 @@ playwright-report
.sentryclirc

test-results/
results/
results/

# typescript
*.tsbuildinfo
next-env.d.ts
1 change: 1 addition & 0 deletions apps/_root/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@sushiswap/prettier-config").default;
8 changes: 4 additions & 4 deletions apps/_root/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"framer-motion": "^7.6.5",
"graphql-request": "^5.0.0",
"nanoid": "^4.0.0",
"next": "13.0.7",
"next-seo": "^5.5.0",
"next-sitemap": "^3.1.16",
"next": "13.1.1",
"next-seo": "5.15.0",
"next-sitemap": "3.1.43",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.1",
Expand All @@ -47,7 +47,7 @@
"next-transpile-modules": "10.0.0",
"postcss": "^8.4.0",
"tailwindcss": "3.2.4",
"typescript": "4.8.2",
"typescript": "4.9.4",
"unimported": "^1.23.0"
}
}
2 changes: 1 addition & 1 deletion apps/_root/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@sushiswap/typescript-config/nextjs.json",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"],
"compilerOptions": {
"baseUrl": "."
Expand Down
1 change: 0 additions & 1 deletion apps/_root/tsconfig.tsbuildinfo

This file was deleted.

1 change: 1 addition & 0 deletions apps/academy/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@sushiswap/prettier-config").default;
8 changes: 4 additions & 4 deletions apps/academy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"classnames": "^2.3.1",
"date-fns": "^2.28.0",
"graphql": "16.6.0",
"next": "13.0.7",
"next-seo": "^5.5.0",
"next-sitemap": "^3.1.16",
"next": "13.1.1",
"next-seo": "5.15.0",
"next-sitemap": "3.1.43",
"qs": "^6.10.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -49,6 +49,6 @@
"postcss": "^8.4.0",
"sharp": "0.31.3",
"tailwindcss": "3.2.4",
"typescript": "4.8.2"
"typescript": "4.9.4"
}
}
2 changes: 1 addition & 1 deletion apps/academy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@sushiswap/typescript-config/nextjs.json",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"],
"compilerOptions": {
"baseUrl": "."
Expand Down
1 change: 0 additions & 1 deletion apps/academy/tsconfig.tsbuildinfo

This file was deleted.

1 change: 1 addition & 0 deletions apps/analytics/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@sushiswap/prettier-config").default;
8 changes: 4 additions & 4 deletions apps/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"fast-json-stable-stringify": "^2.1.0",
"graphql": "16.6.0",
"isomorphic-fetch": "^3.0.0",
"next": "13.0.7",
"next": "13.1.1",
"next-pwa": "^5.6.0",
"next-seo": "^5.5.0",
"next-sitemap": "^3.1.20",
"next-seo": "5.15.0",
"next-sitemap": "3.1.43",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.1",
Expand All @@ -55,7 +55,7 @@
"postcss": "^8.4.0",
"swr": "^1.3.0",
"tailwindcss": "3.2.4",
"typescript": "4.8.2"
"typescript": "4.9.4"
},
"nextBundleAnalysis": {
"budget": 460800,
Expand Down
3 changes: 2 additions & 1 deletion apps/analytics/pages/token-sitemap.xml/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { getTokens, GetTokensQuery } from 'lib/api'
import { GetServerSideProps } from 'next'
import { getServerSideSitemap, ISitemapField } from 'next-sitemap'
import stringify from 'fast-json-stable-stringify'

export const getServerSideProps: GetServerSideProps = async (ctx) => {
const tokens = await getTokens({
pagination: JSON.stringify({ pageIndex: 0, pageSize: 1000 }),
pagination: stringify({ pageIndex: 0, pageSize: 1000 }),
} as unknown as GetTokensQuery)

const ids = tokens.map((token) => token.id)
Expand Down
2 changes: 1 addition & 1 deletion apps/analytics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@sushiswap/typescript-config/nextjs.json",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"],
"compilerOptions": {
"baseUrl": ".",
Expand Down
1 change: 0 additions & 1 deletion apps/analytics/tsconfig.tsbuildinfo

This file was deleted.

2 changes: 1 addition & 1 deletion apps/blog/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('@sushiswap/prettier-config')
module.exports = require("@sushiswap/prettier-config").default;
8 changes: 4 additions & 4 deletions apps/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"date-fns": "^2.28.0",
"fast-json-stable-stringify": "^2.1.0",
"graphql": "16.6.0",
"next": "13.0.7",
"next-seo": "^5.5.0",
"next-sitemap": "^3.1.16",
"next": "13.1.1",
"next-seo": "5.15.0",
"next-sitemap": "3.1.43",
"qs": "^6.10.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -50,7 +50,7 @@
"postcss": "^8.4.0",
"sharp": "0.31.3",
"tailwindcss": "3.2.4",
"typescript": "4.8.2"
"typescript": "4.9.4"
},
"nextBundleAnalysis": {
"budget": 460800,
Expand Down
74 changes: 41 additions & 33 deletions apps/blog/pages/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Container } from '@sushiswap/ui'
import ErrorPage from 'next/error'
import { useRouter } from 'next/router'
import { FC } from 'react'
import { Article, MediaBlock as MediaBlockType, RichTextBlock as RichTextBlockType } from 'types'
import { Container } from "@sushiswap/ui";
import ErrorPage from "next/error";
import { useRouter } from "next/router";
import { FC } from "react";
import {
Article,
MediaBlock as MediaBlockType,
RichTextBlock as RichTextBlockType,
} from "types";

import {
ArticleAuthors,
Expand All @@ -14,47 +18,47 @@ import {
MediaBlock,
PreviewBanner,
RichTextBlock,
} from '../components'
import { getAllArticlesBySlug, getArticleAndMoreArticles } from '../lib/api'
} from "../components";
import { getAllArticlesBySlug, getArticleAndMoreArticles } from "../lib/api";

export async function getStaticPaths() {
// When this is true (in preview environments) don't
// prerender any static pages
// (faster builds, but slower initial page load)
if (process.env.SKIP_BUILD_STATIC_GENERATION === 'true') {
if (process.env.SKIP_BUILD_STATIC_GENERATION === "true") {
return {
paths: [],
fallback: 'blocking',
}
fallback: "blocking",
};
}

const allArticles = await getAllArticlesBySlug()
const allArticles = await getAllArticlesBySlug();

return {
paths: allArticles.articles?.data.reduce<string[]>((acc, article) => {
if (article?.attributes?.slug) acc.push(`/${article?.attributes.slug}`)
if (article?.attributes?.slug) acc.push(`/${article?.attributes.slug}`);

// console.log(acc)
return acc
return acc;
}, []),
fallback: true,
}
};
}

export async function getStaticProps({
params,
preview = null,
}: {
params: { slug: string }
preview: Record<string, unknown> | null
params: { slug: string };
preview: Record<string, unknown> | null;
}) {
const data = await getArticleAndMoreArticles(params.slug, !!preview)
const data = await getArticleAndMoreArticles(params.slug, !!preview);

if (!data?.articles?.data?.[0]) {
return {
props: {},
notFound: true,
}
};
}

return {
Expand All @@ -64,19 +68,19 @@ export async function getStaticProps({
preview: !!preview,
},
revalidate: 60,
}
};
}

interface ArticlePage {
article?: Article
latestArticles?: Article[]
preview: boolean
article?: Article;
latestArticles?: Article[];
preview: boolean;
}

const ArticlePage: FC<ArticlePage> = ({ article, latestArticles, preview }) => {
const router = useRouter()
const router = useRouter();
if (!router.isFallback && !article?.attributes?.slug) {
return <ErrorPage statusCode={404} />
return <ErrorPage statusCode={404} />;
}

return (
Expand All @@ -92,18 +96,22 @@ const ArticlePage: FC<ArticlePage> = ({ article, latestArticles, preview }) => {
<div className="mt-12 prose !prose-invert prose-slate">
{article?.attributes?.blocks?.map((block, i) => {
// @ts-ignore
if (block?.__typename === 'ComponentSharedRichText') {
return <RichTextBlock block={block as RichTextBlockType} key={i} />
if (block?.__typename === "ComponentSharedRichText") {
return (
<RichTextBlock block={block as RichTextBlockType} key={i} />
);
}

// @ts-ignore
if (block?.__typename === 'ComponentSharedMedia') {
return <MediaBlock block={block as MediaBlockType} key={i} />
if (block?.__typename === "ComponentSharedMedia") {
return <MediaBlock block={block as MediaBlockType} key={i} />;
}

// @ts-ignore
if (block?.__typename === 'ComponentSharedDivider') {
return <hr key={i} className="my-12 border border-slate-200/5" />
if (block?.__typename === "ComponentSharedDivider") {
return (
<hr key={i} className="my-12 border border-slate-200/5" />
);
}
})}
</div>
Expand All @@ -113,7 +121,7 @@ const ArticlePage: FC<ArticlePage> = ({ article, latestArticles, preview }) => {
</main>
</Container>
</>
)
}
);
};

export default ArticlePage
export default ArticlePage;
4 changes: 1 addition & 3 deletions apps/blog/pages/article-sitemap.xml/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { getAllArticlesBySlug } from '../../lib/api'
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const { articles } = await getAllArticlesBySlug()

if (!articles?.data?.length) throw new Error('No articles found')

const slugs = articles.data.map((article) => article?.attributes?.slug)
const slugs = (articles?.data || []).map((article) => article.attributes?.slug)

const fields = slugs.map<ISitemapField>((slug) => ({
loc: `https://www.sushi.com/blog/${slug}`,
Expand Down
2 changes: 1 addition & 1 deletion apps/blog/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@sushiswap/typescript-config/nextjs.json",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"],
"compilerOptions": {
"baseUrl": "."
Expand Down
1 change: 0 additions & 1 deletion apps/blog/tsconfig.tsbuildinfo

This file was deleted.

3 changes: 2 additions & 1 deletion apps/bridge/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_INFURA_ID=
NEXT_PUBLIC_INFURA_ID=
SKIP_BUILD_STATIC_GENERATION=true
1 change: 1 addition & 0 deletions apps/bridge/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@sushiswap/prettier-config').default
4 changes: 2 additions & 2 deletions apps/bridge/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { App, AppType } from '@sushiswap/ui'
import { NetworkSelector } from '@sushiswap/wagmi'
import { Profile } from '@sushiswap/wagmi/components/Wallet/Profile'
import { SUPPORTED_CHAIN_IDS } from 'config'
import { useNotifications } from 'lib/state/storage'
import { SUPPORTED_CHAIN_IDS } from '../config'
import { useNotifications } from '../lib/state/storage'
import React from 'react'
import { useAccount } from 'wagmi'

Expand Down
2 changes: 1 addition & 1 deletion apps/bridge/components/NetworkSelectorOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CheckIcon } from '@heroicons/react/outline'
import chains, { ChainId } from '@sushiswap/chain'
import { classNames, Dialog, NetworkIcon, Typography } from '@sushiswap/ui'
import { SUPPORTED_CHAIN_IDS } from 'config'
import { SUPPORTED_CHAIN_IDS } from '../config'
import React, { FC, useCallback } from 'react'

interface NetworkSelectorOverlay {
Expand Down
5 changes: 3 additions & 2 deletions apps/bridge/lib/hooks/useBridgeFees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { stargateFeeLibraryV03Abi, stargatePoolAbi } from '@sushiswap/abi'
import { Amount, Token, Type } from '@sushiswap/currency'
import { STARGATE_CHAIN_ID, STARGATE_POOL_ADDRESS, STARGATE_POOL_ID } from '@sushiswap/stargate'
import { getSushiXSwapContractConfig } from '@sushiswap/wagmi'
import { BigNumber } from 'ethers'
import { isAddress } from 'ethers/lib/utils'

import { BigNumber } from '@ethersproject/bignumber'
import { isAddress } from '@ethersproject/address'
import { useMemo } from 'react'
import { Address, useContractRead, useContractReads } from 'wagmi'

Expand Down
Loading

0 comments on commit 927545b

Please sign in to comment.