fix all the lint warnings

This commit is contained in:
2023-09-04 15:17:32 -06:00
parent a5e0c847b1
commit 4b9cbd0e9f
10 changed files with 91 additions and 39 deletions

View File

@@ -65,6 +65,29 @@ export interface GiveVerifiableCredential {
recipient?: { identifier: string };
}
export interface PlanVerifiableCredential {
"@context": "https://schema.org";
"@type": "PlanAction";
name: string;
description: string;
identifier?: string;
location?: {
geo: { "@type": "GeoCoordinates"; latitude: number; longitude: number };
};
}
export interface PlanServerRecord {
agentDid?: string; // optional, if the issuer wants someone else to manage as well
description: string;
endTime?: string;
issuerDid: string;
handleId: string;
locLat?: number;
locLon?: number;
startTime?: string;
url?: string;
}
export interface RegisterVerifiableCredential {
"@context": string;
"@type": string;
@@ -112,7 +135,11 @@ export function didInfo(
}
}
export interface SuccessResult {
export interface ResultWithType {
type: string;
}
export interface SuccessResult extends ResultWithType {
type: "success";
response: AxiosResponse<ClaimResult>;
}
@@ -242,7 +269,7 @@ export async function createAndSubmitGive(
type: "error",
error: {
error: errorMessage,
userMessage: "Failed to create and submit the claim",
userMessage: "Failed to create and submit the claim.",
},
};
}

View File

@@ -201,6 +201,7 @@ const router = createRouter({
});
const errorHandler = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any,
to: RouteLocationNormalized,
from: RouteLocationNormalized,

View File

@@ -414,6 +414,7 @@ export default class AccountViewView extends Vue {
});
this.checkLimitsFor(identity);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
if (
err.message ===
@@ -517,6 +518,7 @@ export default class AccountViewView extends Vue {
if (resp.status === 200) {
this.limits = resp.data;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if (
error.message ===

View File

@@ -172,6 +172,7 @@ export default class ContactsView extends Vue {
if (this.activeDid && this.contact) {
this.loadGives(this.activeDid, this.contact);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
this.$notify(
{

View File

@@ -154,6 +154,7 @@ export default class HomeView extends Vue {
this.apiServer = settings?.apiServer || "";
this.activeDid = settings?.activeDid || "";
this.allContacts = await db.contacts.toArray();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
this.$notify(
{
@@ -261,16 +262,20 @@ export default class HomeView extends Vue {
-1,
);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.log("Error with give caught:", error);
const message =
error.userMessage ||
error.response?.data?.error?.message ||
"There was an error recording the Give.";
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
this.getGiveErrorMessage(error) ||
"There was an error recording the give.",
text: message,
},
-1,
);
@@ -286,9 +291,5 @@ export default class HomeView extends Vue {
getGiveCreationErrorMessage(result: CreateAndSubmitGiveResult) {
return (result as ErrorResult).error?.userMessage;
}
getGiveErrorMessage(error: any) {
return error.userMessage || error.response?.data?.error?.message;
}
}
</script>

View File

@@ -337,6 +337,7 @@ export default class DiscoverView extends Vue {
} else {
throw JSON.stringify(results);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.log("Error with feed load:", e);
this.$notify(
@@ -415,6 +416,7 @@ export default class DiscoverView extends Vue {
} else {
throw JSON.stringify(results);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.log("Error with feed load:", e);
this.$notify(

View File

@@ -284,6 +284,7 @@ export default class HomeView extends Vue {
this.allContacts = await db.contacts.toArray();
this.feedLastViewedId = settings?.lastViewedClaimId;
this.updateAllFeed();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
this.$notify(
{
@@ -384,12 +385,11 @@ export default class HomeView extends Vue {
}
giveDescription(giveRecord: GiveServerRecord) {
let claim = giveRecord.fullClaim;
if ((claim as any).claim) {
// can happen for some claims wrapped in a Verifiable Credential
claim = (claim as any).claim;
}
// claim.claim happen for some claims wrapped in a Verifiable Credential
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const claim = (giveRecord.fullClaim as any).claim || giveRecord.fullClaim;
// agent.did is for legacy data, before March 2023
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const giverDid = claim.agent?.identifier || (claim.agent as any)?.did;
const giverInfo = didInfo(
giverDid,
@@ -402,6 +402,7 @@ export default class HomeView extends Vue {
: claim.description || "something unknown";
// recipient.did is for legacy data, before March 2023
const gaveRecipientId =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
claim.recipient?.identifier || (claim.recipient as any)?.did;
const gaveRecipientInfo = gaveRecipientId
? " to " +
@@ -515,16 +516,19 @@ export default class HomeView extends Vue {
-1,
);
}
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.log("Error with give caught:", error);
const message =
error.userMessage ||
error.response?.data?.error?.message ||
"There was an error recording the give.";
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
this.getGiveErrorMessage(error) ||
"There was an error recording the give.",
text: message,
},
-1,
);
@@ -533,16 +537,14 @@ export default class HomeView extends Vue {
// Helper functions for readability
// eslint-disable-next-line @typescript-eslint/no-explicit-any
isGiveCreationError(result: any) {
return result.status !== 201 || result.data?.error;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getGiveCreationErrorMessage(result: any) {
return result.data?.error?.message;
}
getGiveErrorMessage(error: any) {
return error.userMessage || error.response?.data?.error?.message;
}
}
</script>

View File

@@ -112,6 +112,7 @@ import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import { accessToken, SimpleSigner } from "@/libs/crypto";
import { useAppStore } from "@/store/app";
import { IIdentifier } from "@veramo/core";
import { PlanVerifiableCredential } from "@/libs/endorserServer";
interface Notification {
group: string;
@@ -217,7 +218,7 @@ export default class NewEditProjectView extends Vue {
private async SaveProject(identity: IIdentifier) {
// Make a claim
const vcClaim: any = {
const vcClaim: PlanVerifiableCredential = {
"@context": "https://schema.org",
"@type": "PlanAction",
name: this.projectName,

View File

@@ -220,6 +220,7 @@ import {
GiverInputInfo,
GiverOutputInfo,
GiveServerRecord,
ResultWithType,
} from "@/libs/endorserServer";
import QuickNav from "@/components/QuickNav.vue";
import EntityIcon from "@/components/EntityIcon.vue";
@@ -547,22 +548,26 @@ export default class ProjectViewView extends Vue {
},
-1,
);
} else if (result.type == "error") {
console.log("Error with give result:", result);
if ("data" in result) {
const data: any = result.data;
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
data?.error?.message ||
"There was an error recording the give.",
},
-1,
} else {
console.log("Error with give creation:", result);
if (result.type != "error") {
console.log(
"... and it has an unexpected result type of",
(result as ResultWithType).type,
);
}
const message =
result?.error?.userMessage ||
"There was an error recording the Give.";
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: message,
},
-1,
);
}
}
}

View File

@@ -129,16 +129,26 @@ export default class ProjectsView extends Vue {
}
} else {
console.log("Bad server response & data:", resp.status, resp.data);
throw Error("Failed to get projects from the server.");
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: "Failed to get projects from the server. Try again later.",
},
-1,
);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.error("Got error loading projects:", error.message);
const additional = error.message ? " " + error.message : "";
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: "Got an error loading projects: " + error.message,
text: "Got an error loading projects." + additional,
},
-1,
);