Improve type safety by using more specific function types

This commit is contained in:
Henry Mercer 2024-06-13 19:26:45 +01:00
parent 2e69043274
commit d8f549d6d8
9 changed files with 21 additions and 14 deletions

View file

@ -51,7 +51,6 @@
// "temporarily downgraded during transition to eslint // "temporarily downgraded during transition to eslint
"files": "**", "files": "**",
"rules": { "rules": {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off", "@typescript-eslint/no-unsafe-assignment": "off",

View file

@ -1 +1 @@
{"version":3,"file":"analyze-action-post-helper.js","sourceRoot":"","sources":["../src/analyze-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,iDAA2C;AAC3C,uCAA6C;AAEtC,KAAK,UAAU,GAAG,CAAC,wBAAkC;IAC1D,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAElC,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAS,EAAC,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5E,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,2FAA2F,CAC5F,CAAC;IACJ,CAAC;IAED,+CAA+C;IAC/C,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CACP,oFAAoF,CACrF,CAAC;QACF,MAAM,SAAS,GAAG,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACzD,MAAM,wBAAwB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAlBD,kBAkBC"} {"version":3,"file":"analyze-action-post-helper.js","sourceRoot":"","sources":["../src/analyze-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,iDAAmD;AACnD,uCAA6C;AAEtC,KAAK,UAAU,GAAG,CACvB,wBAGkB;IAElB,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAElC,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAS,EAAC,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5E,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,2FAA2F,CAC5F,CAAC;IACJ,CAAC;IAED,+CAA+C;IAC/C,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CACP,oFAAoF,CACrF,CAAC;QACF,MAAM,SAAS,GAAG,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACzD,MAAM,wBAAwB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAvBD,kBAuBC"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,10 +1,15 @@
import * as core from "@actions/core"; import * as core from "@actions/core";
import * as actionsUtil from "./actions-util"; import * as actionsUtil from "./actions-util";
import { getConfig } from "./config-utils"; import { Config, getConfig } from "./config-utils";
import { getActionsLogger } from "./logging"; import { getActionsLogger } from "./logging";
export async function run(uploadSarifDebugArtifact: Function) { export async function run(
uploadSarifDebugArtifact: (
config: Config,
outputDir: string,
) => Promise<void>,
) {
const logger = getActionsLogger(); const logger = getActionsLogger();
const config = await getConfig(actionsUtil.getTemporaryDirectory(), logger); const config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);

View file

@ -233,14 +233,14 @@ export interface BetterResolveLanguagesOutput {
export interface ResolveQueriesOutput { export interface ResolveQueriesOutput {
byLanguage: { byLanguage: {
[language: string]: { [language: string]: {
[queryPath: string]: {}; [queryPath: string]: object;
}; };
}; };
noDeclaredLanguage: { noDeclaredLanguage: {
[queryPath: string]: {}; [queryPath: string]: object;
}; };
multipleDeclaredLanguages: { multipleDeclaredLanguages: {
[queryPath: string]: {}; [queryPath: string]: object;
}; };
} }

View file

@ -81,7 +81,7 @@ function createConfigFile(inputFileContents: string, tmpDir: string): string {
return configFilePath; return configFilePath;
} }
type GetContentsResponse = { content?: string } | Array<{}>; type GetContentsResponse = { content?: string } | object[];
function mockGetContents( function mockGetContents(
content: GetContentsResponse, content: GetContentsResponse,

View file

@ -1065,7 +1065,7 @@ function createRegistriesBlock(registries: RegistryConfigWithCredentials[]): {
*/ */
export async function wrapEnvironment( export async function wrapEnvironment(
env: Record<string, string | undefined>, env: Record<string, string | undefined>,
operation: Function, operation: () => Promise<void>,
) { ) {
// Remember the original env // Remember the original env
const oldEnv = { ...process.env }; const oldEnv = { ...process.env };

View file

@ -163,9 +163,12 @@ export async function tryUploadSarifIfRunFailed(
} }
export async function run( export async function run(
uploadDatabaseBundleDebugArtifact: Function, uploadDatabaseBundleDebugArtifact: (
uploadLogsDebugArtifact: Function, config: Config,
printDebugLogs: Function, logger: Logger,
) => Promise<void>,
uploadLogsDebugArtifact: (config: Config) => Promise<void>,
printDebugLogs: (config: Config) => Promise<void>,
config: Config, config: Config,
repositoryNwo: RepositoryNwo, repositoryNwo: RepositoryNwo,
features: FeatureEnablement, features: FeatureEnablement,