Skip to content

Commit

Permalink
Enable lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-white committed Aug 28, 2023
1 parent d1f4c2b commit 4a04080
Show file tree
Hide file tree
Showing 66 changed files with 85 additions and 112 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ module.exports = {
// this should be just temporary.
env: {browser: true, es2020: true},
extends: [
// 'eslint:recommended',
// 'plugin:@typescript-eslint/recommended',
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {ecmaVersion: "latest", sourceType: "module"},
// plugins: ['react-refresh'],
rules: {
// 'react-refresh/only-export-components': 'warn',
// TODO: Remove these exceptions once we have better guards
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off'
},
};
2 changes: 1 addition & 1 deletion src/api/hooks/useGetANS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function useGetNameFromAddress(
shouldCache = false,
isValidator = false,
) {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const queryResult = useQuery<string | null, ResponseError>({
queryKey: ["ANSName", address, shouldCache, state.network_name],
queryFn: () => {
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ResponseError} from "../client";
import {useGlobalState} from "../../global-config/GlobalConfig";

export function useGetAccount(address: string) {
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

const result = useQuery<Types.AccountData, ResponseError>(
["account", {address}, state.network_value],
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetAccountModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function useGetAccountModule(
address: string,
moduleName: string,
): UseQueryResult<Types.MoveModuleBytecode, ResponseError> {
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

return useQuery<Types.MoveModuleBytecode, ResponseError>(
["accountModule", {address, moduleName}, state.network_value],
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetAccountModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {useGlobalState} from "../../global-config/GlobalConfig";
export function useGetAccountModules(
address: string,
): UseQueryResult<Types.MoveModuleBytecode[], ResponseError> {
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

return useQuery<Array<Types.MoveModuleBytecode>, ResponseError>(
["accountModules", {address}, state.network_value],
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetAccountResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function useGetAccountResource(
address: string,
resource: string,
): UseQueryResult<Types.MoveResource, ResponseError> {
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

return useQuery<Types.MoveResource, ResponseError>(
["accountResource", {address, resource}, state.network_value],
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetAccountResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {useGlobalState} from "../../global-config/GlobalConfig";
export function useGetAccountResources(
address: string,
): UseQueryResult<Types.MoveResource[], ResponseError> {
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

return useQuery<Array<Types.MoveResource>, ResponseError>(
["accountResources", {address}, state.network_value],
Expand Down
5 changes: 0 additions & 5 deletions src/api/hooks/useGetAccountTokens.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import {
Current_Token_Datas,
Current_Token_Datas_V2,
Current_Token_Ownerships_V2,
} from "aptos";
import {useGlobalState} from "../../global-config/GlobalConfig";
import {useQuery} from "@tanstack/react-query";
import {normalizeAddress} from "../../utils";
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetAccountTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function useGetAccountTransactions(
start?: number,
limit?: number,
): UseQueryResult<Array<Types.Transaction>, ResponseError> {
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

const accountTransactionsResult = useQuery<
Array<Types.Transaction>,
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetAnalyticsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export type DailyUserTxnData = {
};

export function useGetAnalyticsData() {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [data, setData] = useState<AnalyticsData>();

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/api/hooks/useGetBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function useGetBlockByHeight({
height: number;
withTransactions?: boolean;
}) {
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

const result = useQuery<Types.Block, ResponseError>(
["block", height, state.network_value],
Expand All @@ -28,7 +28,7 @@ export function useGetBlockByVersion({
version: number;
withTransactions?: boolean;
}) {
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

const result = useQuery<Types.Block, ResponseError>(
["block", version, state.network_value],
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetCoinSupplyLimit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function fetchTotalSupply(
}

export function useGetCoinSupplyLimit(): number | null {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [totalSupply, setTotalSupply] = useState<number | null>(null);
const {data: coinInfo} = useGetAccountResource(
"0x1",
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetDelegationNodeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type DelegationNodeInfoProps = {
export function useGetDelegationNodeInfo({
validatorAddress,
}: DelegationNodeInfoProps): DelegationNodeInfoResponse {
const [{aptos_client: client}, _] = useGlobalState();
const [{aptos_client: client}] = useGlobalState();
const {totalVotingPower} = useGetValidatorSet();

const {
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetDelegatorStakeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function useGetDelegatorStakeInfo(
delegatorAddress: Types.Address,
validatorAddress: Types.Address,
) {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [stakes, setStakes] = useState<Types.MoveValue[]>([]);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetEpochTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface BlockResourceData {
}

export function useGetEpochTime() {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [curEpoch, setCurEpoch] = useState<string>();
const [lastEpochTime, setLastEpochTime] = useState<string>();
const [epochInterval, setEpochInterval] = useState<string>();
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetInDevMode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useGlobalState} from "../../global-config/GlobalConfig";

export function useGetInDevMode(): boolean {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
return state.feature_name && state.feature_name === "dev";
}
2 changes: 1 addition & 1 deletion src/api/hooks/useGetInMainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import {useGlobalState} from "../../global-config/GlobalConfig";

// TODO: replace existing mainnet checks across the code base with this hook
export function useGetInMainnet(): boolean {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
return state.network_name === "mainnet";
}
2 changes: 1 addition & 1 deletion src/api/hooks/useGetMostRecentBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {getLedgerInfo, getRecentBlocks} from "..";
import {Types} from "aptos";

export function useGetMostRecentBlocks(count: number) {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [isLoading, setIsLoading] = useState<boolean>(true);
const [recentBlocks, setRecentBlocks] = useState<Types.Block[]>([]);

Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetSearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const NotFoundResult: SearchResult = {

export default function useGetSearchResults(input: string) {
const [results, setResults] = useState<SearchResult[]>([]);
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

const searchText = input.trim();

Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetStakingRewardsRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ConfigurationData {
}

function useGetStakingConfig() {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [rewardsRatePerEpoch, setRewardsRatePerEpoch] = useState<string>();
const [rewardsRateDenominator, setRewardsRateDenominator] =
useState<string>();
Expand Down
4 changes: 2 additions & 2 deletions src/api/hooks/useGetTPS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {useGetTPSByBlockHeight} from "./useGetTPSByBlockHeight";
import {AnalyticsData, ANALYTICS_DATA_URL} from "./useGetAnalyticsData";

export function useGetTPS() {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [blockHeight, setBlockHeight] = useState<number | undefined>();
const {tps} = useGetTPSByBlockHeight(blockHeight);

Expand All @@ -27,7 +27,7 @@ export function useGetTPS() {
}

export function useGetPeakTPS() {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [peakTps, setPeakTps] = useState<number>();

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ResponseError} from "../../api/client";
import {useGlobalState} from "../../global-config/GlobalConfig";

export function useGetTransaction(txnHashOrVersion: string) {
const [state, _setState] = useGlobalState();
const [state] = useGlobalState();

const result = useQuery<Types.Transaction, ResponseError>(
["transaction", {txnHashOrVersion}, state.network_value],
Expand Down
2 changes: 1 addition & 1 deletion src/api/hooks/useGetValidatorSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface Validator {
}

export function useGetValidatorSet() {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [totalVotingPower, setTotalVotingPower] = useState<string | null>(null);
const [numberOfActiveValidators, setNumberOfActiveValidators] = useState<
number | null
Expand Down
13 changes: 5 additions & 8 deletions src/api/hooks/useGetValidators.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useGlobalState} from "../../global-config/GlobalConfig";
import {useEffect, useState} from "react";
import {useGetValidatorSet} from "./useGetValidatorSet";
import {Network, NetworkName} from "../../constants";
import {Network} from "../../constants";
import {standardizeAddress} from "../../utils";

const MAINNET_VALIDATORS_DATA_URL =
Expand Down Expand Up @@ -36,8 +36,8 @@ export interface GeoData {
epoch: number;
}

function useGetValidatorsRawData(network: NetworkName) {
const [state, _] = useGlobalState();
function useGetValidatorsRawData() {
const [state] = useGlobalState();
const [validatorsRawData, setValidatorsRawData] = useState<ValidatorData[]>(
[],
);
Expand Down Expand Up @@ -85,12 +85,9 @@ function useGetValidatorsRawData(network: NetworkName) {
return {validatorsRawData};
}

export function useGetValidators(network?: NetworkName) {
const [state] = useGlobalState();
export function useGetValidators() {
const {activeValidators} = useGetValidatorSet();
const {validatorsRawData} = useGetValidatorsRawData(
network ?? state.network_name,
);
const {validatorsRawData} = useGetValidatorsRawData();

const [validators, setValidators] = useState<ValidatorData[]>([]);

Expand Down
4 changes: 2 additions & 2 deletions src/api/hooks/useGoogleTagManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TagManager from "react-gtm-module";
import TagManager, {DataLayerArgs} from "react-gtm-module";

type GTMParams = {
events: object;
Expand All @@ -12,6 +12,6 @@ export const initGTM = ({events}: GTMParams) => {
TagManager.initialize(tagManagerArgs);
};

export const sendToGTM = (dataLayer: Object): void => {
export const sendToGTM = (dataLayer: DataLayerArgs): void => {
TagManager.dataLayer(dataLayer);
};
4 changes: 2 additions & 2 deletions src/api/hooks/useGraphqlClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function getGraphqlClient(
}

export function useGetGraphqlClient() {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [graphqlClient, setGraphqlClient] = useState<
ApolloClient<NormalizedCacheObject>
>(getGraphqlClient(state.network_name));
Expand All @@ -65,7 +65,7 @@ export function GraphqlClientProvider({children}: GraphqlClientProviderProps) {
}

export function useGetIsGraphqlClientSupported(): boolean {
const [state, _] = useGlobalState();
const [state] = useGlobalState();
const [isGraphqlClientSupported, setIsGraphqlClientSupported] =
useState<boolean>(getIsGraphqlClientSupportedFor(state.network_name));

Expand Down
5 changes: 3 additions & 2 deletions src/api/hooks/useSubmitTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,17 @@ const useSubmitTransaction = () => {
}
// transaction failed
return {...responseOnError, message: response.message};
} catch (error: any) {
} catch (error) {
if (error instanceof FailedTransactionError) {
return {
transactionSubmitted: true,
transactionHash: response ? response.hash : "",
message: error.message,
success: false,
};
} else if (error instanceof Error) {
return {...responseOnError, message: error.message};
}
responseOnError.message = error;
}
return responseOnError;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function CurrencyValue({
fixedDecimalPlaces,
currencyCode,
}: CurrencyValueProps) {
let number = getFormattedBalanceStr(amount, decimals, fixedDecimalPlaces);
const number = getFormattedBalanceStr(amount, decimals, fixedDecimalPlaces);
if (currencyCode) {
return (
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function TimestampValue({timestamp}: TimestampValueProps) {
const moment = parseTimestamp(timestamp);
const timestamp_display = timestampDisplay(moment);

const copyTimestamp = async (event: React.MouseEvent<HTMLButtonElement>) => {
const copyTimestamp = async () => {
await navigator.clipboard.writeText(timestamp);

setTooltipOpen(true);
Expand Down
2 changes: 1 addition & 1 deletion src/components/IndividualPageContent/JsonCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function JsonCard({
}
};

const copyCard = async (event: React.MouseEvent<HTMLButtonElement>) => {
const copyCard = async () => {
await navigator.clipboard.writeText(jsonData);

setTooltipOpen(true);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/TableTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function TableTooltip({children, title}: TableTooltipProps) {
<Modal open={open} onClose={handleClose}>
<Box
sx={{
position: "absolute" as "absolute",
position: "absolute" as const,
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
Expand Down
2 changes: 1 addition & 1 deletion src/components/TitleHashButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function HashButton({hash}: {hash: string}) {

const [tooltipOpen, setTooltipOpen] = useState<boolean>(false);

const copyAddress = async (_event: React.MouseEvent<HTMLButtonElement>) => {
const copyAddress = async () => {
await navigator.clipboard.writeText(hash);

setTooltipOpen(true);
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Account/Components/AccountAllTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
useGetAccountAllTransactionVersions,
} from "../../../api/hooks/useGetAccountAllTransactions";
import EmptyTabContent from "../../../components/IndividualPageContent/EmptyTabContent";
import {Statsig} from "statsig-react";
import {useLogEventWithBasic} from "../hooks/useLogEventWithBasic";

function RenderPagination({
Expand Down Expand Up @@ -62,7 +61,7 @@ export function AccountAllTransactionsWithPagination({
numPages,
countPerPage,
}: AccountAllTransactionsWithPaginationProps) {
const [searchParams, _setSearchParams] = useSearchParams();
const [searchParams] = useSearchParams();
const currentPage = parseInt(searchParams.get("page") ?? "1");
const offset = (currentPage - 1) * countPerPage;

Expand Down
Loading

0 comments on commit 4a04080

Please sign in to comment.