diff --git a/lib/util/cache/memory/index.ts b/lib/util/cache/memory/index.ts index 3b2860220e773a3d5cbe15e59e2c87396c92a2ed..b83ee4969de4ccb13d1df1c220f7a22a73d35e3a 100644 --- a/lib/util/cache/memory/index.ts +++ b/lib/util/cache/memory/index.ts @@ -12,7 +12,7 @@ export function get<T = any>(key: string): T { return repoCache?.[key]; } -export function set(key: string, value: any): void { +export function set(key: string, value: unknown): void { if (repoCache) { repoCache[key] = value; } diff --git a/lib/util/cache/package/index.ts b/lib/util/cache/package/index.ts index 6962b73c6ad2b1591f45349ec5f1be8a96e65137..4735f5e977467cb0b081722d629757bbb27a5035 100644 --- a/lib/util/cache/package/index.ts +++ b/lib/util/cache/package/index.ts @@ -24,7 +24,7 @@ export function get<T = any>(namespace: string, key: string): Promise<T> { export function set( namespace: string, key: string, - value: any, + value: unknown, minutes: number ): Promise<void> { if (!cacheProxy) { diff --git a/lib/util/exec/docker/index.ts b/lib/util/exec/docker/index.ts index cb3221807afc6b590183d6b17b94cef0c654ce57..773126794739de1b1a37765bdb242402e3e7b90b 100644 --- a/lib/util/exec/docker/index.ts +++ b/lib/util/exec/docker/index.ts @@ -117,7 +117,7 @@ function getContainerName(image: string): string { return image.replace(/\//g, '_'); } -export async function removeDockerContainer(image): Promise<void> { +export async function removeDockerContainer(image: string): Promise<void> { const containerName = getContainerName(image); let cmd = `docker ps --filter name=${containerName} -aq`; try { @@ -208,7 +208,7 @@ export async function generateDockerCommand( result.push(`-w "${cwd}"`); } - let tag; + let tag: string; if (options.tag) { tag = options.tag; } else if (tagConstraint) { diff --git a/lib/util/exec/index.ts b/lib/util/exec/index.ts index 27f60115a66e13241793d7e92a0478d1e9885606..7f94d0b5602cbca55624d63ad95811b221b5c7b7 100644 --- a/lib/util/exec/index.ts +++ b/lib/util/exec/index.ts @@ -158,9 +158,10 @@ export async function exec( logger.trace({ err }, 'rawExec err'); clearTimeout(timer); if (useDocker) { - await removeDockerContainer(docker.image).catch((removeErr) => { + await removeDockerContainer(docker.image).catch((removeErr: Error) => { + const message: string = err.message; throw new Error( - `Error: "${removeErr.message}" - Original Error: "${err.message}"` + `Error: "${removeErr.message}" - Original Error: "${message}"` ); }); } diff --git a/lib/util/fs/index.ts b/lib/util/fs/index.ts index 313dd6e488f73f3a0e72a96706d7c02f45e24a6d..e26afe1ea8af34cac930dd5d625e3824b3725fc4 100644 --- a/lib/util/fs/index.ts +++ b/lib/util/fs/index.ts @@ -60,18 +60,18 @@ export async function deleteLocalFile(fileName: string): Promise<void> { } // istanbul ignore next -export async function ensureDir(dirName): Promise<void> { +export async function ensureDir(dirName: string): Promise<void> { await fs.ensureDir(dirName); } // istanbul ignore next -export async function ensureLocalDir(dirName): Promise<void> { +export async function ensureLocalDir(dirName: string): Promise<void> { const localDirName = join(localDir, dirName); await fs.ensureDir(localDirName); } export async function ensureCacheDir( - dirName, + dirName: string, envPathVar?: string ): Promise<string> { const envCacheDirName = envPathVar ? process.env[envPathVar] : null; diff --git a/lib/util/fs/proxies.ts b/lib/util/fs/proxies.ts index 86f26b5fdf06ac4b2fba07bd081e1df3782adc2d..9dfefc4667c167a3739cca73766da266ad3e2d32 100644 --- a/lib/util/fs/proxies.ts +++ b/lib/util/fs/proxies.ts @@ -37,7 +37,7 @@ export function writeFile( // istanbul ignore next export function outputFile( file: string, - data: any, + data: unknown, options?: WriteFileOptions | string ): Promise<void> { return fs.outputFile(file, data, options ?? {}); diff --git a/lib/util/http/github.ts b/lib/util/http/github.ts index 35ca32c3192b467c81bdb1c1656ea92d9becfcb1..aacc666d7574c2bb98e14700404c83ec40b6f3c1 100644 --- a/lib/util/http/github.ts +++ b/lib/util/http/github.ts @@ -257,7 +257,7 @@ export class GithubHttp extends Http<GithubHttpOptions, GithubHttpOptions> { const { paginate = true } = options; let count = options.count || 100; - let cursor = null; + let cursor: string = null; let isIterating = true; while (isIterating) { diff --git a/lib/util/http/index.ts b/lib/util/http/index.ts index c45fa75bae2d0b472e062bed83ab5f4ec4e35059..b3ba41b522dd1119bf28a89177b2b43556d6e362 100644 --- a/lib/util/http/index.ts +++ b/lib/util/http/index.ts @@ -33,7 +33,7 @@ export interface HttpPostOptions extends HttpOptions { } export interface InternalHttpOptions extends HttpOptions { - json?: object; + json?: Record<string, unknown>; responseType?: 'json'; method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head'; } diff --git a/lib/util/package-rules.ts b/lib/util/package-rules.ts index ea73c86e4d3e6b3284dbc6207f4c73d0d62814a8..8401eec933a8716422811ccb1956922f2423e174 100644 --- a/lib/util/package-rules.ts +++ b/lib/util/package-rules.ts @@ -147,7 +147,7 @@ function matchesRule(inputConfig: Config, packageRule: PackageRule): boolean { : packagePattern ); if (packageRegex.test(depName)) { - logger.trace(`${depName} matches against ${packageRegex}`); + logger.trace(`${depName} matches against ${String(packageRegex)}`); isMatch = true; } } @@ -171,7 +171,7 @@ function matchesRule(inputConfig: Config, packageRule: PackageRule): boolean { pattern === '^*$' || pattern === '*' ? '.*' : pattern ); if (packageRegex.test(depName)) { - logger.trace(`${depName} matches against ${packageRegex}`); + logger.trace(`${depName} matches against ${String(packageRegex)}`); isMatch = true; } } diff --git a/lib/util/regex.ts b/lib/util/regex.ts index d1e7aa9559a9c56502372dc6711f81d41ea513f9..64bdbb6b7f3f35c3d4f293fa4a530de349a2263f 100644 --- a/lib/util/regex.ts +++ b/lib/util/regex.ts @@ -21,7 +21,7 @@ export function regEx(pattern: string, flags?: string): RegExp { } catch (err) { const error = new Error(CONFIG_VALIDATION); error.configFile = pattern; - error.validationError = 'Invalid regular expression: ' + err.toString(); + error.validationError = `Invalid regular expression: ${pattern}`; throw error; } } diff --git a/lib/util/template/index.ts b/lib/util/template/index.ts index abc78c1f852b1035cf3eaf55af34289b18aeca4d..502a8639976f033a5ac2c889608e9fdd59f35daf 100644 --- a/lib/util/template/index.ts +++ b/lib/util/template/index.ts @@ -84,7 +84,9 @@ export const allowedFields = { versions: 'An array of ChangeLogRelease objects in the upgrade', }; -function getFilteredObject(input: any): any { +type CompileInput = Record<string, unknown>; + +function getFilteredObject(input: CompileInput): any { const obj = clone(input); const res = {}; const allAllowed = [ @@ -94,8 +96,10 @@ function getFilteredObject(input: any): any { for (const field of allAllowed) { const value = obj[field]; if (is.array(value)) { - res[field] = value.map((element) => getFilteredObject(element)); - } else if (is.object(value)) { + res[field] = value.map((element) => + getFilteredObject(element as CompileInput) + ); + } else if (is.plainObject(value)) { res[field] = getFilteredObject(value); } else if (!is.undefined(value)) { res[field] = value; @@ -106,7 +110,7 @@ function getFilteredObject(input: any): any { export function compile( template: string, - input: any, + input: CompileInput, filterFields = true ): string { const filteredInput = filterFields ? getFilteredObject(input) : input;