Skip to content

Commit 7ab2f2d

Browse files
committed
bring ts-reset
1 parent 7220f92 commit 7ab2f2d

18 files changed

+39
-43
lines changed

configs/app/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { ChainIndicatorId } from 'ui/home/indicators/types';
66
const getEnvValue = (env: string | undefined) => env?.replaceAll('\'', '"');
77
const parseEnvJson = <DataType>(env: string | undefined): DataType | null => {
88
try {
9-
return JSON.parse(env || 'null');
9+
return JSON.parse(env || 'null') as DataType | null;
1010
} catch (error) {
1111
return null;
1212
}

lib/getFilterValueFromQuery.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export default function getFilterValue<FilterType>(filterValues: ReadonlyArray<FilterType>, val: string | Array<string> | undefined) {
2-
if (typeof val === 'string' && filterValues.includes(val as unknown as FilterType)) {
3-
return val as unknown as FilterType;
1+
export default function getFilterValue<FilterType>(filterValues: ReadonlyArray<FilterType>, val: string | Array<string> | undefined): FilterType | undefined {
2+
if (typeof val === 'string' && filterValues.includes(val as FilterType)) {
3+
return val as FilterType;
44
}
55
}

lib/hooks/useContractTabs.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22

33
import type { Address } from 'types/api/address';
44

5-
import notEmpty from 'lib/notEmpty';
65
import ContractCode from 'ui/address/contract/ContractCode';
76
import ContractRead from 'ui/address/contract/ContractRead';
87
import ContractWrite from 'ui/address/contract/ContractWrite';
@@ -33,6 +32,6 @@ export default function useContractTabs(data: Address | undefined) {
3332
data?.has_custom_methods_write ?
3433
{ id: 'write_custom_methods', title: 'Write custom', component: <ContractWrite addressHash={ data?.hash } isCustomAbi/> } :
3534
undefined,
36-
].filter(notEmpty);
35+
].filter(Boolean);
3736
}, [ data ]);
3837
}

lib/hooks/useNavItems.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import transactionsIcon from 'icons/transactions.svg';
2323
import verifiedIcon from 'icons/verified.svg';
2424
import watchlistIcon from 'icons/watchlist.svg';
2525
// import { rightLineArrow } from 'lib/html-entities';
26-
import notEmpty from 'lib/notEmpty';
2726

2827
export interface NavItem {
2928
text: string;
@@ -106,7 +105,7 @@ export default function useNavItems(): ReturnType {
106105
} : null,
107106
// FIXME: need icon for this item
108107
{ text: 'GraphQL', nextRoute: { pathname: '/graphiql' as const }, icon: topAccountsIcon, isActive: false, isNewUi: false },
109-
].filter(notEmpty);
108+
].filter(Boolean);
110109

111110
const mainNavItems = [
112111
{
@@ -125,7 +124,7 @@ export default function useNavItems(): ReturnType {
125124
// at this stage custom menu items is under development, we will implement it later
126125
otherNavItems.length > 0 ?
127126
{ text: 'Other', icon: gearIcon, isActive: otherNavItems.some(item => item.isActive), subItems: otherNavItems } : null,
128-
].filter(notEmpty) as Array<NavItem | NavGroupItem>;
127+
].filter(Boolean);
129128

130129
const accountNavItems = [
131130
{

lib/notEmpty.ts

-3
This file was deleted.

lib/socket/useSocketChannel.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { Channel } from 'phoenix';
22
import { useEffect, useRef, useState } from 'react';
33

4-
import notEmpty from 'lib/notEmpty';
5-
64
import { useSocket } from './context';
75

86
const CHANNEL_REGISTRY: Record<string, Channel> = {};
@@ -27,7 +25,7 @@ export default function useSocketChannel({ topic, params, isDisabled, onJoin, on
2725

2826
useEffect(() => {
2927
const cleanUpRefs = () => {
30-
const refs = [ onCloseRef.current, onErrorRef.current ].filter(notEmpty);
28+
const refs = [ onCloseRef.current, onErrorRef.current ].filter(Boolean);
3129
refs.length > 0 && socket?.off(refs);
3230
};
3331

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"@playwright/experimental-ct-react": "1.31.0",
7979
"@svgr/webpack": "^6.5.1",
8080
"@testing-library/react": "^13.4.0",
81+
"@total-typescript/ts-reset": "^0.3.7",
8182
"@types/d3": "^7.4.0",
8283
"@types/dom-to-image": "^2.6.4",
8384
"@types/jest": "^29.2.0",
@@ -87,8 +88,8 @@
8788
"@types/qrcode": "^1.5.0",
8889
"@types/react": "18.0.9",
8990
"@types/react-dom": "18.0.5",
90-
"@types/swagger-ui-react": "^4.11.0",
9191
"@types/react-google-recaptcha": "^2.1.5",
92+
"@types/swagger-ui-react": "^4.11.0",
9293
"@types/ws": "^8.5.3",
9394
"@typescript-eslint/eslint-plugin": "^5.27.0",
9495
"dotenv-cli": "^6.0.0",

playwright/fixtures/socketServer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const joinChannel = async(socket: WebSocket, channelName: string) => {
3535
return new Promise<[string, string, string]>((resolve, reject) => {
3636
socket.on('message', (msg) => {
3737
try {
38-
const payload: Array<string> = JSON.parse(msg.toString());
38+
const payload = JSON.parse(msg.toString()) as Array<string>;
3939

4040
if (channelName === payload[2] && payload[3] === 'phx_join') {
4141
socket.send(JSON.stringify([

reset.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@total-typescript/ts-reset';

ui/apps/AppCard.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type { AppItemPreview } from 'types/client/apps';
77
import northEastIcon from 'icons/arrows/north-east.svg';
88
import starFilledIcon from 'icons/star_filled.svg';
99
import starOutlineIcon from 'icons/star_outline.svg';
10-
import notEmpty from 'lib/notEmpty';
1110

1211
import AppCardLink from './AppCardLink';
1312
import { APP_CATEGORIES } from './constants';
@@ -30,7 +29,7 @@ const AppCard = ({
3029
isFavorite,
3130
onFavoriteClick,
3231
}: Props) => {
33-
const categoriesLabel = categories.map(c => APP_CATEGORIES[c]).filter(notEmpty).join(', ');
32+
const categoriesLabel = categories.map(c => APP_CATEGORIES[c]).filter(Boolean).join(', ');
3433

3534
const handleInfoClick = useCallback((event: MouseEvent) => {
3635
event.preventDefault();

ui/apps/AppModal.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import starFilledIcon from 'icons/star_filled.svg';
1515
import starOutlineIcon from 'icons/star_outline.svg';
1616
import useIsMobile from 'lib/hooks/useIsMobile';
1717
import { nbsp } from 'lib/html-entities';
18-
import notEmpty from 'lib/notEmpty';
1918

2019
import AppModalLink from './AppModalLink';
2120
import { APP_CATEGORIES } from './constants';
@@ -60,7 +59,7 @@ const AppModal = ({
6059
icon: ghIcon,
6160
url: github,
6261
} : null,
63-
].filter(notEmpty);
62+
].filter(Boolean);
6463

6564
const handleFavoriteClick = useCallback(() => {
6665
onFavoriteClick(id, isFavorite);

ui/apps/useMarketplaceApps.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const favoriteAppsLocalStorageKey = 'favoriteApps';
99

1010
function getFavoriteApps() {
1111
try {
12-
return JSON.parse(localStorage.getItem(favoriteAppsLocalStorageKey) || '[]');
12+
return JSON.parse(localStorage.getItem(favoriteAppsLocalStorageKey) || '[]') as Array<string>;
1313
} catch (e) {
1414
return [];
1515
}

ui/contractVerification/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const DEFAULT_VALUES = {
101101
};
102102

103103
export function isValidVerificationMethod(method?: string): method is SmartContractVerificationMethod {
104-
return method && SUPPORTED_VERIFICATION_METHODS.includes(method as SmartContractVerificationMethod) ? true : false;
104+
return method && SUPPORTED_VERIFICATION_METHODS.includes(method) ? true : false;
105105
}
106106

107107
export function sortVerificationMethods(methodA: SmartContractVerificationMethod, methodB: SmartContractVerificationMethod) {

ui/pages/Address.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import iconSuccess from 'icons/status/success.svg';
99
import useApiQuery from 'lib/api/useApiQuery';
1010
import { useAppContext } from 'lib/appContext';
1111
import useContractTabs from 'lib/hooks/useContractTabs';
12-
import notEmpty from 'lib/notEmpty';
1312
import getQueryParamString from 'lib/router/getQueryParamString';
1413
import AddressBlocksValidated from 'ui/address/AddressBlocksValidated';
1514
import AddressCoinBalance from 'ui/address/AddressCoinBalance';
@@ -57,7 +56,7 @@ const AddressPageContent = () => {
5756
...(addressQuery.data?.public_tags || []),
5857
...(addressQuery.data?.watchlist_names || []),
5958
]
60-
.filter(notEmpty)
59+
.filter(Boolean)
6160
.map((tag) => <Tag key={ tag.label }>{ tag.display_name }</Tag>);
6261

6362
const contractTabs = useContractTabs(addressQuery.data);
@@ -92,7 +91,7 @@ const AddressPageContent = () => {
9291
component: <AddressContract tabs={ contractTabs } addressHash={ hash }/>,
9392
subTabs: contractTabs.map(tab => tab.id),
9493
} : undefined,
95-
].filter(notEmpty);
94+
].filter(Boolean);
9695
}, [ addressQuery.data, contractTabs, hash ]);
9796

9897
const tagsNode = tags.length > 0 ? <Flex columnGap={ 2 }>{ tags }</Flex> : null;

ui/pages/Token.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { useAppContext } from 'lib/appContext';
1010
import useContractTabs from 'lib/hooks/useContractTabs';
1111
import useIsMobile from 'lib/hooks/useIsMobile';
1212
import useQueryWithPages from 'lib/hooks/useQueryWithPages';
13-
import notEmpty from 'lib/notEmpty';
1413
import trimTokenSymbol from 'lib/token/trimTokenSymbol';
1514
import AddressContract from 'ui/address/AddressContract';
1615
import TextAd from 'ui/shared/ad/TextAd';
@@ -118,7 +117,7 @@ const TokenPageContent = () => {
118117
component: <AddressContract tabs={ contractTabs } addressHash={ hashString }/>,
119118
subTabs: contractTabs.map(tab => tab.id),
120119
} : undefined,
121-
].filter(notEmpty);
120+
].filter(Boolean);
122121

123122
let hasPagination;
124123
let pagination;

ui/shared/ad/CoinzillaTextAd.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const CoinzillaTextAd = ({ className }: {className?: string}) => {
3131
useEffect(() => {
3232
fetch('https://request-global.czilladx.com/serve/native.php?z=19260bf627546ab7242')
3333
.then(res => res.status === 200 ? res.json() : null)
34-
.then((data) => {
34+
.then((_data) => {
35+
const data = _data as AdData;
3536
setAdData(data);
3637
if (data?.ad?.impressionUrl) {
3738
fetch(data.ad.impressionUrl);

ui/shared/logs/LogItem.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type { Log } from 'types/api/log';
66

77
// import searchIcon from 'icons/search.svg';
88
import { space } from 'lib/html-entities';
9-
import notEmpty from 'lib/notEmpty';
109
import Address from 'ui/shared/address/Address';
1110
import AddressIcon from 'ui/shared/address/AddressIcon';
1211
import AddressLink from 'ui/shared/address/AddressLink';
@@ -83,7 +82,7 @@ const LogItem = ({ address, index, topics, data, decoded, type, tx_hash: txHash
8382
) }
8483
<RowHeader>Topics</RowHeader>
8584
<GridItem>
86-
{ topics.filter(notEmpty).map((item, index) => (
85+
{ topics.filter(Boolean).map((item, index) => (
8786
<LogTopic
8887
key={ index }
8988
hex={ item }

yarn.lock

+17-12
Original file line numberDiff line numberDiff line change
@@ -3807,6 +3807,11 @@
38073807
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
38083808
integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==
38093809

3810+
"@total-typescript/ts-reset@^0.3.7":
3811+
version "0.3.7"
3812+
resolved "https://registry.yarnpkg.com/@total-typescript/ts-reset/-/ts-reset-0.3.7.tgz#66d0d9d3a9d8055b876640b7d0231809e01351b7"
3813+
integrity sha512-yXt2BRRVCJVvzWaxac5n0nCXzIrQEBE/MeYlNQ8/Iq7UeelNmm/AdnUAu18ilSS893mbEQ4u6whPt/HvOPc4rw==
3814+
38103815
"@trysound/[email protected]":
38113816
version "0.2.0"
38123817
resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad"
@@ -4289,6 +4294,13 @@
42894294
dependencies:
42904295
"@types/react" "*"
42914296

4297+
"@types/react-google-recaptcha@^2.1.5":
4298+
version "2.1.5"
4299+
resolved "https://registry.yarnpkg.com/@types/react-google-recaptcha/-/react-google-recaptcha-2.1.5.tgz#af157dc2e4bde3355f9b815a64f90e85cfa9df8b"
4300+
integrity sha512-iWTjmVttlNgp0teyh7eBXqNOQzVq2RWNiFROWjraOptRnb1OcHJehQnji0sjqIRAk9K0z8stjyhU+OLpPb0N6w==
4301+
dependencies:
4302+
"@types/react" "*"
4303+
42924304
"@types/react-redux@^7.1.20":
42934305
version "7.1.25"
42944306
resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.25.tgz#de841631205b24f9dfb4967dd4a7901e048f9a88"
@@ -4299,13 +4311,6 @@
42994311
hoist-non-react-statics "^3.3.0"
43004312
redux "^4.0.0"
43014313

4302-
"@types/react-google-recaptcha@^2.1.5":
4303-
version "2.1.5"
4304-
resolved "https://registry.yarnpkg.com/@types/react-google-recaptcha/-/react-google-recaptcha-2.1.5.tgz#af157dc2e4bde3355f9b815a64f90e85cfa9df8b"
4305-
integrity sha512-iWTjmVttlNgp0teyh7eBXqNOQzVq2RWNiFROWjraOptRnb1OcHJehQnji0sjqIRAk9K0z8stjyhU+OLpPb0N6w==
4306-
dependencies:
4307-
"@types/react" "*"
4308-
43094314
"@types/react-scroll@^1.8.4":
43104315
version "1.8.4"
43114316
resolved "https://registry.yarnpkg.com/@types/react-scroll/-/react-scroll-1.8.4.tgz#2b6258fb34104d3fcc7a22e8eceaadc669ba3ad1"
@@ -9009,6 +9014,11 @@ json5@^2.2.1:
90099014
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
90109015
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
90119016

9017+
json5@^2.2.2:
9018+
version "2.2.3"
9019+
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
9020+
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
9021+
90129022
jsonfile@^6.0.1:
90139023
version "6.1.0"
90149024
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
@@ -9018,11 +9028,6 @@ jsonfile@^6.0.1:
90189028
optionalDependencies:
90199029
graceful-fs "^4.1.6"
90209030

9021-
json5@^2.2.2:
9022-
version "2.2.3"
9023-
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
9024-
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
9025-
90269031
jsonify@^0.0.1:
90279032
version "0.0.1"
90289033
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.1.tgz#2aa3111dae3d34a0f151c63f3a45d995d9420978"

0 commit comments

Comments
 (0)