Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling the "unnecessary await" linter warning #1177

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: removed unnecessary await and keeping Code Climate happy
  • Loading branch information
jaybuidl committed Aug 22, 2023
commit c6c7fcf27ee0d2ac140f35133aa41f9510bdbfbe
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useAllCasesQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const allCasesQuery = graphql(`
export const useAllCasesQuery = () => {
return useQuery({
queryKey: [`allCasesQuery`],
queryFn: async () => await graphqlQueryFnHelper(allCasesQuery, {}),
queryFn: async () => graphqlQueryFnHelper(allCasesQuery, {}),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useAppealCost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useAppealCost = (disputeID?: string) => {
staleTime: Infinity,
queryFn: async () => {
if (!klerosCore || typeof disputeID === "undefined") return;
return await klerosCore.read.appealCost([BigInt(disputeID)]);
return klerosCore.read.appealCost([BigInt(disputeID)]);
},
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useCasesQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export const useCasesQuery = (skip: number) => {
return useQuery({
queryKey: [`useCasesQuery${skip}`],
enabled: isEnabled,
queryFn: async () => await graphqlQueryFnHelper(casesQuery, { skip: skip }),
queryFn: async () => graphqlQueryFnHelper(casesQuery, { skip: skip }),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useClassicAppealQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export const useClassicAppealQuery = (id?: string | number) => {
return useQuery({
queryKey: ["refetchOnBlock", `classicAppealQuery${id}`],
enabled: isEnabled,
queryFn: async () => await graphqlQueryFnHelper(classicAppealQuery, { disputeID: id?.toString() }),
queryFn: async () => graphqlQueryFnHelper(classicAppealQuery, { disputeID: id?.toString() }),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useCourtDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export const useCourtDetails = (id?: string) => {
return useQuery({
queryKey: ["refetchOnBlock", `courtDetails${id}`],
enabled: isEnabled,
queryFn: async () => await graphqlQueryFnHelper(courtDetailsQuery, { id }),
queryFn: async () => graphqlQueryFnHelper(courtDetailsQuery, { id }),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useCourtPolicyURI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export const useCourtPolicyURI = (id?: string | number) => {
enabled: isEnabled,
staleTime: Infinity,
queryFn: async () =>
isEnabled ? await graphqlQueryFnHelper(courtPolicyURIQuery, { courtID: id.toString() }) : undefined,
isEnabled ? graphqlQueryFnHelper(courtPolicyURIQuery, { courtID: id.toString() }) : undefined,
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useCourtTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ const courtTreeQuery = graphql(`
export const useCourtTree = () => {
return useQuery({
queryKey: ["courtTreeQuery"],
queryFn: async () => await graphqlQueryFnHelper(courtTreeQuery, {}),
queryFn: async () => graphqlQueryFnHelper(courtTreeQuery, {}),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useDisputeDetailsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ export const useDisputeDetailsQuery = (id?: string | number) => {
return useQuery({
queryKey: ["refetchOnBlock", `disputeDetailsQuery${id}`],
enabled: isEnabled,
queryFn: async () => await graphqlQueryFnHelper(disputeDetailsQuery, { disputeID: id?.toString() }),
queryFn: async () => graphqlQueryFnHelper(disputeDetailsQuery, { disputeID: id?.toString() }),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useDrawQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const useDrawQuery = (address?: string | null, disputeID?: string, roundI
return useQuery({
queryKey: [`drawQuery${[address, disputeID, roundID]}`],
enabled: isEnabled,
queryFn: async () => await graphqlQueryFnHelper(drawQuery, { address, disputeID, roundID }),
queryFn: async () => graphqlQueryFnHelper(drawQuery, { address, disputeID, roundID }),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useEvidences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export const useEvidences = (evidenceGroup?: string) => {
return useQuery({
queryKey: ["refetchOnBlock", `evidencesQuery${evidenceGroup}`],
enabled: isEnabled,
queryFn: async () => await graphqlQueryFnHelper(evidencesQuery, { evidenceGroupID: evidenceGroup?.toString() }),
queryFn: async () => graphqlQueryFnHelper(evidencesQuery, { evidenceGroupID: evidenceGroup?.toString() }),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useHomePageQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export const useHomePageQuery = (timeframe: number) => {
return useQuery({
queryKey: [`homePageQuery${timeframe}`],
enabled: isEnabled,
queryFn: async () => await graphqlQueryFnHelper(homePageQuery, { timeframe: timeframe.toString() }),
queryFn: async () => graphqlQueryFnHelper(homePageQuery, { timeframe: timeframe.toString() }),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ export const useUserQuery = (address?: string) => {
return useQuery<UserQuery>({
queryKey: [`userQuery${address}`],
enabled: isEnabled,
queryFn: async () => await graphqlQueryFnHelper(userQuery, { address }),
queryFn: async () => graphqlQueryFnHelper(userQuery, { address }),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/queries/useVotingHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export const useVotingHistory = (disputeID?: string) => {
return useQuery<VotingHistoryQuery>({
queryKey: ["refetchOnBlock", `VotingHistory${disputeID}`],
enabled: isEnabled,
queryFn: async () => await graphqlQueryFnHelper(votingHistoryQuery, { disputeID }),
queryFn: async () => graphqlQueryFnHelper(votingHistoryQuery, { disputeID }),
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/useIPFSQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useIPFSQuery = (ipfsPath?: string) => {
queryFn: async () => {
if (isEnabled) {
const formatedIPFSPath = ipfsPath.startsWith("/") ? ipfsPath : "/" + ipfsPath;
return fetch(`${IPFS_GATEWAY}${formatedIPFSPath}`).then(async (res) => await res.json());
return fetch(`${IPFS_GATEWAY}${formatedIPFSPath}`).then(async (res) => res.json());
}
return undefined;
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Cases/CaseDetails/Appeal/Classic/Fund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const Fund: React.FC<IFund> = ({ amount, setAmount, setIsOpen }) => {
onClick={() => {
if (fundAppeal) {
setIsSending(true);
wrapWithToast(async () => await fundAppeal().then((response) => response.hash), publicClient)
wrapWithToast(async () => fundAppeal().then((response) => response.hash), publicClient)
.then(() => {
setIsOpen(true);
})
Expand Down
10 changes: 4 additions & 6 deletions web/src/pages/Cases/CaseDetails/Evidence/SubmitEvidenceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ const SubmitEvidenceModal: React.FC<{
functionName: "submitEvidence",
args: [BigInt(evidenceGroup), cid],
});
await wrapWithToast(async () => await walletClient.writeContract(request), publicClient).then(
() => {
setMessage("");
close();
}
);
await wrapWithToast(async () => walletClient.writeContract(request), publicClient).then(() => {
setMessage("");
close();
});
}
})
.catch()
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Cases/CaseDetails/Voting/Classic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const Classic: React.FC<IClassic> = ({ arbitrable, voteIDs, setIsOpen }) => {
],
});
if (walletClient) {
wrapWithToast(async () => await walletClient.writeContract(request), publicClient)
wrapWithToast(async () => walletClient.writeContract(request), publicClient)
.then(() => {
setIsOpen(true);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
const handleAllowance = () => {
if (!isUndefined(increaseAllowance)) {
setIsSending(true);
wrapWithToast(async () => await increaseAllowance().then((response) => response.hash), publicClient).finally(
() => {
setIsSending(false);
}
);
wrapWithToast(async () => increaseAllowance().then((response) => response.hash), publicClient).finally(() => {
setIsSending(false);
});
}
};

Expand All @@ -100,7 +98,7 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
const handleStake = () => {
if (typeof setStake !== "undefined") {
setIsSending(true);
wrapWithToast(async () => await setStake().then((response) => response.hash), publicClient)
wrapWithToast(async () => setStake().then((response) => response.hash), publicClient)
.then(() => setIsPopupOpen(true))
.finally(() => {
setIsSending(false);
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Courts/CourtDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const CourtDetails: React.FC = () => {
functionName: "request",
});
if (walletClient) {
wrapWithToast(async () => await walletClient.writeContract(request), publicClient).finally(() => {
wrapWithToast(async () => walletClient.writeContract(request), publicClient).finally(() => {
setIsSending(false);
});
}
Expand Down Expand Up @@ -99,7 +99,7 @@ const StyledCard = styled(Card)`
`;

const StyledBreadcrumb = styled(Breadcrumb)`
margin: 16px 0 12px 0;
margin: 0px 0 12px 0;
`;

export default CourtDetails;
Expand Down
Loading