Skip to content

Commit aec8a9a

Browse files
author
devofficer
committed
fix: eslint to check .ts .tsx files
1 parent 3556e75 commit aec8a9a

File tree

8 files changed

+47
-40
lines changed

8 files changed

+47
-40
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"build": "yarn build:theme && react-scripts --max_old_space_size=4096 build",
99
"build:theme": "lessc --js ./src/bootstrap/theme.less ./src/bootstrap/theme.css",
1010
"release": "standard-version",
11-
"lint": "eslint \"./src/**/*.js\"",
12-
"lint:eslint:fix": "eslint \"./src/**/*.js\" --fix",
13-
"lint:prettier:fix": "prettier --write \"./src/**/*.js\"",
11+
"lint": "eslint \"./src/**/*.js\" \"./src/**/*.ts\" \"./src/**/*.tsx\"",
12+
"lint:eslint:fix": "eslint \"./src/**/*.js\" \"./src/**/*.ts\" \"./src/**/*.tsx\" --fix",
13+
"lint:prettier:fix": "prettier --write \"./src/**/*.js\" \"./src/**/*.ts\" \"./src/**/*.tsx\"",
1414
"format": "yarn run lint:eslint:fix && yarn run lint:prettier:fix"
1515
},
1616
"dependencies": {

src/bootstrap/app-router.tsx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import React, { useEffect, useMemo } from 'react'
2-
import {
3-
Route,
4-
Switch,
5-
Redirect
6-
} from 'react-router-dom'
2+
import { Route, Switch, Redirect } from 'react-router-dom'
73
import { ApolloProvider } from '@apollo/client'
84
import { useWeb3Context, Connectors } from 'web3-react'
95
import getNetworkEnv from 'utils/network-env'
10-
116
import loadable from '@loadable/component'
127
import ErrorPage from 'pages/error-page'
138
import NoWeb3Detected from 'pages/no-web3'
@@ -19,7 +14,7 @@ import usePathValidation from 'hooks/use-path-validation'
1914
import useGraphQLClient from 'hooks/use-graphql-client'
2015
import { Web3ContextCurate } from 'types/web3-cotext'
2116

22-
const { Connector } = Connectors;
17+
const { Connector } = Connectors
2318

2419
const ItemsRouter = loadable(
2520
() => import(/* webpackPrefetch: true */ 'pages/items-router'),
@@ -41,30 +36,38 @@ const ClassicFactory = loadable(
4136
{ fallback: <Loading /> }
4237
)
4338

44-
4539
const AppRouter = () => {
46-
const { networkId, error }: Web3ContextCurate = useWeb3Context();
47-
const isUnsupported = useMemo(() => error?.code === Connector.errorCodes.UNSUPPORTED_NETWORK, [error])
48-
const tcrAddress = getNetworkEnv('REACT_APP_DEFAULT_TCR_ADDRESSES', networkId as number);
40+
const { networkId, error }: Web3ContextCurate = useWeb3Context()
41+
const isUnsupported = useMemo(
42+
() => error?.code === Connector.errorCodes.UNSUPPORTED_NETWORK,
43+
[error]
44+
)
45+
const tcrAddress = getNetworkEnv(
46+
'REACT_APP_DEFAULT_TCR_ADDRESSES',
47+
networkId as number
48+
)
4949
const [pathResolved, invalidTcrAddr] = usePathValidation()
5050
const client = useGraphQLClient(networkId)
5151

5252
useEffect(() => {
5353
if (isUnsupported && window.ethereum) {
54-
const chainIdTokens = window.location.pathname.match(/\/tcr\/(\d+)\//);
55-
const chainId = hexlify(chainIdTokens && chainIdTokens?.length > 1 ? chainIdTokens[1] : DEFAULT_NETWORK);
54+
const chainIdTokens = window.location.pathname.match(/\/tcr\/(\d+)\//)
55+
const chainId = hexlify(
56+
chainIdTokens && chainIdTokens?.length > 1
57+
? chainIdTokens[1]
58+
: DEFAULT_NETWORK
59+
)
5660

5761
window.ethereum.request({
5862
method: 'wallet_switchEthereumChain',
5963
params: [{ chainId }]
60-
});
64+
})
6165
}
62-
}, [isUnsupported]);
66+
}, [isUnsupported])
6367

64-
if (Object.entries(connectors).length === 0)
65-
return <NoWeb3Detected />
68+
if (Object.entries(connectors).length === 0) return <NoWeb3Detected />
6669

67-
if (isUnsupported && error) {
70+
if (isUnsupported && error)
6871
return (
6972
<ErrorPage
7073
code={' '}
@@ -78,16 +81,16 @@ const AppRouter = () => {
7881
}
7982
/>
8083
)
81-
} else if (!networkId || !pathResolved) {
82-
return <Loading />
83-
} else if (invalidTcrAddr || !client) {
84-
return <ErrorPage />
85-
}
84+
else if (!networkId || !pathResolved) return <Loading />
85+
else if (invalidTcrAddr || !client) return <ErrorPage />
8686

8787
return (
8888
<ApolloProvider client={client}>
8989
<Switch>
90-
<Route path="/tcr/:chainId/:tcrAddress/:itemID" component={ItemDetailsRouter} />
90+
<Route
91+
path="/tcr/:chainId/:tcrAddress/:itemID"
92+
component={ItemDetailsRouter}
93+
/>
9194
<Route path="/tcr/:chainId/:tcrAddress" component={ItemsRouter} />
9295
<Route path="/factory" exact component={Factory} />
9396
<Route path="/factory-classic" exact component={ClassicFactory} />
@@ -98,4 +101,4 @@ const AppRouter = () => {
98101
)
99102
}
100103

101-
export default AppRouter;
104+
export default AppRouter

src/hooks/use-check-light-curate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from "react"
1+
import { useEffect, useState } from 'react'
22
import { useWeb3Context } from 'web3-react'
33
import { ethers } from 'ethers'
44
import { useParams } from 'react-router'

src/hooks/use-path-validation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ const usePathValidation = () => {
2626
const DEFAULT_TCR_ADDRESSES = JSON.parse(
2727
process.env.REACT_APP_DEFAULT_TCR_ADDRESSES as string
2828
)
29-
const ADDRs = Object.values(DEFAULT_TCR_ADDRESSES).map((addr) =>
29+
const ADDRs = Object.values(DEFAULT_TCR_ADDRESSES).map(addr =>
3030
(addr as string).toLowerCase()
3131
)
3232
const CHAIN_IDS = Object.keys(DEFAULT_TCR_ADDRESSES)
3333
const tcrIndex = ADDRs.findIndex(addr => addr === tcrAddress)
3434

3535
if (tcrIndex >= 0) chainId = Number(CHAIN_IDS[tcrIndex])
3636
else {
37-
const SUBGRAPH_URLS = JSON.parse(process.env.REACT_APP_SUBGRAPH_URL as string)
37+
const SUBGRAPH_URLS = JSON.parse(
38+
process.env.REACT_APP_SUBGRAPH_URL as string
39+
)
3840
const queryResults = await Promise.all(
3941
Object.values(SUBGRAPH_URLS).map(subgraph => {
4042
const client = new ApolloClient({

src/pages/item-details-router.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ const ItemDetails = loadable(
2323
)
2424

2525
const ItemDetailsRouter = () => {
26-
const { tcrAddress, itemID } = useParams<{ tcrAddress: string, itemID: string }>()
26+
const { tcrAddress, itemID } = useParams<{
27+
tcrAddress: string
28+
itemID: string
29+
}>()
2730
const { networkStatus } = useTcrNetwork()
2831
const search = window.location.search
2932
const isLightCurate = useCheckLightCurate()

src/types/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ interface Window {
33
}
44

55
type Empty = null | undefined
6-

src/types/web3-cotext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Web3Context } from "web3-react/dist/context";
1+
import { Web3Context } from 'web3-react/dist/context'
22

33
export interface ErrorWithCode extends Error {
4-
code?: string | number | undefined;
4+
code?: string | number | undefined
55
}
66

77
export interface Web3ContextCurate extends Web3Context {

src/utils/rich-address.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* `/tx/`${txHash}`
66
*/
77

8-
export type Reference = {
8+
export type Reference = {
99
id: string
1010
namespaceId: string
1111
name: string
@@ -58,9 +58,9 @@ export const references: Reference[] = [
5858

5959
// Generate a map for fast and clean access
6060

61-
let namespacesMap: { [namespaceId: string]: Namespace } = {}
61+
const namespacesMap: { [namespaceId: string]: Namespace } = {}
6262

63-
let referencesMap: {
63+
const referencesMap: {
6464
[namespaceId: string]: { [referenceId: string]: Reference }
6565
} = {}
6666

@@ -85,7 +85,7 @@ export type RichAddress = {
8585
export const parseRichAddress = (crude: string): RichAddress | null => {
8686
if (!crude) return null
8787
// if no 2 colons, it's badly formatted
88-
if (crude.split(":").length !== 3) return null
88+
if (crude.split(':').length !== 3) return null
8989

9090
const [namespaceId, referenceId, address] = crude.split(':')
9191
// namespace not found
@@ -102,4 +102,4 @@ export const parseRichAddress = (crude: string): RichAddress | null => {
102102
export default {
103103
namespacesMap,
104104
referencesMap
105-
}
105+
}

0 commit comments

Comments
 (0)