Skip to content

Commit

Permalink
No implicit any (#403)
Browse files Browse the repository at this point in the history
Co-authored-by: Gilles Dubreuil <gilles@redhat.com>
  • Loading branch information
ibolton336 and gildub authored Sep 15, 2022
1 parent 8c9210d commit cee0600
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 40 deletions.
2 changes: 1 addition & 1 deletion client/src/app/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface IEnvVars {
KEYCLOAK_SERVER_URL: string;
UI_INGRESS_PROXY_BODY_SIZE: string;
}
export const ENV: IEnvVars = window["_env"] || {};
export const ENV: IEnvVars = (window as { [key: string]: any })["_env"] || {};
export const isAuthRequired = ENV.AUTH_REQUIRED !== "false";
export const uploadLimit = ENV.UI_INGRESS_PROXY_BODY_SIZE || "500m";

Expand Down
6 changes: 5 additions & 1 deletion client/src/app/api/rest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ const buildQuery = (params: any) => {

//Volumes
// poll clean task
export const getTaskById = ({ queryKey }): AxiosPromise<Task> => {
export const getTaskById = ({
queryKey,
}: {
queryKey: any;
}): AxiosPromise<Task> => {
const [_, processId] = queryKey;
return axios.get<Task>(`${TASKS}/${processId}`);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ export const AddCustomRules: React.FunctionComponent<IAddCustomRules> = ({
setReadFileData((prevReadFiles) => [...prevReadFiles, newFile]);
};

const handleReadFail = (error: DOMException, percentage, file: File) => {
const handleReadFail = (
error: DOMException,
percentage: number,
file: File
) => {
setError(error.toString());
setReadFileData((prevReadFiles) => [
...prevReadFiles,
Expand All @@ -186,13 +190,13 @@ export const AddCustomRules: React.FunctionComponent<IAddCustomRules> = ({
(fileData) => fileData.loadResult === "success"
).length;

const getloadPercentage = (filename) => {
const getloadPercentage = (filename: string) => {
const readFile = readFileData.find((file) => file.fileName === filename);
if (readFile) return readFile.loadPercentage;
return 0;
};

const getloadResult = (filename) => {
const getloadResult = (filename: string) => {
const readFile = readFileData.find((file) => file.fileName === filename);
if (readFile) return readFile.loadResult;
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "@testing-library/jest-dom";
import { BusinessService } from "@app/api/models";

jest.mock("react-i18next");
const data = [];
const data: any[] = [];
mock.onGet(`${BUSINESS_SERVICES}`).reply(200, data);
mock.onGet(`${TAG_TYPES}`).reply(200, data);
mock.onGet(`${APPLICATIONS}`).reply(200, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const ApplicationForm: React.FC<ApplicationFormProps> = ({
let standardUrlRegex =
/(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/gi;
standardUrlRegex = new RegExp(standardUrlRegex);
const containsURL = (string) =>
const containsURL = (string: string) =>
gitUrlRegex.test(string) || standardUrlRegex.test(string);

return schema.test("gitUrlTest", "Must be a valid URL.", (value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import "@testing-library/jest-dom";

jest.mock("react-i18next");

const data = [];
const data: any[] = [];

mock.onGet(`${IDENTITIES}`).reply(200, data);

Expand Down
2 changes: 1 addition & 1 deletion client/src/app/queries/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useFetchApplications = () => {
onSuccess: (data: Application[]) => {
queryClient.invalidateQueries(reviewsQueryKey);
},
onError: (err: AxiosError) => console.log(error),
onError: (error: AxiosError) => console.log(error),
}
);
return {
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/queries/assessments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const useFetchApplicationAssessments = (
const allAssessmentsForApp = response.data;
return allAssessmentsForApp[0];
},
onError: (error) => console.log("error, ", error),
onError: (error: any) => console.log("error, ", error),
}))
);
const queryResultsByAppId: Record<number, UseQueryResult<Assessment>> = {};
Expand Down
6 changes: 3 additions & 3 deletions client/src/app/queries/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useFetchImports = (
const { data, isLoading, error, refetch } = useQuery(
[ImportsQueryKey, importSummaryID, isValid],
() => getApplicationImports(importSummaryID, isValid),
{ onError: (err: Error) => console.log(error) }
{ onError: (error) => console.log(error) }
);
return {
imports: data || [],
Expand All @@ -34,7 +34,7 @@ export const useFetchImportSummaries = () => {
getApplicationsImportSummary,
{
refetchInterval: 5000,
onError: (err: Error) => console.log(error),
onError: (error) => console.log(error),
}
);
return {
Expand All @@ -49,7 +49,7 @@ export const useFetchImportSummaryByID = (id: number | string) => {
const { data, isLoading, error, refetch } = useQuery(
[ImportQueryKey, id],
() => getApplicationImportSummaryById(id),
{ onError: (err: Error) => console.log(error) }
{ onError: (error) => console.log(error) }
);

return {
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/queries/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useFetchProxies = (
const { isLoading, data, error } = useQuery(
"proxies",
async () => (await getProxies()).data,
{ onError: () => console.log("error, ", error) }
{ onError: (error) => console.log("error, ", error) }
);
return {
proxies: data || [],
Expand Down
8 changes: 7 additions & 1 deletion client/src/app/queries/volumes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ export const useFetchVolumes = (): IVolumeFetchState => {
};
};

export const useCleanRepositoryMutation = ({ onSuccess, onError }) => {
export const useCleanRepositoryMutation = ({
onSuccess,
onError,
}: {
onSuccess: any;
onError: any;
}) => {
// Mutation to kick off the clean task
const {
data: mutationResult,
Expand Down
15 changes: 0 additions & 15 deletions client/src/app/test-config/__mocks__/react-i18next.js

This file was deleted.

12 changes: 12 additions & 0 deletions client/src/app/test-config/__mocks__/react-i18next.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const useTranslation = () => {
return {
t: (str: any) => str,
i18n: {
changeLanguage: () => new Promise(() => {}),
},
};
};
export const initReactI18next = {
type: "3rdParty",
init: jest.fn(),
};
2 changes: 1 addition & 1 deletion client/src/app/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const duplicateNameCheck = <T extends { name?: string }>(
nameValue: T["name"]
) => duplicateFieldCheck("name", itemList, currentItem, nameValue);

export const dedupeFunction = (arr) =>
export const dedupeFunction = (arr: any[]) =>
arr?.filter(
(value, index, self) =>
index === self.findIndex((t) => t.value === value.value)
Expand Down
14 changes: 5 additions & 9 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
"include": ["src/**/*"],
"compilerOptions": {
"outDir": "dist",
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"sourceMap": true,
"allowJs": true,
"checkJs": true,
Expand All @@ -21,7 +17,7 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noImplicitAny": false,
"noImplicitAny": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
Expand All @@ -36,6 +32,6 @@
"noFallthroughCasesInSwitch": true,
"noImplicitThis": true,
"strictNullChecks": true,
"noEmit": true
},
"noEmit": true
}
}

0 comments on commit cee0600

Please sign in to comment.