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

Adds the appropriate return type for the method or function #1162

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
56 changes: 28 additions & 28 deletions packages/api-catalog-service/src/shared/cron/index.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { Agenda } from 'agenda';
import database from '../../setup/database';
import { MONGO_URL } from '../../setup/env';
import { checkAPIHash } from './cron';
import { Agenda } from "agenda";
import database from "../../setup/database";
import { MONGO_URL } from "../../setup/env";
import { checkAPIHash } from "./cron";
export let agenda: Agenda;

export default function initializeAgenda () {
console.info( 'SETUP - Agenda for cron scripts..' );
agenda = new Agenda( {
db: {
address: MONGO_URL
},
defaultConcurrency: 1
} );
export default function initializeAgenda(): void {
console.info("SETUP - Agenda for cron scripts..");
agenda = new Agenda({
db: {
address: MONGO_URL,
},
defaultConcurrency: 1,
});

agenda.define( 'api-sync-hash', async ( job: any ) => {
await checkAPIHash();
} );
agenda.define("api-sync-hash", async (job: any) => {
await checkAPIHash();
});

agenda.on( 'ready', () => {
/* Start the agenda */
agenda.start();
/* Schedule the jobs */
agenda.every( '6 hours', 'api-sync-hash' );
} );
agenda.on("ready", () => {
/* Start the agenda */
agenda.start();
/* Schedule the jobs */
agenda.every("6 hours", "api-sync-hash");
});
}

if ( require.main === module ) {
( async () => {
/* Setup database connection */
await database();
/* Setup agenda */
initializeAgenda();
} )();
if (require.main === module) {
(async () => {
/* Setup database connection */
await database();
/* Setup agenda */
initializeAgenda();
})();
}
6 changes: 3 additions & 3 deletions packages/api-catalog-spa/src/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ReportHandler } from 'web-vitals';
import { ReportHandler } from "web-vitals";

const reportWebVitals = (onPerfEntry?: ReportHandler) => {
const reportWebVitals = (onPerfEntry?: ReportHandler): void => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
Expand Down
19 changes: 11 additions & 8 deletions packages/apps-service/src/utils/unique-id-from-path.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
export default function uniqueIdFromPath ( path: string ) {
return path.toLowerCase()
/* Replace any special characters with `-` */
.replace( /[\ \-\/\:\@\[\]\`\{\~\.]+/g, '-' )
/* Remove any starting or ending `-` */
.replace( /^-+|-+$/g, '' )
/* Removing multiple consecutive `-`s */
.replace( /--+/g, '-' );
export default function uniqueIdFromPath(path: string): string {
return (
path
.toLowerCase()
/* Replace any special characters with `-` */
.replace(/[\ \-\/\:\@\[\]\`\{\~\.]+/g, "-")
/* Remove any starting or ending `-` */
.replace(/^-+|-+$/g, "")
/* Removing multiple consecutive `-`s */
.replace(/--+/g, "-")
);
}
37 changes: 21 additions & 16 deletions packages/developer-console-spa/src/hooks/useAppAPI.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
import { useEffect, useState } from 'react';
import { appByAppId } from '../utils/gql-queries/app-by-appid';
import gqlClient from '../utils/gqlClient';
import { useEffect, useState } from "react";
import { appByAppId } from "../utils/gql-queries/app-by-appid";
import gqlClient from "../utils/gqlClient";

export default function useAppAPI ( appId: string ) {
const [ app, setApp ] = useState<any>( {} );
const [ loading, setLoading ] = useState<boolean>( true );
export default function useAppAPI(appId: string): {
app: error;
loading: error;
setApp: error;
} {
const [app, setApp] = useState<any>({});
const [loading, setLoading] = useState<boolean>(true);

useEffect( () => {
useEffect(() => {
const abortController = new AbortController();
const signal = abortController.signal;

setLoading( true );
setLoading(true);

gqlClient( { query: appByAppId, variables: { appId } }, signal )
.then( res => {
if ( !res?.data?.app ) {
setLoading( false );
gqlClient({ query: appByAppId, variables: { appId } }, signal).then(
(res) => {
if (!res?.data?.app) {
setLoading(false);
return;
}
setApp( res.data.app );
setLoading( false );
} );
setApp(res.data.app);
setLoading(false);
}
);

return () => abortController.abort();
}, [ appId ] );
}, [appId]);

return { app, loading, setApp };
}
48 changes: 26 additions & 22 deletions packages/developer-console-spa/src/hooks/useFeedbackConfig.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
import { useEffect, useState } from 'react';
import { appFeedbackConfig } from '../utils/gql-queries';
import gqlClient from '../utils/gqlClient';
import { useEffect, useState } from "react";
import { appFeedbackConfig } from "../utils/gql-queries";
import gqlClient from "../utils/gqlClient";

export default function useFeedbackConfig ( appId: string ) {
const [ feedbackConfig, setFeedbackConfig ] = useState<any>( {} );
const [ loading, setLoading ] = useState( true );
export default function useFeedbackConfig(appId: string): {
feedbackConfig: error;
setFeedbackConfig: error;
loading: error;
} {
const [feedbackConfig, setFeedbackConfig] = useState<any>({});
const [loading, setLoading] = useState(true);

useEffect( () => {
if ( !appId ) {
useEffect(() => {
if (!appId) {
return;
}
const abortController = new AbortController();
const signal = abortController.signal;

setLoading( true );
setLoading(true);

gqlClient( { query: appFeedbackConfig, variables: { appId } }, signal )
.then( res => {
if ( !res || !res.data ) {
setLoading( false );
gqlClient({ query: appFeedbackConfig, variables: { appId } }, signal)
.then((res) => {
if (!res || !res.data) {
setLoading(false);
return;
}
setFeedbackConfig( res.data.app?.feedback ?? {} );
setLoading( false );
} )
.catch( err => {
window.OpNotification?.danger( {
subject: 'There was some error fetching feedback configuration.',
body: 'Please try again later.'
} );
setFeedbackConfig(res.data.app?.feedback ?? {});
setLoading(false);
})
.catch((err) => {
window.OpNotification?.danger({
subject: "There was some error fetching feedback configuration.",
body: "Please try again later.",
});
});

return () => abortController.abort();
}, [ appId ] );
}, [appId]);

return { feedbackConfig, setFeedbackConfig, loading };
}
44 changes: 24 additions & 20 deletions packages/developer-console-spa/src/hooks/useLighthouseConfig.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
import { useEffect, useState } from 'react';
import { getLHSpaConfigByAppId } from '../services/lighthouse';
import { useEffect, useState } from "react";
import { getLHSpaConfigByAppId } from "../services/lighthouse";

export default function useLighthouseConfig ( id: string ) {
const [ lighthouseConfig, setLighthouseConfig ] = useState<any>( {} );
const [ loading, setLoading ] = useState( true );
export default function useLighthouseConfig(id: string): {
lighthouseConfig: error;
setLighthouseConfig: error;
loading: error;
} {
const [lighthouseConfig, setLighthouseConfig] = useState<any>({});
const [loading, setLoading] = useState(true);

useEffect( () => {
if ( !id ) {
useEffect(() => {
if (!id) {
return;
}
const abortController = new AbortController();
const signal = abortController.signal;

setLoading( true );
setLoading(true);

getLHSpaConfigByAppId( id, signal )
.then( res => {
setLighthouseConfig( res || {} );
setLoading( false );
} )
.catch( err => {
setLoading( false );
window.OpNotification?.danger( {
subject: 'There was some error fetching lighthouse configuration.',
body: 'Please try again later.'
} );
getLHSpaConfigByAppId(id, signal)
.then((res) => {
setLighthouseConfig(res || {});
setLoading(false);
})
.catch((err) => {
setLoading(false);
window.OpNotification?.danger({
subject: "There was some error fetching lighthouse configuration.",
body: "Please try again later.",
});
});

return () => abortController.abort();
}, [ id ] );
}, [id]);

return { lighthouseConfig, setLighthouseConfig, loading };
}
33 changes: 16 additions & 17 deletions packages/developer-console-spa/src/hooks/useMyAppsAPI.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
import { useEffect, useState } from 'react';
import { myApps } from '../utils/gql-queries';
import gqlClient from '../utils/gqlClient';
import { useEffect, useState } from "react";
import { myApps } from "../utils/gql-queries";
import gqlClient from "../utils/gqlClient";

export default function useMyAppsAPI () {
const [ apps, setApps ] = useState<any[]>( [] );
const [ loading, setLoading ] = useState<boolean>( true );
export default function useMyAppsAPI(): { apps: error; loading: error } {
const [apps, setApps] = useState<any[]>([]);
const [loading, setLoading] = useState<boolean>(true);

useEffect( () => {
useEffect(() => {
const abortController = new AbortController();
const signal = abortController.signal;

gqlClient( { query: myApps }, signal )
.then( res => {
if ( !res || !res.data ) {
setLoading( false );
return;
}
setApps( res.data.myApps );
setLoading( false );
} );
gqlClient({ query: myApps }, signal).then((res) => {
if (!res || !res.data) {
setLoading(false);
return;
}
setApps(res.data.myApps);
setLoading(false);
});

return () => abortController.abort();
}, [] );
}, []);

return { apps, loading };
}
6 changes: 3 additions & 3 deletions packages/developer-console-spa/src/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ReportHandler } from 'web-vitals';
import { ReportHandler } from "web-vitals";

const reportWebVitals = (onPerfEntry?: ReportHandler) => {
const reportWebVitals = (onPerfEntry?: ReportHandler): void => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
Expand Down
Loading