diff --git a/lib/config/types.ts b/lib/config/types.ts index e8dfa83833826d..739c606e32a555 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -410,10 +410,10 @@ export interface PackageRuleInputConfig extends Record { lockedVersion?: string; updateType?: UpdateType; isBump?: boolean; - sourceUrl?: string; + sourceUrl?: string | null; language?: string; baseBranch?: string; - manager?: string; + manager?: string | null; datasource?: string; packageRules?: (PackageRule & PackageRuleInputConfig)[]; } diff --git a/lib/modules/manager/types.ts b/lib/modules/manager/types.ts index ec0331a20ce5a5..1f1f542c39fcae 100644 --- a/lib/modules/manager/types.ts +++ b/lib/modules/manager/types.ts @@ -58,7 +58,7 @@ export interface RangeConfig> extends ManagerData { currentValue?: string; depName?: string; depType?: string; - manager?: string; + manager?: string | null; packageJsonType?: 'app' | 'library'; rangeStrategy: RangeStrategy; } @@ -145,6 +145,9 @@ export interface LookupUpdate { newVersion?: string; updateType?: UpdateType; userStrings?: Record; + checksumUrl?: string; + downloadUrl?: string; + releaseTimestamp?: any; } export interface PackageDependency> extends Package { diff --git a/lib/workers/repository/process/lookup/bucket.ts b/lib/workers/repository/process/lookup/bucket.ts index 8c951a050ef373..3c50a95f67ec43 100644 --- a/lib/workers/repository/process/lookup/bucket.ts +++ b/lib/workers/repository/process/lookup/bucket.ts @@ -11,7 +11,7 @@ export function getBucket( currentVersion: string, newVersion: string, versioning: VersioningApi -): string { +): string | null { const { separateMajorMinor, separateMultipleMajor, separateMinorPatch } = config; if (!separateMajorMinor) { diff --git a/lib/workers/repository/process/lookup/filter-checks.ts b/lib/workers/repository/process/lookup/filter-checks.ts index e76c6f541649b4..a290984b5ea3e7 100644 --- a/lib/workers/repository/process/lookup/filter-checks.ts +++ b/lib/workers/repository/process/lookup/filter-checks.ts @@ -26,7 +26,7 @@ export async function filterInternalChecks( sortedReleases: Release[] ): Promise { const { currentVersion, datasource, depName, internalChecksFilter } = config; - let release: Release; + let release: Release | undefined = undefined; let pendingChecks = false; let pendingReleases: Release[] = []; if (internalChecksFilter === 'none') { @@ -41,12 +41,13 @@ export async function filterInternalChecks( releaseConfig.updateType = getUpdateType( releaseConfig, versioning, - currentVersion, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + currentVersion!, candidateRelease.version ); releaseConfig = mergeChildConfig( releaseConfig, - releaseConfig[releaseConfig.updateType] + releaseConfig[releaseConfig.updateType]! ); // Apply packageRules in case any apply to updateType releaseConfig = applyPackageRules(releaseConfig); @@ -69,15 +70,21 @@ export async function filterInternalChecks( continue; } } - if (isActiveConfidenceLevel(minimumConfidence)) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + if (isActiveConfidenceLevel(minimumConfidence!)) { const confidenceLevel = await getMergeConfidenceLevel( - datasource, - depName, - currentVersion, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + datasource!, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + depName!, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + currentVersion!, newVersion, - updateType + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + updateType! ); - if (!satisfiesConfidenceLevel(confidenceLevel, minimumConfidence)) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + if (!satisfiesConfidenceLevel(confidenceLevel, minimumConfidence!)) { logger.debug( { depName, check: 'minimumConfidence' }, `Release ${candidateRelease.version} is pending status checks` @@ -106,5 +113,6 @@ export async function filterInternalChecks( } } } - return { release, pendingChecks, pendingReleases }; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return { release: release!, pendingChecks, pendingReleases }; } diff --git a/lib/workers/repository/process/lookup/filter.ts b/lib/workers/repository/process/lookup/filter.ts index 4f0f03c1acc695..fa5e63069944d5 100644 --- a/lib/workers/repository/process/lookup/filter.ts +++ b/lib/workers/repository/process/lookup/filter.ts @@ -50,7 +50,8 @@ export function filterVersions( const versionRelease = releases.find( (release) => release.version === v.version ); - if (versionRelease.isDeprecated) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + if (versionRelease!.isDeprecated) { logger.trace( `Skipping ${config.depName}@${v.version} because it is deprecated` ); @@ -79,7 +80,7 @@ export function filterVersions( 'Falling back to npm semver syntax for allowedVersions' ); filteredVersions = filteredVersions.filter((v) => - semver.satisfies(semver.coerce(v.version), allowedVersions) + semver.satisfies(semver.coerce(v.version)!, allowedVersions) ); } else if ( config.versioning === poetryVersioning.id && diff --git a/lib/workers/repository/process/lookup/generate.ts b/lib/workers/repository/process/lookup/generate.ts index 058d9a9477867d..64e272350449a6 100644 --- a/lib/workers/repository/process/lookup/generate.ts +++ b/lib/workers/repository/process/lookup/generate.ts @@ -18,19 +18,26 @@ export function generateUpdate( const update: LookupUpdate = { bucket, newVersion, - newValue: null, + newValue: null!, }; - const releaseFields = [ - 'checksumUrl', - 'downloadUrl', - 'newDigest', - 'releaseTimestamp', - ]; - for (const field of releaseFields) { - if (release[field] !== undefined) { - update[field] = release[field]; - } + + // istanbul ignore if + if (release.checksumUrl !== undefined) { + update.checksumUrl = release.checksumUrl; + } + // istanbul ignore if + if (release.downloadUrl !== undefined) { + update.downloadUrl = release.downloadUrl; } + // istanbul ignore if + if (release.newDigest !== undefined) { + update.newDigest = release.newDigest; + } + // istanbul ignore if + if (release.releaseTimestamp !== undefined) { + update.releaseTimestamp = release.releaseTimestamp; + } + const { currentValue } = config; if (currentValue) { try { @@ -39,7 +46,7 @@ export function generateUpdate( rangeStrategy, currentVersion, newVersion, - }); + })!; } catch (err) /* istanbul ignore next */ { logger.warn( { err, currentValue, rangeStrategy, currentVersion, newVersion }, @@ -48,14 +55,14 @@ export function generateUpdate( update.newValue = currentValue; } } else { - update.newValue = currentValue; + update.newValue = currentValue!; } - update.newMajor = versioning.getMajor(newVersion); - update.newMinor = versioning.getMinor(newVersion); + update.newMajor = versioning.getMajor(newVersion)!; + update.newMinor = versioning.getMinor(newVersion)!; // istanbul ignore if if (!update.updateType && !currentVersion) { logger.debug({ update }, 'Update has no currentVersion'); - update.newValue = currentValue; + update.newValue = currentValue!; return update; } update.updateType = @@ -69,7 +76,8 @@ export function generateUpdate( } if ( rangeStrategy === 'bump' && - versioning.matches(newVersion, currentValue) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + versioning.matches(newVersion, currentValue!) ) { update.isBump = true; } diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index 02d84803c3ce9b..33a1fbeefb40eb 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -67,7 +67,8 @@ export async function lookupUpdates( if (unconstrainedValue || isValid) { if ( !updatePinnedDependencies && - versioning.isSingleVersion(currentValue) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + versioning.isSingleVersion(currentValue!) ) { res.skipReason = 'is-pinned'; return res; @@ -132,7 +133,9 @@ export async function lookupUpdates( } // Check that existing constraint can be satisfied const allSatisfyingVersions = allVersions.filter( - (v) => unconstrainedValue || versioning.matches(v.version, currentValue) + (v) => + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + unconstrainedValue || versioning.matches(v.version, currentValue!) ); if (rollbackPrs && !allSatisfyingVersions.length) { const rollback = getRollbackUpdate(config, allVersions, versioning); @@ -152,10 +155,12 @@ export async function lookupUpdates( updateType: 'replacement', newName: dependency.replacementName, newValue: versioning.getNewValue({ - currentValue, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + currentValue: currentValue!, newVersion: dependency.replacementVersion, - rangeStrategy, - }), + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + rangeStrategy: rangeStrategy!, + })!, }); } // istanbul ignore next @@ -171,33 +176,43 @@ export async function lookupUpdates( .map((release) => release.version); let currentVersion: string; if (rangeStrategy === 'update-lockfile') { - currentVersion = lockedVersion; + currentVersion = lockedVersion!; } currentVersion ??= getCurrentVersion( - currentValue, - lockedVersion, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + currentValue!, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + lockedVersion!, versioning, - rangeStrategy, - latestVersion, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + rangeStrategy!, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + latestVersion!, nonDeprecatedVersions - ) || + )! || getCurrentVersion( - currentValue, - lockedVersion, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + currentValue!, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + lockedVersion!, versioning, - rangeStrategy, - latestVersion, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + rangeStrategy!, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + latestVersion!, allVersions.map((v) => v.version) - ); + )!; // istanbul ignore if - if (!currentVersion && lockedVersion) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + if (!currentVersion! && lockedVersion) { return res; } - res.currentVersion = currentVersion; + res.currentVersion = currentVersion!; if ( currentValue && - currentVersion && + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + currentVersion! && rangeStrategy === 'pin' && !versioning.isSingleVersion(currentValue) ) { @@ -209,20 +224,23 @@ export async function lookupUpdates( rangeStrategy, currentVersion, newVersion: currentVersion, - }), - newMajor: versioning.getMajor(currentVersion), + })!, + newMajor: versioning.getMajor(currentVersion)!, }); } // istanbul ignore if - if (!versioning.isVersion(currentVersion)) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + if (!versioning.isVersion(currentVersion!)) { res.skipReason = 'invalid-version'; return res; } // Filter latest, unstable, etc let filteredReleases = filterVersions( config, - currentVersion, - latestVersion, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + currentVersion!, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + latestVersion!, allVersions, versioning ).filter( @@ -237,7 +255,8 @@ export async function lookupUpdates( for (const release of filteredReleases) { const bucket = getBucket( config, - currentVersion, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + currentVersion!, release.version, versioning ); @@ -269,16 +288,20 @@ export async function lookupUpdates( const update = generateUpdate( config, versioning, - rangeStrategy, - lockedVersion || currentVersion, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + rangeStrategy!, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + lockedVersion || currentVersion!, bucket, release ); if (pendingChecks) { update.pendingChecks = pendingChecks; } - if (pendingReleases.length) { - update.pendingVersions = pendingReleases.map((r) => r.version); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + if (pendingReleases!.length) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + update.pendingVersions = pendingReleases!.map((r) => r.version); } if (!update.newValue || update.newValue === currentValue) { if (!lockedVersion) { @@ -326,7 +349,8 @@ export async function lookupUpdates( // digest update res.updates.push({ updateType: 'digest', - newValue: currentValue, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + newValue: currentValue!, }); } } else if (pinDigests) { @@ -336,21 +360,24 @@ export async function lookupUpdates( res.updates.push({ isPinDigest: true, updateType: 'pinDigest', - newValue: currentValue, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + newValue: currentValue!, }); } } if (versioning.valueToVersion) { - res.currentVersion = versioning.valueToVersion(res.currentVersion); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + res.currentVersion = versioning.valueToVersion(res.currentVersion!); for (const update of res.updates || []) { - update.newVersion = versioning.valueToVersion(update.newVersion); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + update.newVersion = versioning.valueToVersion(update.newVersion!); } } // update digest for all for (const update of res.updates) { if (pinDigests || currentDigest) { update.newDigest = - update.newDigest || (await getDigest(config, update.newValue)); + update.newDigest || (await getDigest(config, update.newValue))!; } } } @@ -364,7 +391,8 @@ export async function lookupUpdates( (update) => update.newValue !== currentValue || update.isLockfileUpdate || - (update.newDigest && !update.newDigest.startsWith(currentDigest)) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + (update.newDigest && !update.newDigest.startsWith(currentDigest!)) ); // If range strategy specified in config is 'in-range-only', also strip out updates where currentValue !== newValue if (config.rangeStrategy === 'in-range-only') { diff --git a/lib/workers/repository/process/lookup/rollback.ts b/lib/workers/repository/process/lookup/rollback.ts index 3ad692ed8947df..7c17a70340b843 100644 --- a/lib/workers/repository/process/lookup/rollback.ts +++ b/lib/workers/repository/process/lookup/rollback.ts @@ -8,7 +8,7 @@ export function getRollbackUpdate( config: RollbackConfig, versions: Release[], version: VersioningApi -): LookupUpdate { +): LookupUpdate | null { const { packageFile, versioning, depName, currentValue } = config; // istanbul ignore if if (!('isLessThanRange' in version)) { @@ -19,7 +19,8 @@ export function getRollbackUpdate( return null; } const lessThanVersions = versions.filter((v) => - version.isLessThanRange(v.version, currentValue) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + version.isLessThanRange!(v.version, currentValue!) ); // istanbul ignore if if (!lessThanVersions.length) { @@ -45,14 +46,16 @@ export function getRollbackUpdate( return null; } const newValue = version.getNewValue({ - currentValue, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + currentValue: currentValue!, rangeStrategy: 'replace', newVersion, }); return { bucket: 'rollback', - newMajor: version.getMajor(newVersion), - newValue, + newMajor: version.getMajor(newVersion)!, + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + newValue: newValue!, newVersion, updateType: 'rollback', }; diff --git a/lib/workers/repository/process/lookup/types.ts b/lib/workers/repository/process/lookup/types.ts index b06583fa9e30ce..4c10d150a5e420 100644 --- a/lib/workers/repository/process/lookup/types.ts +++ b/lib/workers/repository/process/lookup/types.ts @@ -52,10 +52,10 @@ export interface UpdateResult { dependencyUrl?: string; homepage?: string; deprecationMessage?: string; - sourceUrl?: string; + sourceUrl?: string | null; currentVersion?: string; isSingleVersion?: boolean; - skipReason: SkipReason; + skipReason?: SkipReason; releases: Release[]; fixedVersion?: string; updates: LookupUpdate[]; diff --git a/lib/workers/repository/process/lookup/update-type.ts b/lib/workers/repository/process/lookup/update-type.ts index 4c8f9dcebe5219..4da91f3e338ffa 100644 --- a/lib/workers/repository/process/lookup/update-type.ts +++ b/lib/workers/repository/process/lookup/update-type.ts @@ -13,10 +13,10 @@ export function getUpdateType( currentVersion: string, newVersion: string ): UpdateType { - if (versioning.getMajor(newVersion) > versioning.getMajor(currentVersion)) { + if (versioning.getMajor(newVersion)! > versioning.getMajor(currentVersion)!) { return 'major'; } - if (versioning.getMinor(newVersion) > versioning.getMinor(currentVersion)) { + if (versioning.getMinor(newVersion)! > versioning.getMinor(currentVersion)!) { return 'minor'; } return 'patch'; diff --git a/tsconfig.strict.json b/tsconfig.strict.json index 85ef1dd9a1c613..2315840d17b0b2 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -59,15 +59,6 @@ "lib/workers/repository/process/fetch.ts", "lib/workers/repository/process/index.ts", "lib/workers/repository/process/limits.ts", - "lib/workers/repository/process/lookup/bucket.ts", - "lib/workers/repository/process/lookup/current.ts", - "lib/workers/repository/process/lookup/filter-checks.ts", - "lib/workers/repository/process/lookup/filter.ts", - "lib/workers/repository/process/lookup/generate.ts", - "lib/workers/repository/process/lookup/index.ts", - "lib/workers/repository/process/lookup/rollback.ts", - "lib/workers/repository/process/lookup/types.ts", - "lib/workers/repository/process/lookup/update-type.ts", "lib/workers/repository/process/sort.ts", "lib/workers/repository/process/write.ts", "lib/workers/repository/process/vulnerabilities.ts",