Skip to content

Commit

Permalink
fixes lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kezike committed Nov 5, 2023
1 parent b8af05d commit 7102f72
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
61 changes: 32 additions & 29 deletions app/lib/exchanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const interactExchange = async (url: string, request={}): Promise<any> => {

// Extend JSON path of credential by a literal value
const extendPath = (path: string, extension: string): string => {
const jsonPathResCharsRegex = /[$@*()\[\].:?]/g;
const jsonPathResCharsRegex = /[$@*()[\].:?]/g;
if (jsonPathResCharsRegex.test(extension)) {
// In order to escape reserved characters in a JSONPath in jsonpath-plus,
// you must prefix each occurrence thereof with a tick symbol (`)
Expand All @@ -52,7 +52,7 @@ const extendPath = (path: string, extension: string): string => {
// Check if credential record matches QueryByExample VPR
const credentialMatchesVprExampleQuery = async (vprExample: any, credentialRecord: CredentialRecordRaw, credentialRecordPath='$.credential'): Promise<boolean> => {

Check warning on line 53 in app/lib/exchanges.ts

View workflow job for this annotation

GitHub Actions / lint (16.x)

Unexpected any. Specify a different type
const credentialRecordMatches = [];
for (let [vprExampleKey, vprExampleValue] of Object.entries(vprExample)) {
for (const [vprExampleKey, vprExampleValue] of Object.entries(vprExample)) {
const newCredentialRecordPath = extendPath(credentialRecordPath, vprExampleKey);
// The result is always dumped into a single-element array
const [credentialRecordScope] = JSONPath({ path: newCredentialRecordPath, json: credentialRecord });
Expand Down Expand Up @@ -87,23 +87,24 @@ const queryCredentialRecordsByType = async (query: any): Promise<CredentialRecor
const credentialRecords = await CredentialRecord.getAllCredentialRecords();
let matchedCredentialRecords: CredentialRecordRaw[];
switch (query.type) {
case QueryType.Example:
const example = query.credentialQuery?.example;
if (!example) {
// This is an error with the exchanger, as the request is malformed
return [];
}
const credentialRecordMatches = await Promise.all(credentialRecords.map((c: CredentialRecordRaw) => credentialMatchesVprExampleQuery(example, c)));
matchedCredentialRecords = credentialRecords.filter((c: CredentialRecordRaw, i: number) => credentialRecordMatches[i]);
break;
case QueryType.Frame:
case QueryType.DidAuth:
case QueryType.DidAuthLegacy:
matchedCredentialRecords = [];
break;
default:
matchedCredentialRecords = [];
break;
case QueryType.Example: {
const example = query.credentialQuery?.example;
if (!example) {
// This is an error with the exchanger, as the request is malformed
return [];
}
const credentialRecordMatches = await Promise.all(credentialRecords.map((c: CredentialRecordRaw) => credentialMatchesVprExampleQuery(example, c)));
matchedCredentialRecords = credentialRecords.filter((c: CredentialRecordRaw, i: number) => credentialRecordMatches[i]);
break;
}
case QueryType.Frame:
case QueryType.DidAuth:
case QueryType.DidAuthLegacy:
matchedCredentialRecords = [];
break;
default:
matchedCredentialRecords = [];
break;
}
return matchedCredentialRecords;
};
Expand All @@ -113,6 +114,7 @@ const selectCredentials = async (credentialRecords: CredentialRecordRaw[]): Prom
// ensure that the selected credentials have been cleared
// before subscribing to redux store updates below
store.dispatch(clearSelectedExchangeCredentials());
// eslint-disable-next-line no-constant-condition
while (true) {
const selectedExchangeCredentials: CredentialRecordRaw[] = getHook('selectedExchangeCredentials');
if (selectedExchangeCredentials.length === 0) {
Expand Down Expand Up @@ -278,17 +280,18 @@ export const handleVcApiExchangeComplete = async ({
if (!Array.isArray(queries)) {
queries = [query];
}
for (let query of queries) {
for (const query of queries) {
switch (query.type) {
case QueryType.DidAuthLegacy:
case QueryType.DidAuth:
signed = true;
break;
default:
const filteredCredentialRecordsGroup: CredentialRecordRaw[] = await queryCredentialRecordsByType(query);
filteredCredentialRecords = filteredCredentialRecords.concat(filteredCredentialRecordsGroup);
const filteredCredentials = filteredCredentialRecords.map((r) => r.credential);
credentials = credentials.concat(filteredCredentials);
case QueryType.DidAuthLegacy:
case QueryType.DidAuth:
signed = true;
break;
default: {
const filteredCredentialRecordsGroup: CredentialRecordRaw[] = await queryCredentialRecordsByType(query);
filteredCredentialRecords = filteredCredentialRecords.concat(filteredCredentialRecordsGroup);
const filteredCredentials = filteredCredentialRecords.map((r) => r.credential);
credentials = credentials.concat(filteredCredentials);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/lib/globalModalBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export default function GlobalModalBody({
);
}

export const getGlobalModalBody = (message: string, loading?: boolean) => {
export const getGlobalModalBody = (message: string, loading?: boolean): JSX.Element => {
return <GlobalModalBody message={message} loading={loading} />;
};
2 changes: 1 addition & 1 deletion app/lib/time.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const delay = async (ms: number) => {
export const delay = async (ms: number): Promise<void> => {
return new Promise(resolve => setTimeout(resolve, ms));
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ExchangeCredentialsNavigationParamList } from '..';

const Stack = createStackNavigator<ExchangeCredentialsNavigationParamList>();

export default function ExchangeCredentialsNavigation() {
export default function ExchangeCredentialsNavigation(): JSX.Element {
return (
<Stack.Navigator>
<Stack.Screen name="ExchangeCredentials" component={ExchangeCredentials} options={{ headerShown: false }} />
Expand Down

0 comments on commit 7102f72

Please sign in to comment.