From e5c6f38d750383538bab95a40184058fec5bf0e0 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Tue, 21 Jun 2022 13:00:21 +0200 Subject: [PATCH] refactor: enable strict checks (#16168) * refactor: enable strict checks * chore: revert changes * chore: fix tsconfig --- .eslintrc.js | 2 +- .github/workflows/build.yml | 4 +- lib/config/migration.ts | 3 - lib/config/options/index.spec.ts | 2 - lib/config/presets/gitea/index.ts | 1 - lib/config/presets/index.spec.ts | 1 - lib/config/presets/local/common.ts | 1 - lib/config/presets/local/index.ts | 1 - lib/config/presets/npm/index.ts | 1 - lib/config/validation.ts | 2 - lib/modules/datasource/crate/index.ts | 1 - lib/modules/datasource/docker/index.ts | 12 +-- lib/modules/datasource/galaxy/index.ts | 9 +-- lib/modules/datasource/github-tags/index.ts | 6 +- lib/modules/datasource/gitlab-tags/index.ts | 1 - lib/modules/datasource/index.spec.ts | 2 - lib/modules/datasource/index.ts | 13 ++-- lib/modules/datasource/npm/npmrc.ts | 1 - lib/modules/datasource/packagist/index.ts | 1 - .../datasource/rubygems/get-rubygems-org.ts | 3 +- .../manager/batect-wrapper/artifacts.ts | 1 - lib/modules/manager/batect/extract.spec.ts | 1 - lib/modules/manager/batect/extract.ts | 1 - lib/modules/manager/composer/extract.ts | 1 - lib/modules/manager/composer/update-locked.ts | 1 - lib/modules/manager/composer/utils.ts | 4 +- lib/modules/manager/flux/extract.ts | 1 - .../manager/git-submodules/artifacts.ts | 3 +- lib/modules/manager/git-submodules/update.ts | 2 - lib/modules/manager/gitlabci/extract.spec.ts | 1 - lib/modules/manager/gitlabci/utils.ts | 4 +- lib/modules/manager/gomod/artifacts.ts | 3 - lib/modules/manager/gomod/extract.ts | 1 - lib/modules/manager/gomod/update.spec.ts | 1 - lib/modules/manager/gomod/update.ts | 11 +-- .../gradle-wrapper/artifacts-real.spec.ts | 1 - .../manager/gradle-wrapper/artifacts.ts | 3 - lib/modules/manager/gradle/parser.spec.ts | 2 - lib/modules/manager/gradle/parser.ts | 4 - lib/modules/manager/gradle/update.ts | 4 +- lib/modules/manager/helmv3/extract.ts | 1 - lib/modules/manager/index.spec.ts | 1 - .../manager/jsonnet-bundler/artifacts.ts | 1 - lib/modules/manager/maven/extract.ts | 11 +-- lib/modules/manager/maven/index.spec.ts | 1 - lib/modules/manager/maven/update.spec.ts | 1 - lib/modules/manager/maven/update.ts | 3 +- lib/modules/manager/metadata.spec.ts | 1 - lib/modules/manager/mix/artifacts.spec.ts | 1 - .../manager/npm/extract/locked-versions.ts | 7 +- lib/modules/manager/npm/extract/monorepo.ts | 15 ++-- lib/modules/manager/npm/extract/pnpm.ts | 3 +- lib/modules/manager/npm/post-update/index.ts | 52 ++++++------- lib/modules/manager/npm/post-update/lerna.ts | 2 +- lib/modules/manager/npm/post-update/npm.ts | 10 +-- lib/modules/manager/npm/range.ts | 2 +- .../npm/update/dependency/index.spec.ts | 1 - .../manager/npm/update/dependency/index.ts | 11 +-- .../update/locked-dependency/index.spec.ts | 1 - .../locked-dependency/package-lock/index.ts | 13 ++-- .../locked-dependency/yarn-lock/index.ts | 6 +- lib/modules/manager/npm/utils.spec.ts | 1 - lib/modules/manager/nuget/extract.ts | 10 +-- lib/modules/manager/nuget/package-tree.ts | 1 - .../manager/pip_requirements/extract.ts | 5 +- lib/modules/manager/pip_setup/extract.ts | 2 +- lib/modules/manager/pipenv/extract.ts | 6 +- .../manager/terraform/lockfile/index.ts | 6 +- .../manager/terraform/lockfile/util.ts | 12 ++- lib/modules/manager/terraform/modules.ts | 4 +- lib/modules/manager/terraform/providers.ts | 9 +-- .../manager/terraform/required-providers.ts | 6 +- lib/modules/manager/terraform/resources.ts | 6 +- lib/modules/manager/terraform/util.ts | 5 +- lib/modules/manager/terragrunt/extract.ts | 2 +- lib/modules/manager/terragrunt/modules.ts | 4 +- .../platform/azure/azure-got-wrapper.ts | 3 +- lib/modules/platform/azure/azure-helper.ts | 7 +- lib/modules/platform/azure/index.ts | 53 ++++++------- lib/modules/platform/azure/util.ts | 5 +- .../platform/bitbucket-server/index.ts | 15 ++-- .../platform/bitbucket-server/utils.ts | 2 +- lib/modules/platform/bitbucket/index.ts | 16 ++-- lib/modules/platform/gitea/index.ts | 29 ++++--- lib/modules/platform/github/index.ts | 76 +++++++++---------- lib/modules/platform/gitlab/index.ts | 23 +++--- lib/modules/platform/index.ts | 6 +- lib/modules/versioning/npm/range.ts | 5 +- lib/workers/global/index.ts | 1 - .../config-migration/branch/migrated-data.ts | 1 - .../repository/config-migration/pr/index.ts | 2 +- .../repository/dependency-dashboard.spec.ts | 1 - .../repository/dependency-dashboard.ts | 12 +-- lib/workers/repository/error-config.ts | 2 +- lib/workers/repository/errors-warnings.ts | 2 +- lib/workers/repository/extract/file-match.ts | 6 +- lib/workers/repository/finalise/prune.ts | 2 +- lib/workers/repository/index.ts | 2 +- lib/workers/repository/init/apis.ts | 8 +- lib/workers/repository/init/merge.ts | 2 +- .../repository/init/vulnerability.spec.ts | 4 +- lib/workers/repository/init/vulnerability.ts | 3 +- .../repository/onboarding/branch/check.ts | 3 +- .../repository/onboarding/branch/config.ts | 2 +- .../repository/onboarding/branch/create.ts | 4 +- .../onboarding/branch/index.spec.ts | 4 +- .../repository/onboarding/branch/index.ts | 4 +- .../repository/onboarding/branch/rebase.ts | 4 +- .../onboarding/pr/config-description.ts | 2 +- lib/workers/repository/onboarding/pr/index.ts | 4 +- .../repository/onboarding/pr/pr-list.ts | 3 +- lib/workers/repository/process/deprecated.ts | 2 +- .../repository/process/extract-update.ts | 2 +- lib/workers/repository/process/fetch.ts | 2 +- lib/workers/repository/process/index.ts | 2 +- lib/workers/repository/process/limits.ts | 2 +- .../process/lookup/filter-checks.ts | 14 ++-- .../repository/process/lookup/filter.ts | 2 +- .../repository/process/lookup/generate.ts | 4 +- .../repository/process/lookup/index.ts | 55 ++++++-------- .../repository/process/lookup/rollback.ts | 6 +- lib/workers/repository/process/sort.ts | 4 +- .../repository/process/vulnerabilities.ts | 2 +- .../update/branch/auto-replace.spec.ts | 1 - .../repository/update/branch/auto-replace.ts | 2 +- .../repository/update/branch/automerge.ts | 2 +- .../update/branch/check-existing.ts | 2 +- .../repository/update/branch/commit.spec.ts | 1 - .../repository/update/branch/commit.ts | 2 +- .../branch/execute-post-upgrade-commands.ts | 2 +- .../update/branch/handle-existing.ts | 2 +- lib/workers/repository/update/branch/index.ts | 6 +- lib/workers/repository/update/branch/reuse.ts | 2 +- lib/workers/repository/update/pr/automerge.ts | 2 +- .../update/pr/changelog/github/index.ts | 2 +- .../update/pr/changelog/gitlab/index.ts | 2 +- .../update/pr/changelog/release-notes.ts | 2 +- .../update/pr/changelog/releases.ts | 2 +- .../update/pr/changelog/source-github.ts | 2 +- .../update/pr/changelog/source-gitlab.ts | 2 +- lib/workers/repository/updates/branch-name.ts | 10 +-- lib/workers/repository/updates/branchify.ts | 2 +- package.json | 4 +- tsconfig.app.json | 1 - tsconfig.json | 4 +- tsconfig.strict.json | 3 +- 146 files changed, 341 insertions(+), 474 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ffb596076a199d..72f2ce598f782b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -95,7 +95,7 @@ module.exports = { }, ], '@typescript-eslint/prefer-optional-chain': 2, - '@typescript-eslint/prefer-nullish-coalescing': 2, + '@typescript-eslint/prefer-nullish-coalescing': 1, // TODO: Temporary (#7154) curly: [2, 'all'], 'require-await': 2, // next 2 rules disabled due to https://github.com/microsoft/TypeScript/issues/20024 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 36a12865108123..2999333f1997e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -137,8 +137,8 @@ jobs: - name: Type check run: yarn type-check - - name: Null check - run: yarn null-check + - name: Strict check + run: yarn strict-check release: needs: [lint, test] diff --git a/lib/config/migration.ts b/lib/config/migration.ts index 88cbae7d3e636b..ace62ce9ff50e1 100644 --- a/lib/config/migration.ts +++ b/lib/config/migration.ts @@ -155,13 +155,10 @@ export function migrateConfig(config: RenovateConfig): MigratedConfig { migratedConfig[key] = String(val[0]); } else if (key === 'node' && (val as RenovateConfig).enabled === true) { // validated non-null - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion delete migratedConfig.node!.enabled; migratedConfig.travis = migratedConfig.travis ?? {}; migratedConfig.travis.enabled = true; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion if (Object.keys(migratedConfig.node!).length) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const subMigrate = migrateConfig(migratedConfig.node!); migratedConfig.node = subMigrate.migratedConfig; } else { diff --git a/lib/config/options/index.spec.ts b/lib/config/options/index.spec.ts index 27277a8b0222e6..ddfc1b2f5e9191 100644 --- a/lib/config/options/index.spec.ts +++ b/lib/config/options/index.spec.ts @@ -23,7 +23,6 @@ describe('config/options/index', () => { .filter((option) => option.supportedManagers) .forEach((option) => { expect(option.supportedManagers).toBeNonEmptyArray(); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (const item of option.supportedManagers!) { expect(managerList).toContain(item); } @@ -39,7 +38,6 @@ describe('config/options/index', () => { .filter((option) => option.supportedPlatforms) .forEach((option) => { expect(option.supportedPlatforms).toBeNonEmptyArray(); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (const item of option.supportedPlatforms!) { expect(platformList).toContain(item); } diff --git a/lib/config/presets/gitea/index.ts b/lib/config/presets/gitea/index.ts index 6bf1ed6106f561..91c80ef522613a 100644 --- a/lib/config/presets/gitea/index.ts +++ b/lib/config/presets/gitea/index.ts @@ -34,7 +34,6 @@ export async function fetchJSONFile( } // TODO: null check #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion return parsePreset(fromBase64(res.content!)); } diff --git a/lib/config/presets/index.spec.ts b/lib/config/presets/index.spec.ts index d6a562dbfe7d32..64290cf42174ef 100644 --- a/lib/config/presets/index.spec.ts +++ b/lib/config/presets/index.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { Fixtures } from '../../../test/fixtures'; import { mocked } from '../../../test/util'; import type { RenovateConfig } from '../types'; diff --git a/lib/config/presets/local/common.ts b/lib/config/presets/local/common.ts index 9e6823bac27624..3271595554cb9c 100644 --- a/lib/config/presets/local/common.ts +++ b/lib/config/presets/local/common.ts @@ -27,7 +27,6 @@ export async function fetchJSONFile( } // TODO: null check #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion return parsePreset(raw!); } diff --git a/lib/config/presets/local/index.ts b/lib/config/presets/local/index.ts index 6b951eeea3e5fd..4703b51c5e00db 100644 --- a/lib/config/presets/local/index.ts +++ b/lib/config/presets/local/index.ts @@ -39,7 +39,6 @@ export function getPreset({ presetName, presetPath, // TODO: fix type #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion endpoint!, tag ); diff --git a/lib/config/presets/npm/index.ts b/lib/config/presets/npm/index.ts index 4cff9788cbbf96..28b2b3253cc6d4 100644 --- a/lib/config/presets/npm/index.ts +++ b/lib/config/presets/npm/index.ts @@ -35,7 +35,6 @@ export async function getPreset({ } const body = (await http.getJson(packageUrl)).body; // TODO: check null #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion dep = body.versions![body['dist-tags']!.latest]; } catch (err) { throw new Error(PRESET_DEP_NOT_FOUND); diff --git a/lib/config/validation.ts b/lib/config/validation.ts index 23be22ec6a7055..92209fc4f7788f 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -320,7 +320,6 @@ export async function validateConfig( if (key === 'packageRules') { for (const [subIndex, packageRule] of val.entries()) { if (is.object(packageRule)) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const resolvedRule = migrateConfig({ packageRules: [ await resolveConfigPresets( @@ -505,7 +504,6 @@ export async function validateConfig( if ( (selectors.includes(key) || key === 'matchCurrentVersion') && // TODO: can be undefined ? #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion !rulesRe.test(parentPath!) && // Inside a packageRule (parentPath || !isPreset) // top level in a preset ) { diff --git a/lib/modules/datasource/crate/index.ts b/lib/modules/datasource/crate/index.ts index f03476ef209e17..6e62d59f765470 100644 --- a/lib/modules/datasource/crate/index.ts +++ b/lib/modules/datasource/crate/index.ts @@ -267,7 +267,6 @@ export class CrateDatasource extends Datasource { const clonePathPromise: Promise | null = memCache.get(cacheKey); let clonePath: string; - // eslint-disable-next-line @typescript-eslint/no-misused-promises if (clonePathPromise) { clonePath = await clonePathPromise; } else { diff --git a/lib/modules/datasource/docker/index.ts b/lib/modules/datasource/docker/index.ts index c03122762d250d..c258891cda89a4 100644 --- a/lib/modules/datasource/docker/index.ts +++ b/lib/modules/datasource/docker/index.ts @@ -159,7 +159,7 @@ export async function getAuthHeaders( ) ).body; - const token = authResponse.token || authResponse.access_token; + const token = authResponse.token ?? authResponse.access_token; // istanbul ignore if if (!token) { logger.warn('Failed to obtain docker registry token'); @@ -512,7 +512,7 @@ export class DockerDatasource extends Datasource { manifest.mediaType === MediaType.ociManifestIndexV1 || (!manifest.mediaType && hasKey('manifests', manifest)) ) { - const imageList = manifest as OciImageList; + const imageList = manifest; if (imageList.manifests.length) { logger.trace( { registry, dockerRepository, tag }, @@ -812,10 +812,9 @@ export class DockerDatasource extends Datasource { { registryUrl, packageName }: GetReleasesConfig, newValue?: string ) => { - const newTag = newValue || 'latest'; + const newTag = newValue ?? 'latest'; const { registryHost, dockerRepository } = getRegistryRepository( packageName, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion registryUrl! ); return `${registryHost}:${dockerRepository}:${newTag}`; @@ -827,13 +826,12 @@ export class DockerDatasource extends Datasource { ): Promise { const { registryHost, dockerRepository } = getRegistryRepository( packageName, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion registryUrl! ); logger.debug( `getDigest(${registryHost}, ${dockerRepository}, ${newValue})` ); - const newTag = newValue || 'latest'; + const newTag = newValue ?? 'latest'; let digest: string | null = null; try { let manifestResponse = await this.getManifestResponse( @@ -857,7 +855,6 @@ export class DockerDatasource extends Datasource { dockerRepository, newTag ); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion digest = extractDigestFromResponseBody(manifestResponse!); } logger.debug({ digest }, 'Got docker digest'); @@ -895,7 +892,6 @@ export class DockerDatasource extends Datasource { }: GetReleasesConfig): Promise { const { registryHost, dockerRepository } = getRegistryRepository( packageName, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion registryUrl! ); const tags = await this.getTags(registryHost, dockerRepository); diff --git a/lib/modules/datasource/galaxy/index.ts b/lib/modules/datasource/galaxy/index.ts index 3b9908b90c082b..2d5d7aa1f89d54 100644 --- a/lib/modules/datasource/galaxy/index.ts +++ b/lib/modules/datasource/galaxy/index.ts @@ -29,13 +29,8 @@ export class GalaxyDatasource extends Datasource { const userName = lookUp[0]; const projectName = lookUp[1]; - const galaxyAPIUrl = - registryUrl + - 'api/v1/roles/?owner__username=' + - userName + - '&name=' + - projectName; - const galaxyProjectUrl = registryUrl + userName + '/' + projectName; + const galaxyAPIUrl = `${registryUrl}api/v1/roles/?owner__username=${userName}&name=${projectName}`; + const galaxyProjectUrl = `${registryUrl}${userName}/${projectName}`; let raw: HttpResponse | null = null; try { diff --git a/lib/modules/datasource/github-tags/index.ts b/lib/modules/datasource/github-tags/index.ts index 6b0ccdff0879dc..b6990fea04f9a3 100644 --- a/lib/modules/datasource/github-tags/index.ts +++ b/lib/modules/datasource/github-tags/index.ts @@ -74,10 +74,8 @@ export class GithubTagsDatasource extends GithubReleasesDatasource { newValue?: string ): Promise { return newValue - ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - this.getTagCommit(registryUrl, repo!, newValue) - : // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - this.getCommit(registryUrl, repo!); + ? this.getTagCommit(registryUrl, repo!, newValue) + : this.getCommit(registryUrl, repo!); } override async getReleases( diff --git a/lib/modules/datasource/gitlab-tags/index.ts b/lib/modules/datasource/gitlab-tags/index.ts index bb9185f7a5eb61..c80b9b4911530f 100644 --- a/lib/modules/datasource/gitlab-tags/index.ts +++ b/lib/modules/datasource/gitlab-tags/index.ts @@ -75,7 +75,6 @@ export class GitlabTagsDatasource extends Datasource { ): Promise { const depHost = getDepHost(registryUrl); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const urlEncodedRepo = encodeURIComponent(repo!); let digest: string | null = null; diff --git a/lib/modules/datasource/index.spec.ts b/lib/modules/datasource/index.spec.ts index 1463e98cd00769..1cbf25a0bc5818 100644 --- a/lib/modules/datasource/index.spec.ts +++ b/lib/modules/datasource/index.spec.ts @@ -1,5 +1,3 @@ -/* fixme #7154 */ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import fs from 'fs-extra'; import { logger } from '../../../test/util'; import { diff --git a/lib/modules/datasource/index.ts b/lib/modules/datasource/index.ts index ece88626ad2201..2baaeb7f35973b 100644 --- a/lib/modules/datasource/index.ts +++ b/lib/modules/datasource/index.ts @@ -236,7 +236,7 @@ export function getDefaultVersioning(datasourceName: string): string { if (!datasource) { logger.warn({ datasourceName }, 'Missing datasource!'); } - return datasource?.defaultVersioning || 'semver'; + return datasource?.defaultVersioning ?? 'semver'; } function applyReplacements( @@ -281,7 +281,7 @@ async function fetchReleases( config.additionalRegistryUrls ); let dep: ReleaseResult | null = null; - const registryStrategy = datasource.registryStrategy || 'hunt'; + const registryStrategy = datasource.registryStrategy ?? 'hunt'; try { if (is.nonEmptyArray(registryUrls)) { if (registryStrategy === 'first') { @@ -336,7 +336,7 @@ export async function getPkgReleases( logger.warn('No datasource found'); return null; } - const packageName = config.packageName || config.depName; + const packageName = config.packageName ?? config.depName; if (!packageName) { logger.error({ config }, 'Datasource getReleases without packageName'); return null; @@ -374,7 +374,7 @@ export async function getPkgReleases( } // Use the datasource's default versioning if none is configured const versioning = - config.versioning || getDefaultVersioning(config.datasource); + config.versioning ?? getDefaultVersioning(config.datasource); const version = allVersioning.get(versioning); // Filter and sort valid versions @@ -391,7 +391,7 @@ export async function getPkgReleases( ); // Filter releases for compatibility for (const [constraintName, constraintValue] of Object.entries( - config.constraints || {} + config.constraints ?? {} )) { // Currently we only support if the constraint is a plain version // TODO: Support range/range compatibility filtering #8476 @@ -448,7 +448,6 @@ export function getDigest( return Promise.resolve(null); } const digestConfig = getDigestConfig(datasource, config); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion return datasource.getDigest!(digestConfig, value); } @@ -457,6 +456,6 @@ export function getDefaultConfig( ): Promise> { const loadedDatasource = getDatasourceFor(datasource); return Promise.resolve>( - loadedDatasource?.defaultConfig || Object.create({}) + loadedDatasource?.defaultConfig ?? Object.create({}) ); } diff --git a/lib/modules/datasource/npm/npmrc.ts b/lib/modules/datasource/npm/npmrc.ts index fccb2d7fd4d6a8..5c9354b3fd8878 100644 --- a/lib/modules/datasource/npm/npmrc.ts +++ b/lib/modules/datasource/npm/npmrc.ts @@ -174,7 +174,6 @@ export function resolveRegistryUrl(packageName: string): string { packageName.startsWith(matchPackagePrefixes[0]) ) { // TODO: fix types #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion registryUrl = registryUrls![0]; } } diff --git a/lib/modules/datasource/packagist/index.ts b/lib/modules/datasource/packagist/index.ts index 3f218ad3712074..48a947215bb221 100644 --- a/lib/modules/datasource/packagist/index.ts +++ b/lib/modules/datasource/packagist/index.ts @@ -274,7 +274,6 @@ export class PackagistDatasource extends Datasource { if (name in providerPackages) { pkgUrl = URL.resolve( regUrl, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion providersUrl! .replace('%package%', name) .replace('%hash%', providerPackages[name]) diff --git a/lib/modules/datasource/rubygems/get-rubygems-org.ts b/lib/modules/datasource/rubygems/get-rubygems-org.ts index e8c26257d95b2a..7e416fa94f1800 100644 --- a/lib/modules/datasource/rubygems/get-rubygems-org.ts +++ b/lib/modules/datasource/rubygems/get-rubygems-org.ts @@ -119,8 +119,7 @@ export class RubyGemsOrgDatasource extends Datasource { async syncVersions(): Promise { if (RubyGemsOrgDatasource.isDataStale()) { this.updateRubyGemsVersionsPromise = - // eslint-disable-next-line @typescript-eslint/no-misused-promises - this.updateRubyGemsVersionsPromise || this.updateRubyGemsVersions(); + this.updateRubyGemsVersionsPromise ?? this.updateRubyGemsVersions(); await this.updateRubyGemsVersionsPromise; this.updateRubyGemsVersionsPromise = null; } diff --git a/lib/modules/manager/batect-wrapper/artifacts.ts b/lib/modules/manager/batect-wrapper/artifacts.ts index 70ed746392f8f5..d8b70c64cfee8b 100644 --- a/lib/modules/manager/batect-wrapper/artifacts.ts +++ b/lib/modules/manager/batect-wrapper/artifacts.ts @@ -34,7 +34,6 @@ export async function updateArtifacts({ packageFileName, config, }: UpdateArtifact): Promise { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const version = config.newVersion!; logger.debug({ version, packageFileName }, 'Updating Batect wrapper scripts'); diff --git a/lib/modules/manager/batect/extract.spec.ts b/lib/modules/manager/batect/extract.spec.ts index 3cc1f50465445f..e36c85ece5e344 100644 --- a/lib/modules/manager/batect/extract.spec.ts +++ b/lib/modules/manager/batect/extract.spec.ts @@ -78,7 +78,6 @@ describe('modules/manager/batect/extract', () => { // TODO: #7154 expect( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion result?.sort((a, b) => a.packageFile!.localeCompare(b.packageFile!)) ).toEqual([ { diff --git a/lib/modules/manager/batect/extract.ts b/lib/modules/manager/batect/extract.ts index 4b957d12ead904..dea4284291e9f2 100644 --- a/lib/modules/manager/batect/extract.ts +++ b/lib/modules/manager/batect/extract.ts @@ -161,7 +161,6 @@ export async function extractAllPackageFiles( const content = await readLocalFile(packageFile, 'utf8'); // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const result = extractPackageFile(content!, packageFile); if (result !== null) { diff --git a/lib/modules/manager/composer/extract.ts b/lib/modules/manager/composer/extract.ts index 021c89fa510e93..06c6838dd3afa3 100644 --- a/lib/modules/manager/composer/extract.ts +++ b/lib/modules/manager/composer/extract.ts @@ -45,7 +45,6 @@ function parseRepositories( switch (repo.type) { case 'vcs': case 'git': - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion repositories[name!] = repo; break; case 'composer': diff --git a/lib/modules/manager/composer/update-locked.ts b/lib/modules/manager/composer/update-locked.ts index 186f54d80f81a2..9187bfb1ebe2b0 100644 --- a/lib/modules/manager/composer/update-locked.ts +++ b/lib/modules/manager/composer/update-locked.ts @@ -12,7 +12,6 @@ export function updateLockedDependency( `composer.updateLockedDependency: ${depName}@${currentVersion} -> ${newVersion} [${lockFile}]` ); try { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const locked = JSON.parse(lockFileContent!) as ComposerLock; if ( locked.packages?.find( diff --git a/lib/modules/manager/composer/utils.ts b/lib/modules/manager/composer/utils.ts index 6787845ebf650d..92c5eecf26ec49 100644 --- a/lib/modules/manager/composer/utils.ts +++ b/lib/modules/manager/composer/utils.ts @@ -18,10 +18,8 @@ export function getComposerArguments( if (config.composerIgnorePlatformReqs) { if (config.composerIgnorePlatformReqs.length === 0) { - // TODO: toolConstraint.constraint can be null or undefined? - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: toolConstraint.constraint can be null or undefined? (#7154) const major = api.getMajor(toolConstraint.constraint!); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const minor = api.getMinor(toolConstraint.constraint!); args += api.matches(`${major}.${minor}`, '^2.2') ? " --ignore-platform-req='ext-*' --ignore-platform-req='lib-*'" diff --git a/lib/modules/manager/flux/extract.ts b/lib/modules/manager/flux/extract.ts index 52f0ec7eb3e3d1..8d07678ece319c 100644 --- a/lib/modules/manager/flux/extract.ts +++ b/lib/modules/manager/flux/extract.ts @@ -141,7 +141,6 @@ export async function extractAllPackageFiles( for (const file of packageFiles) { const content = await readLocalFile(file, 'utf8'); // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const manifest = readManifest(content!, file); if (manifest) { manifests.push(manifest); diff --git a/lib/modules/manager/git-submodules/artifacts.ts b/lib/modules/manager/git-submodules/artifacts.ts index 1a85a0b97ed484..f77865f0c4d928 100644 --- a/lib/modules/manager/git-submodules/artifacts.ts +++ b/lib/modules/manager/git-submodules/artifacts.ts @@ -6,9 +6,8 @@ export default function updateArtifacts({ }: UpdateArtifact): UpdateArtifactsResult[] | null { const res: UpdateArtifactsResult[] = []; updatedDeps.forEach((dep) => { - logger.info('Updating submodule ' + dep.depName); + logger.info(`Updating submodule ${dep.depName}`); res.push({ - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion file: { type: 'addition', path: dep.depName!, contents: '' }, }); }); diff --git a/lib/modules/manager/git-submodules/update.ts b/lib/modules/manager/git-submodules/update.ts index 6639a01f7ace1f..613cc6c1186c18 100644 --- a/lib/modules/manager/git-submodules/update.ts +++ b/lib/modules/manager/git-submodules/update.ts @@ -13,9 +13,7 @@ export default async function updateDependency({ const submoduleGit = Git(upath.join(localDir, upgrade.depName)); try { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion await git.submoduleUpdate(['--init', upgrade.depName!]); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion await submoduleGit.checkout([upgrade.newDigest!]); return fileContent; } catch (err) { diff --git a/lib/modules/manager/gitlabci/extract.spec.ts b/lib/modules/manager/gitlabci/extract.spec.ts index fb66a99062ed8d..a45d88a1aa2ab9 100644 --- a/lib/modules/manager/gitlabci/extract.spec.ts +++ b/lib/modules/manager/gitlabci/extract.spec.ts @@ -87,7 +87,6 @@ describe('modules/manager/gitlabci/extract', () => { expect(deps).toHaveLength(8); // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion expect(deps.some((dep) => dep.currentValue!.includes("'"))).toBeFalse(); }); diff --git a/lib/modules/manager/gitlabci/utils.ts b/lib/modules/manager/gitlabci/utils.ts index 39b30691354692..40f33bf47bc6f0 100644 --- a/lib/modules/manager/gitlabci/utils.ts +++ b/lib/modules/manager/gitlabci/utils.ts @@ -28,8 +28,8 @@ export function getGitlabDep(imageName: string): PackageDependency { const match = depProxyRe.exec(imageName); if (match?.groups) { const dep = { ...getDep(match.groups.depName), replaceString: imageName }; - dep.autoReplaceStringTemplate = - match.groups.prefix + dep.autoReplaceStringTemplate; + // TODO: #7154 + dep.autoReplaceStringTemplate = `${match.groups.prefix}${dep.autoReplaceStringTemplate}`; return dep; } else { return getDep(imageName); diff --git a/lib/modules/manager/gomod/artifacts.ts b/lib/modules/manager/gomod/artifacts.ts index 2b6dc742b65e1f..4b41ccfabafe2f 100644 --- a/lib/modules/manager/gomod/artifacts.ts +++ b/lib/modules/manager/gomod/artifacts.ts @@ -69,7 +69,6 @@ function getGitEnvironmentVariables(): NodeJS.ProcessEnv { `Adding Git authentication for Go Module retrieval for ${httpUrl} using token auth.` ); environmentVariables = getGitAuthenticatedEnvironmentVariables( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion httpUrl!, hostRule, environmentVariables @@ -89,7 +88,6 @@ function getUpdateImportPathCmds( { constraints, newMajor }: UpdateArtifactsConfig ): string[] { const updateImportCommands = updatedDeps - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion .map((dep) => dep.depName!) .filter((x) => !x.startsWith('gopkg.in')) .map((depName) => `mod upgrade --mod-name=${depName} -t=${newMajor}`); @@ -246,7 +244,6 @@ export async function updateArtifacts({ const isImportPathUpdateRequired = config.postUpdateOptions?.includes('gomodUpdateImportPaths') && config.updateType === 'major' && - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion config.newMajor! > 1; if (isImportPathUpdateRequired) { const updateImportCmds = getUpdateImportPathCmds(updatedDeps, config); diff --git a/lib/modules/manager/gomod/extract.ts b/lib/modules/manager/gomod/extract.ts index 97f78f62c402f9..8d91306a1d0246 100644 --- a/lib/modules/manager/gomod/extract.ts +++ b/lib/modules/manager/gomod/extract.ts @@ -71,7 +71,6 @@ export function extractPackageFile(content: string): PackageFile | null { if (multiMatch && !line.endsWith('// indirect')) { logger.trace({ lineNumber }, `require line: "${line}"`); const dep = getDep(lineNumber, multiMatch, 'require'); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion dep.managerData!.multiLine = true; deps.push(dep); } else if (line.trim() !== ')') { diff --git a/lib/modules/manager/gomod/update.spec.ts b/lib/modules/manager/gomod/update.spec.ts index fcb98a41470ca5..63e2d1fe34f63b 100644 --- a/lib/modules/manager/gomod/update.spec.ts +++ b/lib/modules/manager/gomod/update.spec.ts @@ -40,7 +40,6 @@ describe('modules/manager/gomod/update', () => { depType: 'require', }; const res2 = updateDependency({ - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion fileContent: res1!, upgrade: upgrade2, }); diff --git a/lib/modules/manager/gomod/update.ts b/lib/modules/manager/gomod/update.ts index e6eb87ed572fe1..693cd45d4bd6ca 100644 --- a/lib/modules/manager/gomod/update.ts +++ b/lib/modules/manager/gomod/update.ts @@ -58,10 +58,8 @@ export function updateDependency({ } let newLine: string; if (upgrade.updateType === 'digest') { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const newDigestRightSized = upgrade.newDigest!.substring( 0, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion upgrade.currentDigest!.length ); if (lineToChange.includes(newDigestRightSized)) { @@ -72,15 +70,13 @@ export function updateDependency({ 'gomod: need to update digest' ); newLine = lineToChange.replace( - // TODO: can be undefined? - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: can be undefined? (#7154) updateLineExp!, `$$${newDigestRightSized}` ); } else { newLine = lineToChange.replace( - // TODO: can be undefined? - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: can be undefined? (#7154) updateLineExp!, `$$${upgrade.newValue}` ); @@ -96,7 +92,6 @@ export function updateDependency({ 'rethinkdb/rethinkdb-go.v5' ); } else if ( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion upgrade.newMajor! > 1 && !newLine.includes(`/v${upgrade.newMajor}`) ) { @@ -105,7 +100,6 @@ export function updateDependency({ newLine = newLine.replace(depName, `${depName}/v${upgrade.newMajor}`); } else { // Replace version - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const [oldV] = upgrade.currentValue!.split('.'); newLine = newLine.replace( regEx(`/${oldV}(\\s+)`, undefined, false), @@ -117,7 +111,6 @@ export function updateDependency({ if (lineToChange.endsWith('+incompatible')) { let toAdd = '+incompatible'; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion if (upgrade.updateType === 'major' && upgrade.newMajor! >= 2) { toAdd = ''; } diff --git a/lib/modules/manager/gradle-wrapper/artifacts-real.spec.ts b/lib/modules/manager/gradle-wrapper/artifacts-real.spec.ts index 7f065643807a3a..f99fa0851f3e15 100644 --- a/lib/modules/manager/gradle-wrapper/artifacts-real.spec.ts +++ b/lib/modules/manager/gradle-wrapper/artifacts-real.spec.ts @@ -247,7 +247,6 @@ describe('modules/manager/gradle-wrapper/artifacts-real', () => { expect( await readString( // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion adminConfig.localDir!, `gradle/wrapper/gradle-wrapper.properties` ) diff --git a/lib/modules/manager/gradle-wrapper/artifacts.ts b/lib/modules/manager/gradle-wrapper/artifacts.ts index 3fba527ee385ec..d3da5a3d55dcd3 100644 --- a/lib/modules/manager/gradle-wrapper/artifacts.ts +++ b/lib/modules/manager/gradle-wrapper/artifacts.ts @@ -68,7 +68,6 @@ export async function updateArtifacts({ const gradlewPath = upath.resolve(projectDir, `./${gradlew}`); let cmd = await prepareGradleCommand( gradlew, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion projectDir!, await stat(gradlewPath).catch(() => null), `wrapper` @@ -93,7 +92,6 @@ export async function updateArtifacts({ cmd += ` --gradle-distribution-sha256-sum ${quote(checksum)}`; } } else { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion cmd += ` --gradle-version ${quote(config.newValue!)}`; } logger.debug(`Updating gradle wrapper: "${cmd}"`); @@ -101,7 +99,6 @@ export async function updateArtifacts({ docker: { image: 'java', tagConstraint: - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion config.constraints?.java ?? getJavaContraint(config.currentValue!), tagScheme: getJavaVersioning(), }, diff --git a/lib/modules/manager/gradle/parser.spec.ts b/lib/modules/manager/gradle/parser.spec.ts index e518d26c857188..779d9bf10a0c43 100644 --- a/lib/modules/manager/gradle/parser.spec.ts +++ b/lib/modules/manager/gradle/parser.spec.ts @@ -141,7 +141,6 @@ describe('modules/manager/gradle/parser', () => { const [res] = deps; const idx = content // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion .slice(res.managerData!.fileReplacePosition) .indexOf('1.2.3'); expect(idx).toBe(0); @@ -152,7 +151,6 @@ describe('modules/manager/gradle/parser', () => { const { deps } = parseGradle(content, {}, 'build.gradle'); const replacementIndices = deps.map(({ managerData, currentValue }) => // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion content.slice(managerData!.fileReplacePosition).indexOf(currentValue!) ); expect(replacementIndices.every((idx) => idx === 0)).toBeTrue(); diff --git a/lib/modules/manager/gradle/parser.ts b/lib/modules/manager/gradle/parser.ts index dd4203223aa96b..cb33ef3c111c9d 100644 --- a/lib/modules/manager/gradle/parser.ts +++ b/lib/modules/manager/gradle/parser.ts @@ -120,7 +120,6 @@ function handleAssignment({ if (dep) { dep.groupName = key; dep.managerData = { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion fileReplacePosition: valToken.offset + dep.depName!.length + 1, packageFile, }; @@ -149,7 +148,6 @@ function processDepString({ const dep = parseDependencyString(token.value); if (dep) { dep.managerData = { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion fileReplacePosition: token.offset + dep.depName!.length + 1, packageFile, }; @@ -309,7 +307,6 @@ function processPredefinedRegistryUrl({ google: GOOGLE_REPO, gradlePluginPortal: GRADLE_PLUGIN_PORTAL_REPO, }[registryName]; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion return { urls: [registryUrl!] }; } @@ -959,7 +956,6 @@ export function parseProps( ...dep, managerData: { fileReplacePosition: - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion offset + leftPart.length + dep.depName!.length + 1, packageFile, }, diff --git a/lib/modules/manager/gradle/update.ts b/lib/modules/manager/gradle/update.ts index 02629ca4e5c729..3b8cf531eb8605 100644 --- a/lib/modules/manager/gradle/update.ts +++ b/lib/modules/manager/gradle/update.ts @@ -12,7 +12,7 @@ export function updateDependency({ logger.warn('gradle manager does not support replacement updates yet'); return null; } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO check null (#7154) const offset = managerData!.fileReplacePosition; const leftPart = fileContent.slice(0, offset); const rightPart = fileContent.slice(offset); @@ -24,7 +24,7 @@ export function updateDependency({ return fileContent; } if (version === currentValue || upgrade.groupName) { - return leftPart + newValue + restPart; + return `${leftPart}${newValue}${restPart}`; } logger.debug({ depName, version, currentValue, newValue }, 'Unknown value'); } else { diff --git a/lib/modules/manager/helmv3/extract.ts b/lib/modules/manager/helmv3/extract.ts index 4a6f32a44ac0b3..c525c8a787620e 100644 --- a/lib/modules/manager/helmv3/extract.ts +++ b/lib/modules/manager/helmv3/extract.ts @@ -61,7 +61,6 @@ export async function extractPackageFile( return res; } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const repository = resolveAlias(dep.repository, config.registryAliases!); if (!repository) { res.skipReason = 'placeholder-url'; diff --git a/lib/modules/manager/index.spec.ts b/lib/modules/manager/index.spec.ts index 914b2288e082c0..720a49b0e745da 100644 --- a/lib/modules/manager/index.spec.ts +++ b/lib/modules/manager/index.spec.ts @@ -18,7 +18,6 @@ describe('modules/manager/index', () => { it(`has valid supportedDatasources for ${m}`, () => { expect(supportedDatasources).toBeNonEmptyArray(); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion supportedDatasources!.every((d) => { expect(datasources.includes(d)).toBeTrue(); }); diff --git a/lib/modules/manager/jsonnet-bundler/artifacts.ts b/lib/modules/manager/jsonnet-bundler/artifacts.ts index 703347bba2d46f..77551f708ad6b0 100644 --- a/lib/modules/manager/jsonnet-bundler/artifacts.ts +++ b/lib/modules/manager/jsonnet-bundler/artifacts.ts @@ -13,7 +13,6 @@ import type { } from '../types'; function dependencyUrl(dep: PackageDependency): string { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const url = dep.packageName!; if (dep.managerData?.subdir) { return url.concat('/', dep.managerData.subdir); diff --git a/lib/modules/manager/maven/extract.ts b/lib/modules/manager/maven/extract.ts index 5f80d4bdb2ae12..f7e95756969a94 100644 --- a/lib/modules/manager/maven/extract.ts +++ b/lib/modules/manager/maven/extract.ts @@ -178,15 +178,12 @@ function applyPropsInternal( return substr; }); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const depName = replaceAll(dep.depName!); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const registryUrls = dep.registryUrls!.map((url) => replaceAll(url)); let fileReplacePosition = dep.fileReplacePosition; let propSource = dep.propSource; let groupName: string | null = null; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const currentValue = dep.currentValue!.replace( regEx(/^\${.*?}$/), (substr) => { @@ -289,7 +286,6 @@ export function extractPackage( } result.deps.forEach((dep) => { if (is.array(dep.registryUrls)) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion repoUrls.forEach((url) => dep.registryUrls!.push(url)); } }); @@ -297,7 +293,7 @@ export function extractPackage( if (packageFile && project.childNamed('parent')) { const parentPath = - project.valueWithPath('parent.relativePath')?.trim() || '../pom.xml'; + project.valueWithPath('parent.relativePath')?.trim() ?? '../pom.xml'; result.parent = resolveParentFile(packageFile, parentPath); } @@ -370,7 +366,6 @@ export function resolveParents(packages: PackageFile[]): PackageFile[] { const extractedProps: Record = {}; const registryUrls: Record> = {}; packages.forEach((pkg) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const name = pkg.packageFile!; packageFileNames.push(name); extractedPackages[name] = pkg; @@ -386,7 +381,6 @@ export function resolveParents(packages: PackageFile[]): PackageFile[] { const visitedPackages: Set = new Set(); let pkg: PackageFile | null = extractedPackages[name]; while (pkg) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion propsHierarchy.unshift(pkg.mavenProps!); if (pkg.deps) { @@ -414,7 +408,6 @@ export function resolveParents(packages: PackageFile[]): PackageFile[] { packageFileNames.forEach((name) => { const pkg = extractedPackages[name]; pkg.deps.forEach((rawDep) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const urlsSet = new Set([...rawDep.registryUrls!, ...registryUrls[name]]); rawDep.registryUrls = [...urlsSet]; }); @@ -425,7 +418,7 @@ export function resolveParents(packages: PackageFile[]): PackageFile[] { const pkg = extractedPackages[name]; pkg.deps.forEach((rawDep) => { const dep = applyProps(rawDep, name, extractedProps[name]); - const sourceName = dep.propSource || name; + const sourceName = dep.propSource ?? name; extractedDeps[sourceName].push(dep); }); }); diff --git a/lib/modules/manager/maven/index.spec.ts b/lib/modules/manager/maven/index.spec.ts index f397c0594f4dfc..ecffba19c17f96 100644 --- a/lib/modules/manager/maven/index.spec.ts +++ b/lib/modules/manager/maven/index.spec.ts @@ -1,5 +1,4 @@ // TODO #7154 -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { Fixtures } from '../../../../test/fixtures'; import { fs } from '../../../../test/util'; import type { PackageDependency, PackageFile } from '../types'; diff --git a/lib/modules/manager/maven/update.spec.ts b/lib/modules/manager/maven/update.spec.ts index 247b41d617587c..dbe881f8d9260b 100644 --- a/lib/modules/manager/maven/update.spec.ts +++ b/lib/modules/manager/maven/update.spec.ts @@ -1,5 +1,4 @@ // TODO #7154 -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { XmlDocument } from 'xmldoc'; import { Fixtures } from '../../../../test/fixtures'; import * as pomUpdater from '.'; diff --git a/lib/modules/manager/maven/update.ts b/lib/modules/manager/maven/update.ts index 0134ae9fee7b37..c76169b2cf9d73 100644 --- a/lib/modules/manager/maven/update.ts +++ b/lib/modules/manager/maven/update.ts @@ -24,8 +24,7 @@ export function updateAtPosition( return fileContent; } if (version === currentValue || upgrade.groupName) { - // TODO: validate newValue - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: validate newValue (#7154) const replacedPart = versionPart.replace(version, newValue!); return leftPart + replacedPart + restPart; } diff --git a/lib/modules/manager/metadata.spec.ts b/lib/modules/manager/metadata.spec.ts index 71a66590d8e9b2..ee0a675dd38414 100644 --- a/lib/modules/manager/metadata.spec.ts +++ b/lib/modules/manager/metadata.spec.ts @@ -16,7 +16,6 @@ describe('modules/manager/metadata', () => { // do nothing } expect(readme).toBeDefined(); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const lines = readme!.split('\n'); let isCode = false; const res: string[] = []; diff --git a/lib/modules/manager/mix/artifacts.spec.ts b/lib/modules/manager/mix/artifacts.spec.ts index 27f7dd88747aef..69ae7572973a53 100644 --- a/lib/modules/manager/mix/artifacts.spec.ts +++ b/lib/modules/manager/mix/artifacts.spec.ts @@ -132,7 +132,6 @@ describe('modules/manager/mix/artifacts', () => { expect(execSnapshots).toMatchSnapshot(); // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const [updateResult] = result!; expect(updateResult).toEqual({ file: { type: 'addition', path: 'mix.lock', contents: 'New mix.lock' }, diff --git a/lib/modules/manager/npm/extract/locked-versions.ts b/lib/modules/manager/npm/extract/locked-versions.ts index 3c1d9f1cac671f..b8d881027afef6 100644 --- a/lib/modules/manager/npm/extract/locked-versions.ts +++ b/lib/modules/manager/npm/extract/locked-versions.ts @@ -24,14 +24,11 @@ export async function getLockedVersions( if (!isYarn1 && !packageFile.constraints?.yarn) { if (lockfileVersion && lockfileVersion >= 8) { // https://github.com/yarnpkg/berry/commit/9bcd27ae34aee77a567dd104947407532fa179b3 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion packageFile.constraints!.yarn = '^3.0.0'; } else if (lockfileVersion && lockfileVersion >= 6) { // https://github.com/yarnpkg/berry/commit/f753790380cbda5b55d028ea84b199445129f9ba - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion packageFile.constraints!.yarn = '^2.2.0'; } else { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion packageFile.constraints!.yarn = '^2.0.0'; } } @@ -49,7 +46,7 @@ export async function getLockedVersions( } } } else if (npmLock) { - logger.debug('Found ' + npmLock + ' for ' + packageFile.packageFile); + logger.debug(`Found ${npmLock} for ${packageFile.packageFile}`); lockFiles.push(npmLock); if (!lockFileCache[npmLock]) { logger.trace('Retrieving/parsing ' + npmLock); @@ -63,13 +60,11 @@ export async function getLockedVersions( packageFile.constraints.npm += ' <7'; } } else { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion packageFile.constraints!.npm = '<7'; } } for (const dep of packageFile.deps) { dep.lockedVersion = semver.valid( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion lockFileCache[npmLock].lockedVersions[dep.depName!] ); } diff --git a/lib/modules/manager/npm/extract/monorepo.ts b/lib/modules/manager/npm/extract/monorepo.ts index 31581102b35876..fd4b497299056c 100644 --- a/lib/modules/manager/npm/extract/monorepo.ts +++ b/lib/modules/manager/npm/extract/monorepo.ts @@ -24,16 +24,13 @@ export async function detectMonorepos( } = p; const { lernaJsonFile, yarnZeroInstall, hasPackageManager } = managerData; - const packages = yarnWorkspacesPackages || lernaPackages; + const packages = yarnWorkspacesPackages ?? lernaPackages; if (packages?.length) { const internalPackagePatterns = ( is.array(packages) ? packages : [packages] - ) - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - .map((pattern) => getSiblingFileName(packageFile!, pattern)); + ).map((pattern) => getSiblingFileName(packageFile!, pattern)); const internalPackageFiles = packageFiles.filter((sp) => matchesAnyPattern( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion getSubDirectory(sp.packageFile!), internalPackagePatterns ) @@ -49,17 +46,17 @@ export async function detectMonorepos( }); for (const subPackage of internalPackageFiles) { - subPackage.managerData = subPackage.managerData || {}; + subPackage.managerData = subPackage.managerData ?? {}; subPackage.managerData.lernaJsonFile = lernaJsonFile; subPackage.managerData.yarnZeroInstall = yarnZeroInstall; subPackage.managerData.hasPackageManager = hasPackageManager; subPackage.lernaClient = lernaClient; - subPackage.yarnLock = subPackage.yarnLock || yarnLock; - subPackage.npmLock = subPackage.npmLock || npmLock; + subPackage.yarnLock = subPackage.yarnLock ?? yarnLock; + subPackage.npmLock = subPackage.npmLock ?? npmLock; subPackage.skipInstalls = skipInstalls && subPackage.skipInstalls; // skip if both are true if (subPackage.yarnLock) { subPackage.hasYarnWorkspaces = !!yarnWorkspacesPackages; - subPackage.npmrc = subPackage.npmrc || npmrc; + subPackage.npmrc = subPackage.npmrc ?? npmrc; } if (p.constraints) { diff --git a/lib/modules/manager/npm/extract/pnpm.ts b/lib/modules/manager/npm/extract/pnpm.ts index 844c405bb3eacb..99da51e7eb8850 100644 --- a/lib/modules/manager/npm/extract/pnpm.ts +++ b/lib/modules/manager/npm/extract/pnpm.ts @@ -92,7 +92,7 @@ export async function detectPnpmWorkspaces( } // search for corresponding pnpm workspace - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const pnpmWorkspace = await findPnpmWorkspace(packageFile!); if (pnpmWorkspace === null) { continue; @@ -115,7 +115,6 @@ export async function detectPnpmWorkspaces( const packagePaths = packagePathCache.get(workspaceYamlPath); const isPackageInWorkspace = packagePaths?.some((p) => - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion p.endsWith(packageFile!) ); diff --git a/lib/modules/manager/npm/post-update/index.ts b/lib/modules/manager/npm/post-update/index.ts index 51db6b2a29bb44..dbda105ca35218 100644 --- a/lib/modules/manager/npm/post-update/index.ts +++ b/lib/modules/manager/npm/post-update/index.ts @@ -84,7 +84,7 @@ export function determineLockFileDirs( function getPackageFile(fileName: string): Partial { logger.trace('Looking for packageFile: ' + fileName); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + for (const packageFile of packageFiles.npm!) { if (packageFile.packageFile === fileName) { logger.trace({ packageFile }, 'Found packageFile'); @@ -95,7 +95,7 @@ export function determineLockFileDirs( return {}; } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 for (const p of config.updatedPackageFiles!) { logger.trace(`Checking ${String(p.path)} for lock files`); const packageFile = getPackageFile(p.path); @@ -138,9 +138,8 @@ export async function writeExistingFiles( 'Writing package.json files' ); for (const packageFile of npmFiles) { - const basedir = - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - upath.dirname(packageFile.packageFile!); + // TODO #7154 + const basedir = upath.dirname(packageFile.packageFile!); const npmrc: string = packageFile.npmrc ?? config.npmrc; const npmrcFilename = upath.join(basedir, '.npmrc'); if (is.string(npmrc)) { @@ -182,7 +181,7 @@ export async function writeExistingFiles( upgrade.rangeStrategy === 'widen' && upgrade.npmLock === npmLock ) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 widens.push(upgrade.depName!); } const { depName } = upgrade; @@ -209,7 +208,7 @@ export async function writeExistingFiles( npmLockParsed.dependencies ) { widens.forEach((depName) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 delete npmLockParsed.dependencies![depName]; }); } @@ -258,7 +257,7 @@ export async function writeUpdatedPackageFiles( ) { logger.debug(`Writing lock file: ${packageFile.path}`); // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + await writeLocalFile(packageFile.path, packageFile.contents!); continue; } @@ -268,11 +267,11 @@ export async function writeUpdatedPackageFiles( logger.debug(`Writing ${packageFile.path}`); const detectedIndent = // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + detectIndent(packageFile.contents!.toString()).indent || ' '; // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + const massagedFile = JSON.parse(packageFile.contents!.toString()); try { const { token } = hostRules.find({ @@ -282,12 +281,10 @@ export async function writeUpdatedPackageFiles( for (const upgrade of config.upgrades) { // istanbul ignore if: test me if (upgrade.gitRef && upgrade.packageFile === packageFile.path) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion massagedFile[upgrade.depType as NpmDepType][upgrade.depName!] = - massagedFile[ - upgrade.depType as NpmDepType - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - ][upgrade.depName!].replace( + massagedFile[upgrade.depType as NpmDepType][ + upgrade.depName! + ].replace( 'git+https://github.com', `git+https://${token}@github.com` ); @@ -574,8 +571,8 @@ export async function getAdditionalFiles( updatedArtifacts.push({ type: 'addition', path: npmLock, - // TODO: can this be undefined? - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: can this be undefined? (#7154) + contents: res.lockFile!.replace(tokenRe, ''), }); } @@ -642,8 +639,7 @@ export async function getAdditionalFiles( } artifactErrors.push({ lockFile: yarnLock, - // TODO #7154 - + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing stderr: res.stderr || res.stdout, }); } else { @@ -658,8 +654,7 @@ export async function getAdditionalFiles( updatedArtifacts.push({ type: 'addition', path: lockFileName, - // - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 contents: res.lockFile!, }); await updateYarnOffline(lockFileDir, updatedArtifacts); @@ -677,7 +672,7 @@ export async function getAdditionalFiles( await resetNpmrcContent(lockFileDir, npmrcContent); // istanbul ignore if: needs test if (existingYarnrcYmlContent) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 await writeLocalFile(yarnRcYmlFilename!, existingYarnrcYmlContent); } } @@ -715,7 +710,7 @@ export async function getAdditionalFiles( } artifactErrors.push({ lockFile: pnpmShrinkwrap, - // TODO #7154 + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing stderr: res.stderr || res.stdout, }); } else { @@ -730,8 +725,7 @@ export async function getAdditionalFiles( updatedArtifacts.push({ type: 'addition', path: pnpmShrinkwrap, - // TODO: can be undefined? - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: can be undefined? (#7154) contents: res.lockFile!, }); } @@ -743,7 +737,7 @@ export async function getAdditionalFiles( let lockFile: string; logger.debug(`Finding package.json for lerna location "${lernaJsonFile}"`); const lernaPackageFile = packageFiles.npm.find( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 (p) => getSubDirectory(p.packageFile!) === getSubDirectory(lernaJsonFile) ); // istanbul ignore if: not sure how to test @@ -824,13 +818,13 @@ export async function getAdditionalFiles( const filename = packageFile.npmLock ?? packageFile.yarnLock; logger.trace(`Checking for ${filename}`); const existingContent = await getFile( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 filename!, config.reuseExistingBranch ? config.branchName : config.baseBranch ); if (existingContent) { logger.trace('Found lock file'); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const lockFilePath = filename!; logger.trace('Checking against ' + lockFilePath); try { @@ -850,7 +844,7 @@ export async function getAdditionalFiles( logger.debug('File is updated: ' + lockFilePath); updatedArtifacts.push({ type: 'addition', - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 path: filename!, contents: newContent, }); diff --git a/lib/modules/manager/npm/post-update/lerna.ts b/lib/modules/manager/npm/post-update/lerna.ts index e33388be4f07d5..90db8a57c187b1 100644 --- a/lib/modules/manager/npm/post-update/lerna.ts +++ b/lib/modules/manager/npm/post-update/lerna.ts @@ -22,7 +22,7 @@ export function getLernaVersion( ); return 'latest'; } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 return lernaDep.currentValue!; } diff --git a/lib/modules/manager/npm/post-update/npm.ts b/lib/modules/manager/npm/post-update/npm.ts index d2c4eaa889e547..a9375269bdacf7 100644 --- a/lib/modules/manager/npm/post-update/npm.ts +++ b/lib/modules/manager/npm/post-update/npm.ts @@ -149,13 +149,9 @@ export async function generateLockFile( const depType = lockUpdate.depType as | 'dependencies' | 'optionalDependencies'; - if ( - lockFileParsed.packages?.['']?.[depType]?.[ - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - lockUpdate.depName! - ] - ) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + + // TODO #7154 + if (lockFileParsed.packages?.['']?.[depType]?.[lockUpdate.depName!]) { lockFileParsed.packages[''][depType]![lockUpdate.depName!] = lockUpdate.newValue!; } diff --git a/lib/modules/manager/npm/range.ts b/lib/modules/manager/npm/range.ts index 051f6c736018de..6c676a7472f812 100644 --- a/lib/modules/manager/npm/range.ts +++ b/lib/modules/manager/npm/range.ts @@ -6,7 +6,7 @@ import type { RangeConfig } from '../types'; export function getRangeStrategy(config: RangeConfig): RangeStrategy { const { depType, depName, packageJsonType, currentValue, rangeStrategy } = config; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const isComplexRange = parseRange(currentValue!).length > 1; if (rangeStrategy === 'bump' && isComplexRange) { logger.debug( diff --git a/lib/modules/manager/npm/update/dependency/index.spec.ts b/lib/modules/manager/npm/update/dependency/index.spec.ts index e438a6bf15c7b3..01b3b91f04f5bf 100644 --- a/lib/modules/manager/npm/update/dependency/index.spec.ts +++ b/lib/modules/manager/npm/update/dependency/index.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import * as npmUpdater from '../..'; import { Fixtures } from '../../../../../../test/fixtures'; diff --git a/lib/modules/manager/npm/update/dependency/index.ts b/lib/modules/manager/npm/update/dependency/index.ts index 768a0954af4568..70eca55de162f8 100644 --- a/lib/modules/manager/npm/update/dependency/index.ts +++ b/lib/modules/manager/npm/update/dependency/index.ts @@ -47,7 +47,7 @@ function replaceAsString( } else if (depType === 'dependenciesMeta') { if (oldValue !== newValue) { parsedContents.dependenciesMeta = renameObjKey( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 parsedContents.dependenciesMeta!, oldValue, newValue @@ -117,7 +117,8 @@ export function updateDependency({ logger.debug('Updating package.json git digest'); newValue = upgrade.currentRawValue.replace( upgrade.currentDigest, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 + upgrade.newDigest!.substring(0, upgrade.currentDigest.length) ); } else { @@ -162,7 +163,7 @@ export function updateDependency({ return fileContent; } - /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ + // TODO #7154 let newFileContent = replaceAsString( parsedContents, fileContent, @@ -218,7 +219,7 @@ export function updateDependency({ 'resolutions', depKey, parsedContents.resolutions[depKey], - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 newValue! ); if (upgrade.newName) { @@ -246,7 +247,7 @@ export function updateDependency({ 'dependenciesMeta', depName, depKey, - depName + '@' + newValue + `${depName}@${newValue}` ); } } diff --git a/lib/modules/manager/npm/update/locked-dependency/index.spec.ts b/lib/modules/manager/npm/update/locked-dependency/index.spec.ts index 89120d9738a6ac..857621abaaf9a0 100644 --- a/lib/modules/manager/npm/update/locked-dependency/index.spec.ts +++ b/lib/modules/manager/npm/update/locked-dependency/index.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { updateLockedDependency } from '../..'; import { Fixtures } from '../../../../../../test/fixtures'; import * as httpMock from '../../../../../../test/http-mock'; diff --git a/lib/modules/manager/npm/update/locked-dependency/package-lock/index.ts b/lib/modules/manager/npm/update/locked-dependency/package-lock/index.ts index 25cabb0d34af42..353641cb6bfd68 100644 --- a/lib/modules/manager/npm/update/locked-dependency/package-lock/index.ts +++ b/lib/modules/manager/npm/update/locked-dependency/package-lock/index.ts @@ -30,13 +30,12 @@ export async function updateLockedDependency( try { let packageJson: PackageJson; let packageLockJson: PackageLockOrEntry; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const detectedIndent = detectIndent(lockFileContent!).indent || ' '; let newPackageJsonContent: string | null | undefined; try { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 packageJson = JSON.parse(packageFileContent!); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion packageLockJson = JSON.parse(lockFileContent!); } catch (err) { logger.warn({ err }, 'Failed to parse files'); @@ -46,7 +45,7 @@ export async function updateLockedDependency( const lockedDeps = getLockedDependencies( packageLockJson, depName, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 currentVersion! ); if (lockedDeps.some((dep) => dep.bundled)) { @@ -129,7 +128,7 @@ export async function updateLockedDependency( packageJson, packageLockJson, depName, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 currentVersion!, newVersion ); @@ -203,7 +202,7 @@ export async function updateLockedDependency( newVersion, })!; newPackageJsonContent = updateDependency({ - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 fileContent: packageFileContent!, upgrade: { depName, depType, newValue }, }); @@ -226,7 +225,7 @@ export async function updateLockedDependency( ...config, ...parentUpdate, lockFileContent: newLockFileContent, - packageFileContent: newPackageJsonContent || packageFileContent, + packageFileContent: newPackageJsonContent ?? packageFileContent, }; const parentUpdateResult = await updateLockedDependency( parentUpdateConfig, diff --git a/lib/modules/manager/npm/update/locked-dependency/yarn-lock/index.ts b/lib/modules/manager/npm/update/locked-dependency/yarn-lock/index.ts index 77ec2ac1cc5fa1..da325462afe76a 100644 --- a/lib/modules/manager/npm/update/locked-dependency/yarn-lock/index.ts +++ b/lib/modules/manager/npm/update/locked-dependency/yarn-lock/index.ts @@ -16,7 +16,7 @@ export function updateLockedDependency( ); let yarnLock: YarnLock; try { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 yarnLock = parseSyml(lockFileContent!); } catch (err) { logger.warn({ err }, 'Failed to parse yarn files'); @@ -30,7 +30,7 @@ export function updateLockedDependency( const lockedDeps = getLockedDependencies( yarnLock, depName, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 currentVersion! ); if (!lockedDeps.length) { @@ -67,7 +67,7 @@ export function updateLockedDependency( ); return { status: 'update-failed' }; } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 let newLockFileContent = lockFileContent!; for (const dependency of updateLockedDeps) { const { depName, constraint, newVersion } = dependency; diff --git a/lib/modules/manager/npm/utils.spec.ts b/lib/modules/manager/npm/utils.spec.ts index e7d8af6ec13169..60c7752659ab07 100644 --- a/lib/modules/manager/npm/utils.spec.ts +++ b/lib/modules/manager/npm/utils.spec.ts @@ -58,7 +58,6 @@ describe('modules/manager/npm/utils', () => { const lockFile = Fixtures.get('lockfile-parsing/package-lock.json'); const { detectedIndent, lockFileParsed } = parseLockFile(lockFile); // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const lockFileComposed = composeLockFile(lockFileParsed!, detectedIndent); expect(lockFileComposed).toBe(lockFile); }); diff --git a/lib/modules/manager/nuget/extract.ts b/lib/modules/manager/nuget/extract.ts index ea4507e79b3793..ec032b7d5a841b 100644 --- a/lib/modules/manager/nuget/extract.ts +++ b/lib/modules/manager/nuget/extract.ts @@ -44,13 +44,13 @@ function extractDepsFromXml(xmlNode: XmlDocument): PackageDependency[] { if (elemNames.has(name)) { const depName = attr?.Include || attr?.Update; const version = - attr?.Version || - child.valueWithPath('Version') || - attr?.VersionOverride || + attr?.Version ?? + child.valueWithPath('Version') ?? + attr?.VersionOverride ?? child.valueWithPath('VersionOverride'); const currentValue = checkVersion - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - ?.exec(version!) + + ?.exec(version) ?.groups?.currentValue?.trim(); if (depName && currentValue) { results.push({ diff --git a/lib/modules/manager/nuget/package-tree.ts b/lib/modules/manager/nuget/package-tree.ts index e7872f73a0c7fd..1a9537f6a30fe8 100644 --- a/lib/modules/manager/nuget/package-tree.ts +++ b/lib/modules/manager/nuget/package-tree.ts @@ -41,7 +41,6 @@ export async function getDependentPackageFiles( const packageFileContent = await readLocalFile(f, 'utf8'); // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const doc = new xmldoc.XmlDocument(packageFileContent!); const projectReferenceAttributes = doc .childrenNamed('ItemGroup') diff --git a/lib/modules/manager/pip_requirements/extract.ts b/lib/modules/manager/pip_requirements/extract.ts index 34524aee2b1c63..64bb9f01322fa5 100644 --- a/lib/modules/manager/pip_requirements/extract.ts +++ b/lib/modules/manager/pip_requirements/extract.ts @@ -40,7 +40,7 @@ export function cleanRegistryUrls(registryUrls: string[]): string[] { .replace(regEx(/^{/), '') .replace(regEx(/}$/), ''); const sub = process.env[envvar]; - return sub || match; + return sub ?? match; } ); }); @@ -76,7 +76,7 @@ export function extractPackageFile(content: string): PackageFile | null { const [lineNoEnvMarkers] = line.split(';').map((part) => part.trim()); const lineNoHashes = lineNoEnvMarkers.split(' \\')[0]; const packageMatches = - pkgValRegex.exec(lineNoHashes) || pkgRegex.exec(lineNoHashes); + pkgValRegex.exec(lineNoHashes) ?? pkgRegex.exec(lineNoHashes); const gitPackageMatches = packageGitRegex.exec(lineNoHashes); if (!packageMatches && !gitPackageMatches) { return null; @@ -109,7 +109,6 @@ export function extractPackageFile(content: string): PackageFile | null { } // validated above - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const [, depName, , currVal] = packageMatches!; const currentValue = currVal?.trim(); dep = { diff --git a/lib/modules/manager/pip_setup/extract.ts b/lib/modules/manager/pip_setup/extract.ts index 9e8d5a84d4d977..592226734bd0de 100644 --- a/lib/modules/manager/pip_setup/extract.ts +++ b/lib/modules/manager/pip_setup/extract.ts @@ -36,7 +36,7 @@ function depStringHandler( ): Context { const depStr = token.value; const match = extractRegex.exec(depStr); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const { depName, currentValue } = match!.groups!; const dep: PackageDependency = { diff --git a/lib/modules/manager/pipenv/extract.ts b/lib/modules/manager/pipenv/extract.ts index 9d963f916a2b34..adeb9039696c78 100644 --- a/lib/modules/manager/pipenv/extract.ts +++ b/lib/modules/manager/pipenv/extract.ts @@ -60,7 +60,6 @@ function extractFromSection( skipReason = 'invalid-name'; } // validated above - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const specifierMatches = specifierRegex.exec(currentValue!); if (!specifierMatches) { logger.debug( @@ -83,7 +82,7 @@ function extractFromSection( dep.datasource = PypiDatasource.id; } if (nestedVersion) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 dep.managerData!.nestedVersion = nestedVersion; } if (requirements.index) { @@ -132,15 +131,12 @@ export async function extractPackageFile( const constraints: Record = {}; if (is.nonEmptyString(pipfile.requires?.python_version)) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion constraints.python = `== ${pipfile.requires!.python_version}.*`; } else if (is.nonEmptyString(pipfile.requires?.python_full_version)) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion constraints.python = `== ${pipfile.requires!.python_full_version}`; } if (is.nonEmptyString(pipfile.packages?.pipenv)) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion constraints.pipenv = pipfile.packages!.pipenv; } else if (is.nonEmptyString(pipfile['dev-packages']?.pipenv)) { constraints.pipenv = pipfile['dev-packages']!.pipenv; diff --git a/lib/modules/manager/terraform/lockfile/index.ts b/lib/modules/manager/terraform/lockfile/index.ts index c8765fa7dccde0..f2aee3eab9c2c4 100644 --- a/lib/modules/manager/terraform/lockfile/index.ts +++ b/lib/modules/manager/terraform/lockfile/index.ts @@ -89,7 +89,7 @@ export async function updateArtifacts({ updates.push(...maintenanceUpdates); } else { const providerDeps = updatedDeps.filter((dep) => - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 ['provider', 'required_provider'].includes(dep.depType!) ); for (const dep of providerDeps) { @@ -108,15 +108,13 @@ export async function updateArtifacts({ continue; } const update: ProviderLockUpdate = { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 newVersion: newVersion!, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion newConstraint: newConstraint!, newHashes: (await TerraformProviderHash.createHashes( registryUrl, updateLock.packageName, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion newVersion! )) ?? /* istanbul ignore next: needs test */ [], ...updateLock, diff --git a/lib/modules/manager/terraform/lockfile/util.ts b/lib/modules/manager/terraform/lockfile/util.ts index a19b2aff952f4c..774be9e7284914 100644 --- a/lib/modules/manager/terraform/lockfile/util.ts +++ b/lib/modules/manager/terraform/lockfile/util.ts @@ -139,30 +139,28 @@ export function writeLockUpdates( const sections: string[][] = []; // sort updates in order of appearance in the lockfile - /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ + // TODO #7154 updates.sort( (a, b) => a.lineNumbers.block!.start - b.lineNumbers.block!.start ); - /* eslint-enable @typescript-eslint/no-unnecessary-type-assertion */ updates.forEach((update, index, array) => { // re add leading whitespace let startWhitespace: number | undefined; if (index > 0) { // get end of the - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 startWhitespace = array[index - 1].lineNumbers.block!.end; } const leadingNonRelevantLines = lines.slice( startWhitespace, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 update.lineNumbers.block!.start ); sections.push(leadingNonRelevantLines); const providerBlockLines = lines.slice( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 update.lineNumbers.block!.start, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion update.lineNumbers.block!.end ); const newProviderBlockLines: string[] = []; @@ -201,7 +199,7 @@ export function writeLockUpdates( (value) => `${hashLinePrefix}${value}${hashLineSuffix}` ); newProviderBlockLines.splice( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 update.lineNumbers.hashes.start!, 0, ...hashesWithWhitespace diff --git a/lib/modules/manager/terraform/modules.ts b/lib/modules/manager/terraform/modules.ts index 5be46e462232c9..2e8542463fe8e6 100644 --- a/lib/modules/manager/terraform/modules.ts +++ b/lib/modules/manager/terraform/modules.ts @@ -30,14 +30,14 @@ export function extractTerraformModule( ): ExtractionResult { const result = extractTerraformProvider(startingLine, lines, moduleName); result.dependencies.forEach((dep) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 dep.managerData!.terraformDependencyType = TerraformDependencyTypes.module; }); return result; } export function analyseTerraformModule(dep: PackageDependency): void { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const source = dep.managerData!.source as string; const githubRefMatch = githubRefMatchRegex.exec(source); const bitbucketRefMatch = bitbucketRefMatchRegex.exec(source); diff --git a/lib/modules/manager/terraform/providers.ts b/lib/modules/manager/terraform/providers.ts index 07ec08caaf5d2b..b1251cf77dbce5 100644 --- a/lib/modules/manager/terraform/providers.ts +++ b/lib/modules/manager/terraform/providers.ts @@ -41,8 +41,8 @@ export function extractTerraformProvider( // istanbul ignore else if (is.string(line)) { // `{` will be counted with +1 and `}` with -1. Therefore if we reach braceCounter == 0. We have found the end of the terraform block - const openBrackets = (line.match(regEx(/\{/g)) || []).length; - const closedBrackets = (line.match(regEx(/\}/g)) || []).length; + const openBrackets = (line.match(regEx(/\{/g)) ?? []).length; + const closedBrackets = (line.match(regEx(/\}/g)) ?? []).length; braceCounter = braceCounter + openBrackets - closedBrackets; // only update fields inside the root block @@ -52,9 +52,8 @@ export function extractTerraformProvider( if (kvMatch.groups.key === 'version') { dep.currentValue = kvMatch.groups.value; } else if (kvMatch.groups.key === 'source') { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 dep.managerData!.source = kvMatch.groups.value; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion dep.managerData!.sourceLine = lineNumber; } } @@ -81,7 +80,7 @@ export function analyzeTerraformProvider( dep.datasource = TerraformProviderDatasource.id; if (is.nonEmptyString(dep.managerData?.source)) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const source = sourceExtractionRegex.exec(dep.managerData!.source); if (!source?.groups) { dep.skipReason = 'unsupported-url'; diff --git a/lib/modules/manager/terraform/required-providers.ts b/lib/modules/manager/terraform/required-providers.ts index 1c730c3f6d56ae..537e40b25c1db9 100644 --- a/lib/modules/manager/terraform/required-providers.ts +++ b/lib/modules/manager/terraform/required-providers.ts @@ -22,7 +22,7 @@ function extractBlock( if (kvMatch?.groups) { switch (kvMatch.groups.key) { case 'source': - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 dep.managerData!.source = kvMatch.groups.value; break; @@ -58,14 +58,14 @@ export function extractTerraformRequiredProviders( const kvMatch = keyValueExtractionRegex.exec(line); if (kvMatch?.groups) { dep.currentValue = kvMatch.groups.value; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 dep.managerData!.moduleName = kvMatch.groups.key; deps.push(dep); } else { const nameMatch = providerBlockExtractionRegex.exec(line); if (nameMatch?.groups) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 dep.managerData!.moduleName = nameMatch.groups.key; lineNumber = extractBlock(lineNumber, lines, dep); deps.push(dep); diff --git a/lib/modules/manager/terraform/resources.ts b/lib/modules/manager/terraform/resources.ts index c691e940e7fe52..47bb534e292dc1 100644 --- a/lib/modules/manager/terraform/resources.ts +++ b/lib/modules/manager/terraform/resources.ts @@ -75,8 +75,8 @@ export function extractTerraformResource( // istanbul ignore else if (is.string(line)) { // `{` will be counted with +1 and `}` with -1. Therefore if we reach braceCounter == 0. We have found the end of the terraform block - const openBrackets = (line.match(regEx(/\{/g)) || []).length; - const closedBrackets = (line.match(regEx(/\}/g)) || []).length; + const openBrackets = (line.match(regEx(/\{/g)) ?? []).length; + const closedBrackets = (line.match(regEx(/\}/g)) ?? []).length; braceCounter = braceCounter + openBrackets - closedBrackets; const kvMatch = keyValueExtractionRegex.exec(line); @@ -141,7 +141,7 @@ export function analyseTerraformResource( dep.skipReason = 'local-chart'; } dep.depType = 'helm_release'; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 dep.registryUrls = [dep.managerData.repository!]; dep.depName = dep.managerData.chart; dep.datasource = HelmDatasource.id; diff --git a/lib/modules/manager/terraform/util.ts b/lib/modules/manager/terraform/util.ts index dea1126352164c..4852300c1e6b80 100644 --- a/lib/modules/manager/terraform/util.ts +++ b/lib/modules/manager/terraform/util.ts @@ -53,13 +53,14 @@ export function massageProviderLookupName(dep: PackageDependency): void { if (!dep.packageName) { dep.packageName = dep.depName; } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + + // TODO #7154 if (!dep.packageName!.includes('/')) { dep.packageName = `hashicorp/${dep.packageName}`; } // handle cases like `Telmate/proxmox` - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 dep.packageName = dep.packageName!.toLowerCase(); } diff --git a/lib/modules/manager/terragrunt/extract.ts b/lib/modules/manager/terragrunt/extract.ts index 929bec4d319912..f9a06462d93b25 100644 --- a/lib/modules/manager/terragrunt/extract.ts +++ b/lib/modules/manager/terragrunt/extract.ts @@ -54,7 +54,7 @@ export function extractPackageFile(content: string): PackageFile | null { logger.warn({ err }, 'Error extracting terragrunt plugins'); } deps.forEach((dep) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 switch (dep.managerData!.terragruntDependencyType) { case TerragruntDependencyTypes.terragrunt: analyseTerragruntModule(dep); diff --git a/lib/modules/manager/terragrunt/modules.ts b/lib/modules/manager/terragrunt/modules.ts index 16ea8f6a26689e..877b2c050c183c 100644 --- a/lib/modules/manager/terragrunt/modules.ts +++ b/lib/modules/manager/terragrunt/modules.ts @@ -23,7 +23,7 @@ export function extractTerragruntModule( const moduleName = 'terragrunt'; const result = extractTerragruntProvider(startingLine, lines, moduleName); result.dependencies.forEach((dep) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 dep.managerData!.terragruntDependencyType = TerragruntDependencyTypes.terragrunt; }); @@ -33,7 +33,7 @@ export function extractTerragruntModule( export function analyseTerragruntModule( dep: PackageDependency ): void { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const source = dep.managerData!.source; const githubRefMatch = githubRefMatchRegex.exec(source ?? ''); const gitTagsRefMatch = gitTagsRefMatchRegex.exec(source ?? ''); diff --git a/lib/modules/platform/azure/azure-got-wrapper.ts b/lib/modules/platform/azure/azure-got-wrapper.ts index aaa337a718b832..408ef5d36504fa 100644 --- a/lib/modules/platform/azure/azure-got-wrapper.ts +++ b/lib/modules/platform/azure/azure-got-wrapper.ts @@ -15,8 +15,7 @@ function getAuthenticationHandler(config: HostRule): IRequestHandler { if (!config.token && config.username && config.password) { return getBasicHandler(config.username, config.password, true); } - // TODO: token can be undefined here - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: token can be undefined here (#7154) return getHandlerFromToken(config.token!, true); } diff --git a/lib/modules/platform/azure/azure-helper.ts b/lib/modules/platform/azure/azure-helper.ts index 7d132d8afbb628..0b22aebfb99a32 100644 --- a/lib/modules/platform/azure/azure-helper.ts +++ b/lib/modules/platform/azure/azure-helper.ts @@ -49,9 +49,8 @@ export async function getAzureBranchObj( }; } return { - // TODO: fix undefined + // TODO: fix undefined (#7154) name: getNewBranchName(branchName)!, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion oldObjectId: refs[0].objectId!, }; } @@ -134,10 +133,10 @@ export async function getMergeMethod( if (!branchRef) { return true; } + // TODO #7154 return scope.matchKind === 'Exact' ? scope.refName === branchRef - : // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - branchRef.startsWith(scope.refName!); + : branchRef.startsWith(scope.refName!); }; const policyConfigurations = ( diff --git a/lib/modules/platform/azure/index.ts b/lib/modules/platform/azure/index.ts index 8296d495cf7bf7..788ad4fea7671e 100644 --- a/lib/modules/platform/azure/index.ts +++ b/lib/modules/platform/azure/index.ts @@ -137,7 +137,7 @@ export async function getRawFile( } as GitVersionDescriptor; const buf = await azureApiGit.getItemContent( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 repoId!, fileName, undefined, @@ -159,7 +159,7 @@ export async function getJsonFile( branchOrTag?: string ): Promise { const raw = await getRawFile(fileName, repoName, branchOrTag); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 return JSON5.parse(raw!); } @@ -186,8 +186,9 @@ export async function initRepo({ logger.debug('Repo is empty'); throw new Error(REPOSITORY_EMPTY); } + // TODO #7154 config.repoId = repo.id!; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + config.project = repo.project!.name!; config.owner = '?owner?'; logger.debug(`${repository} owner = ${config.owner}`); @@ -196,7 +197,7 @@ export async function initRepo({ logger.debug(`${repository} default branch = ${defaultBranch}`); const names = getProjectAndRepo(repository); config.defaultMergeMethod = await azureHelper.getMergeMethod( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 repo.id!, names.project, null, @@ -210,10 +211,10 @@ export async function initRepo({ hostType: defaults.hostType, url: defaults.endpoint, }); - const manualUrl = - defaults.endpoint + - `${encodeURIComponent(projectName)}/_git/${encodeURIComponent(repoName)}`; - const url = repo.remoteUrl || manualUrl; + const manualUrl = `${defaults.endpoint}${encodeURIComponent( + projectName + )}/_git/${encodeURIComponent(repoName)}`; + const url = repo.remoteUrl ?? manualUrl; await git.initRepo({ ...config, url, @@ -335,12 +336,12 @@ async function getStatusCheck(branchName: string): Promise { const branch = await azureApiGit.getBranch( config.repoId, - // TODO: fix undefined + // TODO: fix undefined (#7154) getBranchNameWithoutRefsheadsPrefix(branchName)! ); // only grab the latest statuses, it will group any by context return azureApiGit.getStatuses( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 branch.commit!.commitId!, config.repoId, undefined, @@ -366,7 +367,7 @@ export async function getBranchStatusCheck( const res = await getStatusCheck(branchName); for (const check of res) { if (getGitStatusContextCombinedName(check.context) === context) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 return azureToRenovateStatusMapping[check.state!] ?? BranchStatus.yellow; } } @@ -435,7 +436,7 @@ export async function createPr({ pr = await azureApiGit.updatePullRequest( { autoCompleteSetBy: { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 id: pr.createdBy!.id, }, completionOptions: { @@ -445,35 +446,32 @@ export async function createPr({ }, }, config.repoId, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 pr.pullRequestId! ); } if (platformOptions?.azureAutoApprove) { await azureApiGit.createPullRequestReviewer( { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion reviewerUrl: pr.createdBy!.url, vote: AzurePrVote.Approved, isFlagged: false, isRequired: false, }, config.repoId, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 pr.pullRequestId!, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion pr.createdBy!.id! ); } await Promise.all( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion labels!.map((label) => azureApiGit.createPullRequestLabel( { name: label, }, config.repoId, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 pr.pullRequestId! ) ) @@ -558,7 +556,7 @@ export async function ensureComment({ config.repoId, number, threadIdFound, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 commentIdFound! ); logger.debug( @@ -647,7 +645,7 @@ export async function setBranchStatus({ }; await azureApiGit.createCommitStatus( statusToCreate, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 branch.commit!.commitId!, config.repoId ); @@ -663,10 +661,9 @@ export async function mergePr({ let pr = await azureApiGit.getPullRequestById(pullRequestId, config.project); + // TODO #7154 const mergeMethod = - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion config.mergeMethods[pr.targetRefName!] ?? - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion (config.mergeMethods[pr.targetRefName!] = await azureHelper.getMergeMethod( config.repoId, config.project, @@ -721,7 +718,7 @@ export async function mergePr({ { pullRequestId, status: pr.status }, `Expected PR to have status ${ PullRequestStatus[PullRequestStatus.Completed] - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 }, however it is ${PullRequestStatus[pr.status!]}.` ); } @@ -771,15 +768,15 @@ async function getUserIds(users: string[]): Promise { const azureApiCore = await azureApi.coreApi(); const repos = await azureApiGit.getRepositories(); const repo = repos.filter((c) => c.id === config.repoId)[0]; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + + // TODO #7154 const teams = await azureApiCore.getTeams(repo.project!.id!); const members = await Promise.all( teams.map( async (t) => await azureApiCore.getTeamMembersWithExtendedProperties( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 repo.project!.id!, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion t.id! ) ) @@ -794,7 +791,7 @@ async function getUserIds(users: string[]): Promise { r.toLowerCase() === m.identity?.uniqueName?.toLowerCase() ) { if (ids.filter((c) => c.id === m.identity?.id).length === 0) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 ids.push({ id: m.identity.id!, name: r }); } } @@ -806,7 +803,7 @@ async function getUserIds(users: string[]): Promise { users.forEach((r) => { if (r.toLowerCase() === t.name?.toLowerCase()) { if (ids.filter((c) => c.id === t.id).length === 0) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 ids.push({ id: t.id!, name: r }); } } diff --git a/lib/modules/platform/azure/util.ts b/lib/modules/platform/azure/util.ts index 0b7aa652faa983..60fe471cf914fa 100644 --- a/lib/modules/platform/azure/util.ts +++ b/lib/modules/platform/azure/util.ts @@ -101,7 +101,8 @@ export function getRenovatePRFormat(azurePr: GitPullRequest): AzurePr { const bodyStruct = getPrBodyStruct(azurePr.description); const createdAt = azurePr.creationDate?.toISOString(); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + + // TODO #7154 const state = stateMap[azurePr.status!] ?? PrState.Open; const sourceRefName = azurePr.sourceRefName; @@ -183,6 +184,6 @@ export function getRepoByName( (r) => project === r?.project?.name?.toLowerCase() && repo === r?.name?.toLowerCase() - ) || null + ) ?? null ); } diff --git a/lib/modules/platform/bitbucket-server/index.ts b/lib/modules/platform/bitbucket-server/index.ts index ef6725ea853f57..212f01a481bcb1 100644 --- a/lib/modules/platform/bitbucket-server/index.ts +++ b/lib/modules/platform/bitbucket-server/index.ts @@ -144,7 +144,7 @@ export async function getJsonFile( repoName?: string, branchOrTag?: string ): Promise { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const raw = (await getRawFile(fileName, repoName, branchOrTag)) as string; return JSON5.parse(raw); } @@ -191,7 +191,7 @@ export async function initRepo({ const gitUrl = utils.getRepoGitUrl( config.repositorySlug, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 defaults.endpoint!, info, opts @@ -263,7 +263,7 @@ export async function getPr( reviewers: res.body.reviewers.map((r) => r.user.name), }; pr.hasReviewers = is.nonEmptyArray(pr.reviewers); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 pr.version = updatePrVersion(pr.number, pr.version!); return pr; @@ -464,7 +464,7 @@ export async function setBranchStatus({ const body: any = { key: context, description, - url: targetUrl || 'https://renovatebot.com', + url: targetUrl ?? 'https://renovatebot.com', }; switch (state) { @@ -563,8 +563,7 @@ export async function addReviewers( throw new Error(REPOSITORY_NOT_FOUND); } - // TODO: can `reviewers` be undefined? - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: can `reviewers` be undefined? (#7154) const reviewersSet = new Set([...pr.reviewers!, ...reviewers]); await bitbucketServerHttp.putJson( @@ -835,7 +834,7 @@ export async function createPr({ ...utils.prInfo(prInfoRes.body), }; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 updatePrVersion(pr.number, pr.version!); // istanbul ignore if @@ -886,10 +885,10 @@ export async function updatePr({ updatePrVersion(prNo, updatedPr.version); const currentState = updatedPr.state; + // TODO #7154 const newState = { [PrState.Open]: 'OPEN', [PrState.Closed]: 'DECLINED', - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion }[state!]; if ( diff --git a/lib/modules/platform/bitbucket-server/utils.ts b/lib/modules/platform/bitbucket-server/utils.ts index 5f8f88f2d49d80..4031166e97b38a 100644 --- a/lib/modules/platform/bitbucket-server/utils.ts +++ b/lib/modules/platform/bitbucket-server/utils.ts @@ -172,11 +172,11 @@ export function getRepoGitUrl( if (!cloneUrl) { // Fallback to generating the url if the API didn't give us an URL const { host, pathname } = url.parse(defaultEndpoint); + // TODO #7154 gitUrl = git.getUrl({ protocol: defaultEndpoint.split(':')[0] as GitProtocol, auth: `${opts.username}:${opts.password}`, host: `${host}${pathname}${ - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion pathname!.endsWith('/') ? '' : /* istanbul ignore next */ '/' }scm`, repository, diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index 15a098988cf0f3..48962df1563440 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -89,7 +89,7 @@ export async function initPlatform({ } // TODO: Add a connection check that endpoint/username/password combination are valid (#9594) const platformConfig: PlatformResult = { - endpoint: endpoint || BITBUCKET_PROD_ENDPOINT, + endpoint: endpoint ?? BITBUCKET_PROD_ENDPOINT, }; return Promise.resolve(platformConfig); } @@ -125,7 +125,7 @@ export async function getRawFile( const url = `/2.0/repositories/${repo}/src/` + - (finalBranchOrTag || `HEAD`) + + (finalBranchOrTag ?? `HEAD`) + `/${path}`; const res = await bitbucketHttp.get(url); return res.body; @@ -136,7 +136,7 @@ export async function getJsonFile( repoName?: string, branchOrTag?: string ): Promise { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const raw = (await getRawFile(fileName, repoName, branchOrTag)) as string; return JSON5.parse(raw); } @@ -189,7 +189,7 @@ export async function initRepo({ // Converts API hostnames to their respective HTTP git hosts: // `api.bitbucket.org` to `bitbucket.org` // `api-staging.` to `staging.` - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const hostnameWithoutApiPrefix = regEx(/api[.|-](.+)/).exec(hostname!)?.[1]; const url = git.getUrl({ @@ -374,7 +374,7 @@ export async function getBranchStatusCheck( ): Promise { const statuses = await getStatus(branchName); const bbState = statuses.find((status) => status.key === context)?.state; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 return bbToRenovateStatusMapping[bbState!] || null; } @@ -388,7 +388,7 @@ export async function setBranchStatus({ const sha = await getBranchCommit(branchName); // TargetUrl can not be empty so default to bitbucket - const url = targetUrl || /* istanbul ignore next */ 'https://bitbucket.org'; + const url = targetUrl ?? /* istanbul ignore next */ 'https://bitbucket.org'; const body = { name: context, @@ -595,8 +595,8 @@ export async function addReviewers( ): Promise { logger.debug(`Adding reviewers '${reviewers.join(', ')}' to #${prId}`); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - const { title } = (await getPr(prId)) as Pr; + // TODO #7154 + const { title } = (await getPr(prId))!; const body = { title, diff --git a/lib/modules/platform/gitea/index.ts b/lib/modules/platform/gitea/index.ts index 97e437db5eb3b7..5a98cf8cafda00 100644 --- a/lib/modules/platform/gitea/index.ts +++ b/lib/modules/platform/gitea/index.ts @@ -68,6 +68,7 @@ function toRenovateIssue(data: helper.Issue): Issue { }; } +// TODO #7154 function toRenovatePR(data: helper.PR): Pr | null { if (!data) { return null; @@ -104,7 +105,7 @@ function toRenovatePR(data: helper.PR): Pr | null { cannotMergeReason: data.mergeable ? undefined : `pr.mergeable="${data.mergeable}"`, - hasAssignees: !!(data.assignee?.login || is.nonEmptyArray(data.assignees)), + hasAssignees: !!(data.assignee?.login ?? is.nonEmptyArray(data.assignees)), }; } @@ -193,7 +194,7 @@ const platform: Platform = { let gitAuthor: string; try { const user = await helper.getCurrentUser({ token }); - gitAuthor = `${user.full_name || user.username} <${user.email}>`; + gitAuthor = `${user.full_name ?? user.username} <${user.email}>`; botUserID = user.id; botUserName = user.username; defaults.version = await helper.getVersion({ token }); @@ -226,12 +227,8 @@ const platform: Platform = { repoName?: string, branchOrTag?: string ): Promise { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - const raw = (await platform.getRawFile( - fileName, - repoName, - branchOrTag - )) as string; + // TODO #7154 + const raw = (await platform.getRawFile(fileName, repoName, branchOrTag))!; return JSON5.parse(raw); }, @@ -341,7 +338,7 @@ const platform: Platform = { // Create new status for branch commit const branchCommit = git.getBranchCommit(branchName); // TODO: check branchCommit - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + await helper.createCommitStatus(config.repository, branchCommit!, { state: helper.renovateToGiteaStatusMapping[state] || 'pending', context, @@ -376,7 +373,7 @@ const platform: Platform = { logger.debug({ ccs }, 'Branch status check result'); return ( - helper.giteaToRenovateStatusMapping[ccs.worstStatus] || + helper.giteaToRenovateStatusMapping[ccs.worstStatus] ?? BranchStatus.yellow ); }, @@ -435,7 +432,7 @@ const platform: Platform = { // Add pull request to cache for further lookups / queries if (config.prList !== null) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 (await config.prList).push(pr!); } } @@ -610,7 +607,7 @@ const platform: Platform = { return null; } logger.debug(`Found Issue #${issue.number}`); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 return getIssue!(issue.number!); }, @@ -660,7 +657,7 @@ const platform: Platform = { for (const issue of issues) { if (issue.state === 'open' && issue.number !== activeIssue.number) { logger.warn(`Closing duplicate Issue #${issue.number}`); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 await helper.closeIssue(config.repository, issue.number!); } } @@ -681,7 +678,7 @@ const platform: Platform = { logger.debug(`Updating Issue #${activeIssue.number}`); const existingIssue = await helper.updateIssue( config.repository, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 activeIssue.number!, { body, @@ -704,7 +701,7 @@ const platform: Platform = { ) { await helper.updateIssueLabels( config.repository, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 activeIssue.number!, { labels, @@ -738,7 +735,7 @@ const platform: Platform = { for (const issue of issueList) { if (issue.state === 'open' && issue.title === title) { logger.debug({ number: issue.number }, 'Closing issue'); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 await helper.closeIssue(config.repository, issue.number!); } } diff --git a/lib/modules/platform/github/index.ts b/lib/modules/platform/github/index.ts index 003d4f3cdf9d22..81f25e24a8b8be 100644 --- a/lib/modules/platform/github/index.ts +++ b/lib/modules/platform/github/index.ts @@ -162,7 +162,7 @@ export async function initPlatform({ logger.debug({ platformConfig, renovateUsername }, 'Platform config'); const platformResult: PlatformResult = { endpoint: platformConfig.endpoint, - gitAuthor: gitAuthor || discoveredGitAuthor, + gitAuthor: gitAuthor ?? discoveredGitAuthor, renovateUsername, }; @@ -230,7 +230,7 @@ export async function getJsonFile( repoName?: string, branchOrTag?: string ): Promise { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const raw = (await getRawFile(fileName, repoName, branchOrTag)) as string; return JSON5.parse(raw); } @@ -270,10 +270,10 @@ export async function initRepo({ let infoQuery = repoInfoQuery; // GitHub Enterprise Server <3.3.0 doesn't support autoMergeAllowed and hasIssuesEnabled objects + // TODO #7154 if ( platformConfig.isGhe && // semver not null safe, accepts null and undefined - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion semver.satisfies(platformConfig.gheVersion!, '<3.3.0') ) { infoQuery = infoQuery.replace(/\n\s*autoMergeAllowed\s*\n/, '\n'); @@ -376,7 +376,7 @@ export async function initRepo({ await githubApi.getJson<{ full_name: string }[]>( 'user/repos?per_page=100', { - token: forkToken || opts.token, + token: forkToken ?? opts.token, paginate: true, pageLimit: 100, } @@ -387,7 +387,7 @@ export async function initRepo({ full_name: string; default_branch: string; }>(`repos/${repository}/forks`, { - token: forkToken || opts.token, + token: forkToken ?? opts.token, }); config.repository = forkedRepo.body.full_name; const forkDefaultBranch = forkedRepo.body.default_branch; @@ -460,7 +460,7 @@ export async function initRepo({ sha, force: true, }, - token: forkToken || opts.token, + token: forkToken ?? opts.token, }); } catch (err) /* istanbul ignore next */ { logger.warn( @@ -492,13 +492,12 @@ export async function initRepo({ logger.debug(`Using ${tokenType} token for git init`); parsedEndpoint.auth = opts.token ?? null; } - // TODO: null checks #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: null checks (#7154) parsedEndpoint.host = parsedEndpoint.host!.replace( 'api.github.com', 'github.com' ); - parsedEndpoint.pathname = config.repository + '.git'; + parsedEndpoint.pathname = `${config.repository}.git`; const url = URL.format(parsedEndpoint); await git.initRepo({ ...config, @@ -576,7 +575,7 @@ function cachePr(pr?: Pr | null): void { // Fetch fresh Pull Request and cache it when possible async function fetchPr(prNo: number): Promise { const { body: ghRestPr } = await githubApi.getJson( - `repos/${config.parentRepo || config.repository}/pulls/${prNo}` + `repos/${config.parentRepo ?? config.repository}/pulls/${prNo}` ); const result = coerceRestPr(ghRestPr); cachePr(result); @@ -614,8 +613,7 @@ export async function getPrList(): Promise { !config.forkMode && !config.ignorePrAuthor && config.renovateUsername ? config.renovateUsername : null; - // TODO: check null `repo` #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: check null `repo` (#7154) const prCache = await getPrCache(githubApi, repo!, username); config.prList = Object.values(prCache); } @@ -948,7 +946,7 @@ export async function getIssue( try { const issueBody = ( await githubApi.getJson<{ body: string }>( - `repos/${config.parentRepo || config.repository}/issues/${number}`, + `repos/${config.parentRepo ?? config.repository}/issues/${number}`, { useCache } ) ).body.body; @@ -971,15 +969,14 @@ export async function findIssue(title: string): Promise { return null; } logger.debug(`Found issue ${issue.number}`); - // TODO: can number be required? #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: can number be required? (#7154) return getIssue(issue.number!); } async function closeIssue(issueNumber: number): Promise { logger.debug(`closeIssue(${issueNumber})`); await githubApi.patchJson( - `repos/${config.parentRepo || config.repository}/issues/${issueNumber}`, + `repos/${config.parentRepo ?? config.repository}/issues/${issueNumber}`, { body: { state: 'closed' }, } @@ -1027,13 +1024,13 @@ export async function ensureIssue({ for (const i of issues) { if (i.state === 'open' && i.number !== issue.number) { logger.warn(`Closing duplicate issue ${i.number}`); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 await closeIssue(i.number!); } } const issueBody = ( await githubApi.getJson<{ body: string }>( - `repos/${config.parentRepo || config.repository}/issues/${ + `repos/${config.parentRepo ?? config.repository}/issues/${ issue.number }` ) @@ -1053,7 +1050,7 @@ export async function ensureIssue({ data.labels = labels; } await githubApi.patchJson( - `repos/${config.parentRepo || config.repository}/issues/${ + `repos/${config.parentRepo ?? config.repository}/issues/${ issue.number }`, { @@ -1065,12 +1062,12 @@ export async function ensureIssue({ } } await githubApi.postJson( - `repos/${config.parentRepo || config.repository}/issues`, + `repos/${config.parentRepo ?? config.repository}/issues`, { body: { title, body, - labels: labels || [], + labels: labels ?? [], }, } ); @@ -1100,7 +1097,7 @@ export async function ensureIssueClosing(title: string): Promise { const issueList = await getIssueList(); for (const issue of issueList) { if (issue.state === 'open' && issue.title === title) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 await closeIssue(issue.number!); logger.debug({ number: issue.number }, 'Issue closed'); } @@ -1112,7 +1109,7 @@ export async function addAssignees( assignees: string[] ): Promise { logger.debug(`Adding assignees '${assignees.join(', ')}' to #${issueNo}`); - const repository = config.parentRepo || config.repository; + const repository = config.parentRepo ?? config.repository; await githubApi.postJson(`repos/${repository}/issues/${issueNo}/assignees`, { body: { assignees, @@ -1133,7 +1130,7 @@ export async function addReviewers( try { await githubApi.postJson( `repos/${ - config.parentRepo || config.repository + config.parentRepo ?? config.repository }/pulls/${prNo}/requested_reviewers`, { body: { @@ -1152,7 +1149,7 @@ async function addLabels( labels: string[] | null | undefined ): Promise { logger.debug(`Adding labels '${labels?.join(', ')}' to #${issueNo}`); - const repository = config.parentRepo || config.repository; + const repository = config.parentRepo ?? config.repository; if (is.array(labels) && labels.length) { await githubApi.postJson(`repos/${repository}/issues/${issueNo}/labels`, { body: labels, @@ -1165,7 +1162,7 @@ export async function deleteLabel( label: string ): Promise { logger.debug(`Deleting label ${label} from #${issueNo}`); - const repository = config.parentRepo || config.repository; + const repository = config.parentRepo ?? config.repository; try { await githubApi.deleteJson( `repos/${repository}/issues/${issueNo}/labels/${label}` @@ -1179,7 +1176,7 @@ async function addComment(issueNo: number, body: string): Promise { // POST /repos/:owner/:repo/issues/:number/comments await githubApi.postJson( `repos/${ - config.parentRepo || config.repository + config.parentRepo ?? config.repository }/issues/${issueNo}/comments`, { body: { body }, @@ -1191,7 +1188,7 @@ async function editComment(commentId: number, body: string): Promise { // PATCH /repos/:owner/:repo/issues/comments/:id await githubApi.patchJson( `repos/${ - config.parentRepo || config.repository + config.parentRepo ?? config.repository }/issues/comments/${commentId}`, { body: { body }, @@ -1203,7 +1200,7 @@ async function deleteComment(commentId: number): Promise { // DELETE /repos/:owner/:repo/issues/comments/:id await githubApi.deleteJson( `repos/${ - config.parentRepo || config.repository + config.parentRepo ?? config.repository }/issues/comments/${commentId}` ); } @@ -1212,7 +1209,7 @@ async function getComments(issueNo: number): Promise { // GET /repos/:owner/:repo/issues/:number/comments logger.debug(`Getting comments for #${issueNo}`); const url = `repos/${ - config.parentRepo || config.repository + config.parentRepo ?? config.repository }/issues/${issueNo}/comments?per_page=100`; try { const comments = ( @@ -1334,9 +1331,9 @@ async function tryPrAutomerge( } // If GitHub Enterprise Server <3.3.0 it doesn't support automerge + // TODO #7154 if (platformConfig.isGhe) { // semver not null safe, accepts null and undefined - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion if (semver.satisfies(platformConfig.gheVersion!, '<3.3.0')) { logger.debug( { prNumber }, @@ -1391,8 +1388,8 @@ export async function createPr({ const body = sanitize(rawBody); const base = targetBranch; // Include the repository owner to handle forkMode and regular mode - // TODO: can `repository` be null? #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: can `repository` be null? (#7154) + const head = `${config.repository!.split('/')[0]}:${sourceBranch}`; const options: any = { body: { @@ -1411,7 +1408,7 @@ export async function createPr({ logger.debug({ title, head, base, draft: draftPR }, 'Creating PR'); const ghPr = ( await githubApi.postJson( - `repos/${config.parentRepo || config.repository}/pulls`, + `repos/${config.parentRepo ?? config.repository}/pulls`, options ) ).body; @@ -1451,7 +1448,7 @@ export async function updatePr({ } try { const { body: ghPr } = await githubApi.patchJson( - `repos/${config.parentRepo || config.repository}/pulls/${prNo}`, + `repos/${config.parentRepo ?? config.repository}/pulls/${prNo}`, options ); const result = coerceRestPr(ghPr); @@ -1476,7 +1473,7 @@ export async function mergePr({ { branch: branchName, prNo }, 'Branch protection: Attempting to merge PR when PR reviews are enabled' ); - const repository = config.parentRepo || config.repository; + const repository = config.parentRepo ?? config.repository; const reviews = await githubApi.getJson<{ state: string }[]>( `repos/${repository}/pulls/${prNo}/reviews` ); @@ -1493,7 +1490,7 @@ export async function mergePr({ logger.debug('Found approving reviews'); } const url = `repos/${ - config.parentRepo || config.repository + config.parentRepo ?? config.repository }/pulls/${prNo}/merge`; const options: any = { body: {} as { merge_method?: string }, @@ -1579,9 +1576,10 @@ export function massageMarkdown(input: string): string { export async function getVulnerabilityAlerts(): Promise { let vulnerabilityAlerts: { node: VulnerabilityAlert }[] | undefined; + // TODO #7154 const gheSupportsStateFilter = semver.satisfies( // semver not null safe, accepts null and undefined - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + platformConfig.gheVersion!, '>=3.5' ); @@ -1629,7 +1627,7 @@ export async function getVulnerabilityAlerts(): Promise { const key = `${ecosystem.toLowerCase()}/${name}`; const range = vulnerableVersionRange; const elem = shortAlerts[key] || {}; - elem[range] = patch || null; + elem[range] = patch ?? null; shortAlerts[key] = elem; } logger.debug({ alerts: shortAlerts }, 'GitHub vulnerability details'); diff --git a/lib/modules/platform/gitlab/index.ts b/lib/modules/platform/gitlab/index.ts index 6584bcb9152984..53595121dc93b2 100644 --- a/lib/modules/platform/gitlab/index.ts +++ b/lib/modules/platform/gitlab/index.ts @@ -169,7 +169,7 @@ export async function getRawFile( const repo = urlEscape(repoName ?? config.repository); const url = `projects/${repo}/repository/files/${escapedFileName}?ref=` + - (branchOrTag || `HEAD`); + (branchOrTag ?? `HEAD`); const res = await gitlabApi.getJson<{ content: string }>(url); const buf = res.body.content; const str = Buffer.from(buf, 'base64').toString(); @@ -181,7 +181,7 @@ export async function getJsonFile( repoName?: string, branchOrTag?: string ): Promise { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const raw = (await getRawFile(fileName, repoName, branchOrTag)) as string; return JSON5.parse(raw); } @@ -218,12 +218,12 @@ function getRepoUrl( ); } - // TODO: null check #7154 + // TODO: null check (#7154) const { protocol, host, pathname } = parseUrl(defaults.endpoint)!; const newPathname = pathname.slice(0, pathname.indexOf('/api')); const url = URL.format({ protocol: protocol.slice(0, -1) || 'https', - auth: 'oauth2:' + opts.token, + auth: `oauth2:${opts.token}`, host, pathname: newPathname + '/' + repository + '.git', }); @@ -233,7 +233,7 @@ function getRepoUrl( logger.debug({ url: res.body.http_url_to_repo }, `using http URL`); const repoUrl = URL.parse(`${res.body.http_url_to_repo}`); - repoUrl.auth = 'oauth2:' + opts.token; + repoUrl.auth = `oauth2:${opts.token}`; return URL.format(repoUrl); } @@ -579,7 +579,7 @@ export async function createPr({ remove_source_branch: true, title, description, - labels: (labels || []).join(','), + labels: (labels ?? []).join(','), squash: config.squash, }, } @@ -610,7 +610,7 @@ export async function getPr(iid: number): Promise { displayNumber: `Merge Request #${mr.iid}`, bodyStruct: getPrBodyStruct(mr.description), state: mr.state === 'opened' ? PrState.Open : mr.state, - hasAssignees: !!(mr.assignee?.id || mr.assignees?.[0]?.id), + hasAssignees: !!(mr.assignee?.id ?? mr.assignees?.[0]?.id), hasReviewers: !!mr.reviewers?.length, title: mr.title, labels: mr.labels, @@ -634,8 +634,7 @@ export async function updatePr({ const newState = { [PrState.Closed]: 'close', [PrState.Open]: 'reopen', - // TODO: null check #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: null check (#7154) }[state!]; await gitlabApi.putJson( `projects/${config.repository}/merge_requests/${iid}`, @@ -893,7 +892,7 @@ export async function ensureIssue({ body: { title, description, - labels: (labels || issue.labels || []).join(','), + labels: (labels ?? issue.labels ?? []).join(','), confidential: confidential ?? false, }, } @@ -905,7 +904,7 @@ export async function ensureIssue({ body: { title, description, - labels: (labels || []).join(','), + labels: (labels ?? []).join(','), confidential: confidential ?? false, }, }); @@ -1019,7 +1018,7 @@ export async function deleteLabel( logger.debug(`Deleting label ${label} from #${issueNo}`); try { const pr = await getPr(issueNo); - const labels = (pr.labels || []) + const labels = (pr.labels ?? []) .filter((l: string) => l !== label) .join(','); await gitlabApi.putJson( diff --git a/lib/modules/platform/index.ts b/lib/modules/platform/index.ts index 0a4251348f8d34..889d5cc9eaa97f 100644 --- a/lib/modules/platform/index.ts +++ b/lib/modules/platform/index.ts @@ -40,8 +40,7 @@ export function setPlatformApi(name: string): void { export async function initPlatform(config: AllConfig): Promise { setPrivateKey(config.gitPrivateKey); setNoVerify(config.gitNoVerify ?? []); - // TODO: `platform` #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: `platform` (#7154) setPlatformApi(config.platform!); // TODO: types const platformInfo = await platform.initPlatform(config); @@ -57,8 +56,7 @@ export async function initPlatform(config: AllConfig): Promise { // This is done for validation and will be overridden later once repo config is incorporated setGitAuthor(returnConfig.gitAuthor); const platformRule: HostRule = { - // TODO: null check #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO: null check (#7154) matchHost: URL.parse(returnConfig.endpoint).hostname!, }; ( diff --git a/lib/modules/versioning/npm/range.ts b/lib/modules/versioning/npm/range.ts index 647f528740f079..c375f330975cc8 100644 --- a/lib/modules/versioning/npm/range.ts +++ b/lib/modules/versioning/npm/range.ts @@ -56,6 +56,7 @@ function replaceCaretValue(oldValue: string, newValue: string): string { return needReplace ? resultTuple.join('.') : oldValue; } +// TODO: #7154 export function getNewValue({ currentValue, rangeStrategy, @@ -92,14 +93,14 @@ export function getNewValue({ // TODO fix this const splitCurrent = currentValue.split(element.operator); splitCurrent.pop(); - return splitCurrent.join(element.operator) + newValue; + return `${splitCurrent.join(element.operator)}${newValue}`; } if (parsedRange.length > 1) { const previousElement = parsedRange[parsedRange.length - 2]; if (previousElement.operator === '-') { const splitCurrent = currentValue.split('-'); splitCurrent.pop(); - return splitCurrent.join('-') + '- ' + newValue; + return `${splitCurrent.join('-')}- ${newValue}`; } if (element.operator?.startsWith('>')) { logger.warn(`Complex ranges ending in greater than are not supported`); diff --git a/lib/workers/global/index.ts b/lib/workers/global/index.ts index f41b40ad017456..70a32e5b6eb0c9 100644 --- a/lib/workers/global/index.ts +++ b/lib/workers/global/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import is from '@sindresorhus/is'; import { ERROR } from 'bunyan'; import fs from 'fs-extra'; diff --git a/lib/workers/repository/config-migration/branch/migrated-data.ts b/lib/workers/repository/config-migration/branch/migrated-data.ts index a120f7633c3677..ce310b70c9737e 100644 --- a/lib/workers/repository/config-migration/branch/migrated-data.ts +++ b/lib/workers/repository/config-migration/branch/migrated-data.ts @@ -52,7 +52,6 @@ export class MigratedDataFactory { // indent defaults to 2 spaces // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const indent = detectIndent(raw!).indent ?? ' '; let content: string; diff --git a/lib/workers/repository/config-migration/pr/index.ts b/lib/workers/repository/config-migration/pr/index.ts index 3c62ab5852cb37..7ab87877c16d7b 100644 --- a/lib/workers/repository/config-migration/pr/index.ts +++ b/lib/workers/repository/config-migration/pr/index.ts @@ -117,7 +117,7 @@ If you need any further assistance then you can also [request help here](${ } else { const pr = await platform.createPr({ sourceBranch: branchName, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 targetBranch: config.defaultBranch!, prTitle, prBody, diff --git a/lib/workers/repository/dependency-dashboard.spec.ts b/lib/workers/repository/dependency-dashboard.spec.ts index 9a51cecdecc3fa..8fb40454cde2b9 100644 --- a/lib/workers/repository/dependency-dashboard.spec.ts +++ b/lib/workers/repository/dependency-dashboard.spec.ts @@ -518,7 +518,6 @@ describe('workers/repository/dependency-dashboard', () => { config.dependencyDashboard = true; config.dependencyDashboardChecks = { branchName2: 'approve-branch' }; config.dependencyDashboardIssue = 1; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion mockedFunction(platform.getIssue!).mockResolvedValueOnce({ title: 'Dependency Dashboard', body: `This issue contains a list of Renovate updates and their statuses. diff --git a/lib/workers/repository/dependency-dashboard.ts b/lib/workers/repository/dependency-dashboard.ts index 3c2fbcef165013..7289c6b79ec61c 100644 --- a/lib/workers/repository/dependency-dashboard.ts +++ b/lib/workers/repository/dependency-dashboard.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import is from '@sindresorhus/is'; import { nameFromLevel } from 'bunyan'; import { GlobalConfig } from '../../config/global'; @@ -45,7 +45,7 @@ export async function readDashboardBody(config: RenovateConfig): Promise { stringifiedConfig.includes('"prCreation":"approval"') ) { config.dependencyDashboardTitle = - config.dependencyDashboardTitle || `Dependency Dashboard`; + config.dependencyDashboardTitle ?? `Dependency Dashboard`; const issue = await platform.findIssue(config.dependencyDashboardTitle); if (issue) { config.dependencyDashboardIssue = issue.number; @@ -63,7 +63,7 @@ function getListItem(branch: BranchConfig, type: string): string { item += branch.prTitle; } const uniquePackages = [ - ...new Set(branch.upgrades.map((upgrade) => '`' + upgrade.depName + '`')), + ...new Set(branch.upgrades.map((upgrade) => `\`${upgrade.depName}\``)), ]; if (uniquePackages.length < 2) { return item + '\n'; @@ -114,8 +114,8 @@ export async function ensureDependencyDashboard( config.packageRules?.some((rule) => rule.dependencyDashboardApproval) || branches.some( (branch) => - branch.dependencyDashboardApproval || - branch.dependencyDashboardPrApproval + !!branch.dependencyDashboardApproval || + !!branch.dependencyDashboardPrApproval ) ) ) { @@ -271,7 +271,7 @@ export async function ensureDependencyDashboard( branch.prBlockedBy !== 'BranchAutomerge' ); const otherBranches = inProgress.filter( - (branch) => branch.prBlockedBy || !branch.prNo + (branch) => !!branch.prBlockedBy || !branch.prNo ); // istanbul ignore if if (otherBranches.length) { diff --git a/lib/workers/repository/error-config.ts b/lib/workers/repository/error-config.ts index dc42b9a442440c..227e4e4fc51ed4 100644 --- a/lib/workers/repository/error-config.ts +++ b/lib/workers/repository/error-config.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { GlobalConfig } from '../../config/global'; import type { RenovateConfig } from '../../config/types'; import { logger } from '../../logger'; diff --git a/lib/workers/repository/errors-warnings.ts b/lib/workers/repository/errors-warnings.ts index 4c3d0d3ab18b7f..0c2fb0ed6aea09 100644 --- a/lib/workers/repository/errors-warnings.ts +++ b/lib/workers/repository/errors-warnings.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import type { RenovateConfig } from '../../config/types'; import { logger } from '../../logger'; import type { PackageFile } from '../../modules/manager/types'; diff --git a/lib/workers/repository/extract/file-match.ts b/lib/workers/repository/extract/file-match.ts index e13f180b041909..27683f3342eb1c 100644 --- a/lib/workers/repository/extract/file-match.ts +++ b/lib/workers/repository/extract/file-match.ts @@ -40,9 +40,9 @@ export function getFilteredFileList( fileList: string[] ): string[] { const { includePaths, ignorePaths } = config; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 + let filteredList = getIncludedFiles(fileList, includePaths!); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion filteredList = filterIgnoredFiles(filteredList, ignorePaths!); return filteredList; } @@ -54,7 +54,7 @@ export function getMatchingFiles( const fileList = getFilteredFileList(config, allFiles); const { fileMatch, manager } = config; let matchedFiles: string[] = []; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 for (const match of fileMatch!) { logger.debug(`Using file match: ${match} for manager ${manager}`); const re = regEx(match); diff --git a/lib/workers/repository/finalise/prune.ts b/lib/workers/repository/finalise/prune.ts index c7327e3a24f3ac..403140bd786226 100644 --- a/lib/workers/repository/finalise/prune.ts +++ b/lib/workers/repository/finalise/prune.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { GlobalConfig } from '../../../config/global'; import type { RenovateConfig } from '../../../config/types'; import { REPOSITORY_CHANGED } from '../../../constants/error-messages'; @@ -100,6 +99,7 @@ export async function pruneStaleBranches( logger.debug('No branchList'); return; } + // TODO #7154 let renovateBranches = getBranchList().filter((branchName) => branchName.startsWith(config.branchPrefix!) ); diff --git a/lib/workers/repository/index.ts b/lib/workers/repository/index.ts index 6605c5233e5a7f..c176080ec5e24d 100644 --- a/lib/workers/repository/index.ts +++ b/lib/workers/repository/index.ts @@ -62,7 +62,7 @@ export async function renovateRepository( await ensureDependencyDashboard(config, branches); } await finaliseRepo(config, branchList); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 repoResult = processResult(config, res!); } } catch (err) /* istanbul ignore next */ { diff --git a/lib/workers/repository/init/apis.ts b/lib/workers/repository/init/apis.ts index fe21c16925b69b..d1d425ad335ed4 100644 --- a/lib/workers/repository/init/apis.ts +++ b/lib/workers/repository/init/apis.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { configFileNames } from '../../../config/app-strings'; import type { RenovateConfig } from '../../../config/types'; import { @@ -7,11 +6,12 @@ import { } from '../../../constants/error-messages'; import { RepoParams, RepoResult, platform } from '../../../modules/platform'; -// TODO: fix types +// TODO: fix types (#7154) export type WorkerPlatformConfig = RepoResult & RenovateConfig & Record; +// TODO #7154 const defaultConfigFile = (config: RenovateConfig): string => configFileNames.includes(config.onboardingConfigFileName!) ? config.onboardingConfigFileName! @@ -45,7 +45,7 @@ async function validateIncludeForks(config: RenovateConfig): Promise { } } -// TODO: fix types +// TODO: fix types (#7154) async function getPlatformConfig( config: RepoParams ): Promise { @@ -56,7 +56,7 @@ async function getPlatformConfig( }; } -// TODO: fix types +// TODO: fix types (#7154) export async function initApis( input: RenovateConfig ): Promise { diff --git a/lib/workers/repository/init/merge.ts b/lib/workers/repository/init/merge.ts index c623921b5a969f..f0528cef20b26b 100644 --- a/lib/workers/repository/init/merge.ts +++ b/lib/workers/repository/init/merge.ts @@ -205,7 +205,7 @@ export async function mergeRenovateConfig( delete migratedConfig.errors; delete migratedConfig.warnings; logger.debug({ config: migratedConfig }, 'migrated config'); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const repository = config.repository!; // Decrypt before resolving in case we need npm authentication for any presets const decryptedConfig = await decryptConfig(migratedConfig, repository); diff --git a/lib/workers/repository/init/vulnerability.spec.ts b/lib/workers/repository/init/vulnerability.spec.ts index 722a012952b0fe..c8d90421ea2136 100644 --- a/lib/workers/repository/init/vulnerability.spec.ts +++ b/lib/workers/repository/init/vulnerability.spec.ts @@ -24,14 +24,12 @@ describe('workers/repository/init/vulnerability', () => { it('returns if alerts are disabled', async () => { // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion config.vulnerabilityAlerts!.enabled = false; expect(await detectVulnerabilityAlerts(config)).toEqual(config); }); it('returns if no alerts', async () => { // TODO #7154 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion delete config.vulnerabilityAlerts!.enabled; platform.getVulnerabilityAlerts.mockResolvedValue([]); expect(await detectVulnerabilityAlerts(config)).toEqual(config); @@ -47,7 +45,7 @@ describe('workers/repository/init/vulnerability', () => { it('returns alerts and remediations', async () => { config.transitiveRemediation = true; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 delete config.vulnerabilityAlerts!.enabled; platform.getVulnerabilityAlerts.mockResolvedValue([ partial({}), diff --git a/lib/workers/repository/init/vulnerability.ts b/lib/workers/repository/init/vulnerability.ts index ad02bf6c38605d..440a3a33abc3e6 100644 --- a/lib/workers/repository/init/vulnerability.ts +++ b/lib/workers/repository/init/vulnerability.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import type { PackageRule, RenovateConfig } from '../../../config/types'; import { NO_VULNERABILITY_ALERTS } from '../../../constants/error-messages'; import { logger } from '../../../logger'; @@ -44,6 +43,7 @@ type CombinedAlert = Record< > >; +// TODO can return `null` and `undefined` (#7154) export async function detectVulnerabilityAlerts( input: RenovateConfig ): Promise { @@ -108,6 +108,7 @@ export async function detectVulnerabilityAlerts( const firstPatchedVersion = alert.securityVulnerability.firstPatchedVersion.identifier; const advisory = alert.securityAdvisory; + // TODO #7154 let vulnerableRequirements = alert.vulnerableRequirements!; // istanbul ignore if if (!vulnerableRequirements.length) { diff --git a/lib/workers/repository/onboarding/branch/check.ts b/lib/workers/repository/onboarding/branch/check.ts index 7210ce61046924..7225bc38e9b66a 100644 --- a/lib/workers/repository/onboarding/branch/check.ts +++ b/lib/workers/repository/onboarding/branch/check.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { configFileNames } from '../../../../config/app-strings'; import type { RenovateConfig } from '../../../../config/types'; import { @@ -42,7 +41,7 @@ const packageJsonConfigExists = async (): Promise => { return false; }; -// TODO: types +// TODO: types (#7154) export type Pr = any; const closedPrExists = (config: RenovateConfig): Promise => diff --git a/lib/workers/repository/onboarding/branch/config.ts b/lib/workers/repository/onboarding/branch/config.ts index 6236169342a159..1aa01c1fd43eec 100644 --- a/lib/workers/repository/onboarding/branch/config.ts +++ b/lib/workers/repository/onboarding/branch/config.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { GlobalConfig } from '../../../../config/global'; import { getPreset } from '../../../../config/presets/local'; import { PRESET_DEP_NOT_FOUND } from '../../../../config/presets/util'; @@ -21,6 +20,7 @@ async function getOnboardingConfig( 'Checking if this org/owner has a default Renovate preset which can be used.' ); + // TODO #7154 const orgName = config.repository!.split('/')[0]; // Check for org/renovate-config diff --git a/lib/workers/repository/onboarding/branch/create.ts b/lib/workers/repository/onboarding/branch/create.ts index 98870a40b6a2ee..d7865b2fb2bfe3 100644 --- a/lib/workers/repository/onboarding/branch/create.ts +++ b/lib/workers/repository/onboarding/branch/create.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { configFileNames } from '../../../../config/app-strings'; import { GlobalConfig } from '../../../../config/global'; import type { RenovateConfig } from '../../../../config/types'; @@ -12,11 +11,13 @@ const defaultConfigFile = configFileNames[0]; export async function createOnboardingBranch( config: Partial ): Promise { + // TODO #7154 const configFile = configFileNames.includes(config.onboardingConfigFileName!) ? config.onboardingConfigFileName : defaultConfigFile; logger.debug('createOnboardingBranch()'); + // TODO #7154 const contents = await getOnboardingConfigContents(config, configFile!); logger.debug('Creating onboarding branch'); @@ -37,6 +38,7 @@ export async function createOnboardingBranch( files: [ { type: 'addition', + // TODO #7154 path: configFile!, contents, }, diff --git a/lib/workers/repository/onboarding/branch/index.spec.ts b/lib/workers/repository/onboarding/branch/index.spec.ts index 45a73f45cd8cb9..3bd7a3268e919a 100644 --- a/lib/workers/repository/onboarding/branch/index.spec.ts +++ b/lib/workers/repository/onboarding/branch/index.spec.ts @@ -79,7 +79,7 @@ describe('workers/repository/onboarding/branch/index', () => { const file = git.commitFiles.mock.calls[0][0].files[0] as FileAddition; const contents = file.contents?.toString(); expect(contents).toBeJsonString(); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 expect(JSON.parse(contents!)).toEqual({ $schema: 'https://docs.renovatebot.com/renovate-schema.json', }); @@ -113,7 +113,7 @@ describe('workers/repository/onboarding/branch/index', () => { const file = git.commitFiles.mock.calls[0][0].files[0] as FileAddition; const contents = file.contents?.toString(); expect(contents).toBeJsonString(); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 expect(JSON.parse(contents!)).toEqual({ $schema: 'https://docs.renovatebot.com/renovate-schema.json', extends: ['some/renovate-config'], diff --git a/lib/workers/repository/onboarding/branch/index.ts b/lib/workers/repository/onboarding/branch/index.ts index 030998f9d1fb6f..5371c7146e96c0 100644 --- a/lib/workers/repository/onboarding/branch/index.ts +++ b/lib/workers/repository/onboarding/branch/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { mergeChildConfig } from '../../../../config'; import { GlobalConfig } from '../../../../config/global'; import type { RenovateConfig } from '../../../../config/types'; @@ -44,6 +43,7 @@ export async function checkOnboardingBranch( } // istanbul ignore if if (platform.refreshPr) { + // TODO #7154 const onboardingPr = await platform.getBranchPr(config.onboardingBranch!); await platform.refreshPr(onboardingPr!.number); } @@ -72,8 +72,10 @@ export async function checkOnboardingBranch( } } if (!GlobalConfig.get('dryRun')) { + // TODO #7154 await checkoutBranch(onboardingBranch!); } + // TODO #7154 const branchList = [onboardingBranch!]; return { ...config, repoIsOnboarded, onboardingBranch, branchList }; } diff --git a/lib/workers/repository/onboarding/branch/rebase.ts b/lib/workers/repository/onboarding/branch/rebase.ts index 1aadf206ef3132..b4bce2b1ed22e6 100644 --- a/lib/workers/repository/onboarding/branch/rebase.ts +++ b/lib/workers/repository/onboarding/branch/rebase.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { configFileNames } from '../../../../config/app-strings'; import { GlobalConfig } from '../../../../config/global'; import type { RenovateConfig } from '../../../../config/types'; @@ -17,6 +16,7 @@ export async function rebaseOnboardingBranch( config: RenovateConfig ): Promise { logger.debug('Checking if onboarding branch needs rebasing'); + // TODO #7154 if (await isBranchModified(config.onboardingBranch!)) { logger.debug('Onboarding branch has been edited and cannot be rebased'); return null; @@ -24,6 +24,7 @@ export async function rebaseOnboardingBranch( const configFile = defaultConfigFile(config); const existingContents = await getFile(configFile, config.onboardingBranch); const contents = await getOnboardingConfigContents(config, configFile); + // TODO #7154 if ( contents === existingContents && !(await isBranchStale(config.onboardingBranch!)) @@ -45,6 +46,7 @@ export async function rebaseOnboardingBranch( return null; } + // TODO #7154 return commitAndPush({ branchName: config.onboardingBranch!, files: [ diff --git a/lib/workers/repository/onboarding/pr/config-description.ts b/lib/workers/repository/onboarding/pr/config-description.ts index c09ae1096ff59b..7476e6a9534520 100644 --- a/lib/workers/repository/onboarding/pr/config-description.ts +++ b/lib/workers/repository/onboarding/pr/config-description.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import is from '@sindresorhus/is'; import { configFileNames } from '../../../../config/app-strings'; import type { RenovateConfig } from '../../../../config/types'; @@ -34,6 +33,7 @@ export function getConfigDesc( config: RenovateConfig, packageFiles?: Record ): string { + // TODO #7154 const configFile = configFileNames.includes(config.onboardingConfigFileName!) ? config.onboardingConfigFileName : defaultConfigFile; diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts index 409c2c0886defe..d16fb2ab21b042 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import is from '@sindresorhus/is'; import { GlobalConfig } from '../../../../config/global'; import type { RenovateConfig } from '../../../../config/types'; @@ -32,6 +31,7 @@ export async function ensureOnboardingPr( } logger.debug('ensureOnboardingPr()'); logger.trace({ config }); + // TODO #7154 const existingPr = await platform.getBranchPr(config.onboardingBranch!); logger.debug('Filling in onboarding PR template'); let prTemplate = `Welcome to [Renovate](${ @@ -45,6 +45,7 @@ export async function ensureOnboardingPr( : emojify( `:vertical_traffic_light: Renovate will begin keeping your dependencies up-to-date only once you merge or close this Pull Request.\n\n` ); + // TODO #7154 prTemplate += emojify( ` @@ -150,6 +151,7 @@ If you need any further assistance then you can also [request help here](${ if (GlobalConfig.get('dryRun')) { logger.info('DRY-RUN: Would create onboarding PR'); } else { + // TODO #7154 const pr = await platform.createPr({ sourceBranch: config.onboardingBranch!, targetBranch: config.defaultBranch!, diff --git a/lib/workers/repository/onboarding/pr/pr-list.ts b/lib/workers/repository/onboarding/pr/pr-list.ts index 6c4af79aa5dca8..b3fe124b68a5df 100644 --- a/lib/workers/repository/onboarding/pr/pr-list.ts +++ b/lib/workers/repository/onboarding/pr/pr-list.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import type { RenovateConfig } from '../../../../config/types'; import { logger } from '../../../../logger'; import { emojify } from '../../../../util/emoji'; @@ -20,6 +19,7 @@ export function getPrList( for (const branch of branches) { const prTitleRe = regEx(/@([a-z]+\/[a-z]+)/); + // TODO #7154 prDesc += `
\n${branch.prTitle!.replace( prTitleRe, '@​$1' @@ -60,6 +60,7 @@ export function getPrList( prDesc += '\n\n'; prDesc += '
\n\n'; } + // TODO #7154 const prHourlyLimit = config.prHourlyLimit!; if ( prHourlyLimit > 0 && diff --git a/lib/workers/repository/process/deprecated.ts b/lib/workers/repository/process/deprecated.ts index 46469213bd36df..642335326d0ad8 100644 --- a/lib/workers/repository/process/deprecated.ts +++ b/lib/workers/repository/process/deprecated.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { GlobalConfig } from '../../../config/global'; import type { RenovateConfig } from '../../../config/types'; import { logger } from '../../../logger'; diff --git a/lib/workers/repository/process/extract-update.ts b/lib/workers/repository/process/extract-update.ts index eab3f61620d1e3..e0777d8c8a466a 100644 --- a/lib/workers/repository/process/extract-update.ts +++ b/lib/workers/repository/process/extract-update.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import is from '@sindresorhus/is'; import hasha from 'hasha'; import type { RenovateConfig } from '../../../config/types'; diff --git a/lib/workers/repository/process/fetch.ts b/lib/workers/repository/process/fetch.ts index 55905525eab9fe..38e690b12ce69d 100644 --- a/lib/workers/repository/process/fetch.ts +++ b/lib/workers/repository/process/fetch.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import is from '@sindresorhus/is'; import pAll from 'p-all'; import { getManagerConfig, mergeChildConfig } from '../../../config'; diff --git a/lib/workers/repository/process/index.ts b/lib/workers/repository/process/index.ts index 4eb1b36921adbd..83c001eb6a6c17 100644 --- a/lib/workers/repository/process/index.ts +++ b/lib/workers/repository/process/index.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { mergeChildConfig } from '../../../config'; import { GlobalConfig } from '../../../config/global'; import type { RenovateConfig } from '../../../config/types'; diff --git a/lib/workers/repository/process/limits.ts b/lib/workers/repository/process/limits.ts index c26c7d5231c982..f9525e5420577b 100644 --- a/lib/workers/repository/process/limits.ts +++ b/lib/workers/repository/process/limits.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { DateTime } from 'luxon'; import type { RenovateConfig } from '../../../config/types'; import { logger } from '../../../logger'; diff --git a/lib/workers/repository/process/lookup/filter-checks.ts b/lib/workers/repository/process/lookup/filter-checks.ts index a290984b5ea3e7..93044425c83425 100644 --- a/lib/workers/repository/process/lookup/filter-checks.ts +++ b/lib/workers/repository/process/lookup/filter-checks.ts @@ -41,7 +41,7 @@ export async function filterInternalChecks( releaseConfig.updateType = getUpdateType( releaseConfig, versioning, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 currentVersion!, candidateRelease.version ); @@ -70,20 +70,17 @@ export async function filterInternalChecks( continue; } } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + + // TODO #7154 if (isActiveConfidenceLevel(minimumConfidence!)) { const confidenceLevel = await getMergeConfidenceLevel( - // 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, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion updateType! ); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 if (!satisfiesConfidenceLevel(confidenceLevel, minimumConfidence!)) { logger.debug( { depName, check: 'minimumConfidence' }, @@ -113,6 +110,7 @@ export async function filterInternalChecks( } } } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + + // TODO #7154 return { release: release!, pendingChecks, pendingReleases }; } diff --git a/lib/workers/repository/process/lookup/filter.ts b/lib/workers/repository/process/lookup/filter.ts index fa5e63069944d5..54329d083c15cc 100644 --- a/lib/workers/repository/process/lookup/filter.ts +++ b/lib/workers/repository/process/lookup/filter.ts @@ -50,7 +50,7 @@ export function filterVersions( const versionRelease = releases.find( (release) => release.version === v.version ); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 if (versionRelease!.isDeprecated) { logger.trace( `Skipping ${config.depName}@${v.version} because it is deprecated` diff --git a/lib/workers/repository/process/lookup/generate.ts b/lib/workers/repository/process/lookup/generate.ts index 64e272350449a6..89869351aa1cfb 100644 --- a/lib/workers/repository/process/lookup/generate.ts +++ b/lib/workers/repository/process/lookup/generate.ts @@ -66,7 +66,7 @@ export function generateUpdate( return update; } update.updateType = - update.updateType || + update.updateType ?? getUpdateType(config, versioning, currentVersion, newVersion); if (!versioning.isVersion(update.newValue)) { update.isRange = true; @@ -76,7 +76,7 @@ export function generateUpdate( } if ( rangeStrategy === 'bump' && - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 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 9b682b4d03e2ae..157f31062cc207 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -45,7 +45,7 @@ export async function lookupUpdates( isVulnerabilityAlert, updatePinnedDependencies, } = config; - const unconstrainedValue = lockedVersion && is.undefined(currentValue); + const unconstrainedValue = !!lockedVersion && is.undefined(currentValue); const res: UpdateResult = { updates: [], warnings: [], @@ -68,7 +68,7 @@ export async function lookupUpdates( if (unconstrainedValue || isValid) { if ( !updatePinnedDependencies && - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 versioning.isSingleVersion(currentValue!) ) { res.skipReason = 'is-pinned'; @@ -137,7 +137,7 @@ export async function lookupUpdates( // Check that existing constraint can be satisfied const allSatisfyingVersions = allVersions.filter( (v) => - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 unconstrainedValue || versioning.matches(v.version, currentValue!) ); if (rollbackPrs && !allSatisfyingVersions.length) { @@ -158,10 +158,9 @@ export async function lookupUpdates( updateType: 'replacement', newName: dependency.replacementName, newValue: versioning.getNewValue({ - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 currentValue: currentValue!, newVersion: dependency.replacementVersion, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion rangeStrategy: rangeStrategy!, })!, }); @@ -181,40 +180,32 @@ export async function lookupUpdates( if (rangeStrategy === 'update-lockfile') { currentVersion = lockedVersion!; } + // TODO #7154 currentVersion ??= getCurrentVersion( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion currentValue!, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion lockedVersion!, versioning, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion rangeStrategy!, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion latestVersion!, nonDeprecatedVersions - )! || + ) ?? getCurrentVersion( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion currentValue!, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion lockedVersion!, versioning, - // 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 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion if (!currentVersion! && lockedVersion) { return res; } res.currentVersion = currentVersion!; if ( currentValue && - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 currentVersion! && rangeStrategy === 'pin' && !versioning.isSingleVersion(currentValue) @@ -232,17 +223,15 @@ export async function lookupUpdates( }); } // istanbul ignore if - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion if (!versioning.isVersion(currentVersion!)) { res.skipReason = 'invalid-version'; return res; } // Filter latest, unstable, etc + // TODO #7154 let filteredReleases = filterVersions( config, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion currentVersion!, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion latestVersion!, allVersions, versioning @@ -258,7 +247,7 @@ export async function lookupUpdates( for (const release of filteredReleases) { const bucket = getBucket( config, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 currentVersion!, release.version, versioning @@ -291,19 +280,19 @@ export async function lookupUpdates( const update = generateUpdate( config, versioning, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 + rangeStrategy!, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - lockedVersion || currentVersion!, + lockedVersion ?? currentVersion!, bucket, release ); if (pendingChecks) { update.pendingChecks = pendingChecks; } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + + // TODO #7154 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) { @@ -321,7 +310,8 @@ export async function lookupUpdates( res.isSingleVersion = true; } res.isSingleVersion = - res.isSingleVersion || !!versioning.isSingleVersion(update.newValue); + !!res.isSingleVersion || + !!versioning.isSingleVersion(update.newValue); res.updates.push(update); } @@ -352,7 +342,7 @@ export async function lookupUpdates( // digest update res.updates.push({ updateType: 'digest', - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 newValue: currentValue!, }); } @@ -363,24 +353,25 @@ export async function lookupUpdates( res.updates.push({ isPinDigest: true, updateType: 'pinDigest', - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 newValue: currentValue!, }); } } if (versioning.valueToVersion) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 res.currentVersion = versioning.valueToVersion(res.currentVersion!); for (const update of res.updates || []) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 update.newVersion = versioning.valueToVersion(update.newVersion!); } } // update digest for all for (const update of res.updates) { if (pinDigests || currentDigest) { + // TODO #7154 update.newDigest = - update.newDigest || (await getDigest(config, update.newValue))!; + update.newDigest ?? (await getDigest(config, update.newValue))!; } } } @@ -394,7 +385,7 @@ export async function lookupUpdates( (update) => update.newValue !== currentValue || update.isLockfileUpdate || - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 (update.newDigest && !update.newDigest.startsWith(currentDigest!)) ); // If range strategy specified in config is 'in-range-only', also strip out updates where currentValue !== newValue diff --git a/lib/workers/repository/process/lookup/rollback.ts b/lib/workers/repository/process/lookup/rollback.ts index 57cf13bb141fe9..c7440b50b80914 100644 --- a/lib/workers/repository/process/lookup/rollback.ts +++ b/lib/workers/repository/process/lookup/rollback.ts @@ -19,7 +19,7 @@ export function getRollbackUpdate( return null; } const lessThanVersions = versions.filter((v) => - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 version.isLessThanRange!(v.version, currentValue!) ); // istanbul ignore if @@ -55,15 +55,15 @@ export function getRollbackUpdate( return null; } const newValue = version.getNewValue({ - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 currentValue: currentValue!, rangeStrategy: 'replace', newVersion, }); return { bucket: 'rollback', + // TODO #7154 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/sort.ts b/lib/workers/repository/process/sort.ts index ceaabb51646cbb..2286dca3d9d29b 100644 --- a/lib/workers/repository/process/sort.ts +++ b/lib/workers/repository/process/sort.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { logger } from '../../../logger'; import type { BranchConfig } from '../../types'; @@ -17,14 +16,17 @@ export function sortBranches(branches: Partial[]): void { if (a.isVulnerabilityAlert && !b.isVulnerabilityAlert) { return -1; } + // TODO #7154 if (a.prPriority !== b.prPriority) { return b.prPriority! - a.prPriority!; } + // TODO #7154 const sortDiff = sortOrder.indexOf(a.updateType!) - sortOrder.indexOf(b.updateType!); if (sortDiff !== 0) { return sortDiff; } + // TODO #7154 // Sort by prTitle if updateType is the same return a.prTitle! < b.prTitle! ? -1 : 1; }); diff --git a/lib/workers/repository/process/vulnerabilities.ts b/lib/workers/repository/process/vulnerabilities.ts index f540b44cc64abf..9cbe6c9da79945 100644 --- a/lib/workers/repository/process/vulnerabilities.ts +++ b/lib/workers/repository/process/vulnerabilities.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { Ecosystem, Osv, OsvOffline } from '@jamiemagee/osv-offline'; import pAll from 'p-all'; import { getManagerConfig, mergeChildConfig } from '../../../config'; diff --git a/lib/workers/repository/update/branch/auto-replace.spec.ts b/lib/workers/repository/update/branch/auto-replace.spec.ts index ff0a9fa2115544..d2367b1d682945 100644 --- a/lib/workers/repository/update/branch/auto-replace.spec.ts +++ b/lib/workers/repository/update/branch/auto-replace.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { Fixtures } from '../../../../../test/fixtures'; import { defaultConfig } from '../../../../../test/util'; import { GlobalConfig } from '../../../../config/global'; diff --git a/lib/workers/repository/update/branch/auto-replace.ts b/lib/workers/repository/update/branch/auto-replace.ts index 2395f4dc331144..a309e4f3b27aca 100644 --- a/lib/workers/repository/update/branch/auto-replace.ts +++ b/lib/workers/repository/update/branch/auto-replace.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { WORKER_FILE_UPDATE_FAILED } from '../../../../constants/error-messages'; import { logger } from '../../../../logger'; import { get } from '../../../../modules/manager'; diff --git a/lib/workers/repository/update/branch/automerge.ts b/lib/workers/repository/update/branch/automerge.ts index e634f8d7f5f75e..6aeb20a66b1f79 100644 --- a/lib/workers/repository/update/branch/automerge.ts +++ b/lib/workers/repository/update/branch/automerge.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { GlobalConfig } from '../../../../config/global'; import type { RenovateConfig } from '../../../../config/types'; import { logger } from '../../../../logger'; diff --git a/lib/workers/repository/update/branch/check-existing.ts b/lib/workers/repository/update/branch/check-existing.ts index fcd39fc1efa8f4..fad8d013f2b37a 100644 --- a/lib/workers/repository/update/branch/check-existing.ts +++ b/lib/workers/repository/update/branch/check-existing.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { REPOSITORY_CHANGED } from '../../../../constants/error-messages'; import { logger } from '../../../../logger'; import { Pr, platform } from '../../../../modules/platform'; diff --git a/lib/workers/repository/update/branch/commit.spec.ts b/lib/workers/repository/update/branch/commit.spec.ts index 47df38f4bb0fc0..86dd53bd5f43c8 100644 --- a/lib/workers/repository/update/branch/commit.spec.ts +++ b/lib/workers/repository/update/branch/commit.spec.ts @@ -60,7 +60,6 @@ describe('workers/repository/update/branch/commit', () => { expect(platform.commitFiles).toHaveBeenCalledTimes(1); // TODO #7154 expect( - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion mockedFunction(platform.commitFiles!).mock.calls ).toMatchSnapshot(); }); diff --git a/lib/workers/repository/update/branch/commit.ts b/lib/workers/repository/update/branch/commit.ts index e15ced2c2e3334..827d03c5ee77b4 100644 --- a/lib/workers/repository/update/branch/commit.ts +++ b/lib/workers/repository/update/branch/commit.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import is from '@sindresorhus/is'; import minimatch from 'minimatch'; import { GlobalConfig } from '../../../../config/global'; diff --git a/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts b/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts index dca6b59b34c94d..d7d7e0e4ddd013 100644 --- a/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts +++ b/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import is from '@sindresorhus/is'; import minimatch from 'minimatch'; import { GlobalConfig } from '../../../../config/global'; diff --git a/lib/workers/repository/update/branch/handle-existing.ts b/lib/workers/repository/update/branch/handle-existing.ts index e832bc1ffdd695..735ce2b242a56a 100644 --- a/lib/workers/repository/update/branch/handle-existing.ts +++ b/lib/workers/repository/update/branch/handle-existing.ts @@ -10,7 +10,7 @@ import type { BranchConfig } from '../../../types'; export async function handlepr(config: BranchConfig, pr: Pr): Promise { if (pr.state === PrState.Closed) { let content; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const userStrings = config.userStrings!; if (config.updateType === 'major') { content = template.compile(userStrings.ignoreMajor, config); diff --git a/lib/workers/repository/update/branch/index.ts b/lib/workers/repository/update/branch/index.ts index 6df732162e5ee9..1e8c807b312bdc 100644 --- a/lib/workers/repository/update/branch/index.ts +++ b/lib/workers/repository/update/branch/index.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import is from '@sindresorhus/is'; import { DateTime } from 'luxon'; import { GlobalConfig } from '../../../../config/global'; @@ -353,8 +353,8 @@ export async function processBranch( const userRebaseRequested = dependencyDashboardCheck === 'rebase' || - config.dependencyDashboardRebaseAllOpen || - config.rebaseRequested; + !!config.dependencyDashboardRebaseAllOpen || + !!config.rebaseRequested; if (userRebaseRequested) { logger.debug('Manual rebase requested via Dependency Dashboard'); diff --git a/lib/workers/repository/update/branch/reuse.ts b/lib/workers/repository/update/branch/reuse.ts index 11a8e149d7df8a..c1ac3e786fda36 100644 --- a/lib/workers/repository/update/branch/reuse.ts +++ b/lib/workers/repository/update/branch/reuse.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { GlobalConfig } from '../../../../config/global'; import { logger } from '../../../../logger'; import { platform } from '../../../../modules/platform'; diff --git a/lib/workers/repository/update/pr/automerge.ts b/lib/workers/repository/update/pr/automerge.ts index 2ec9b9546c3256..fd875b9bb5b96a 100644 --- a/lib/workers/repository/update/pr/automerge.ts +++ b/lib/workers/repository/update/pr/automerge.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { GlobalConfig } from '../../../../config/global'; import { logger } from '../../../../logger'; import { Pr, platform } from '../../../../modules/platform'; diff --git a/lib/workers/repository/update/pr/changelog/github/index.ts b/lib/workers/repository/update/pr/changelog/github/index.ts index f98a2aeefd5866..a32d6d3e06b5be 100644 --- a/lib/workers/repository/update/pr/changelog/github/index.ts +++ b/lib/workers/repository/update/pr/changelog/github/index.ts @@ -116,7 +116,7 @@ export async function getReleaseList( release: ChangeLogRelease ): Promise { logger.trace('github.getReleaseList()'); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const apiBaseUrl = project.apiBaseUrl!; // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const repository = project.repository!; diff --git a/lib/workers/repository/update/pr/changelog/gitlab/index.ts b/lib/workers/repository/update/pr/changelog/gitlab/index.ts index c24f431aacb732..2fedafb345ca90 100644 --- a/lib/workers/repository/update/pr/changelog/gitlab/index.ts +++ b/lib/workers/repository/update/pr/changelog/gitlab/index.ts @@ -100,7 +100,7 @@ export async function getReleaseList( _release: ChangeLogRelease ): Promise { logger.trace('gitlab.getReleaseNotesMd()'); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + // TODO #7154 const apiBaseUrl = project.apiBaseUrl!; // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const repository = project.repository!; diff --git a/lib/workers/repository/update/pr/changelog/release-notes.ts b/lib/workers/repository/update/pr/changelog/release-notes.ts index efc52019bf815d..964d67b4fcf2dc 100644 --- a/lib/workers/repository/update/pr/changelog/release-notes.ts +++ b/lib/workers/repository/update/pr/changelog/release-notes.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import URL from 'url'; import is from '@sindresorhus/is'; import { DateTime } from 'luxon'; diff --git a/lib/workers/repository/update/pr/changelog/releases.ts b/lib/workers/repository/update/pr/changelog/releases.ts index a0298f48f83813..dfcb2c8b74d7f6 100644 --- a/lib/workers/repository/update/pr/changelog/releases.ts +++ b/lib/workers/repository/update/pr/changelog/releases.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import { logger } from '../../../../../logger'; import { Release, diff --git a/lib/workers/repository/update/pr/changelog/source-github.ts b/lib/workers/repository/update/pr/changelog/source-github.ts index c111c7a28b1756..b081677940ee1b 100644 --- a/lib/workers/repository/update/pr/changelog/source-github.ts +++ b/lib/workers/repository/update/pr/changelog/source-github.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import URL from 'url'; import { GlobalConfig } from '../../../../../config/global'; import { PlatformId } from '../../../../../constants'; diff --git a/lib/workers/repository/update/pr/changelog/source-gitlab.ts b/lib/workers/repository/update/pr/changelog/source-gitlab.ts index 964ced4a93acec..2cd1b38c276109 100644 --- a/lib/workers/repository/update/pr/changelog/source-gitlab.ts +++ b/lib/workers/repository/update/pr/changelog/source-gitlab.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import URL from 'url'; import { logger } from '../../../../../logger'; import type { Release } from '../../../../../modules/datasource/types'; diff --git a/lib/workers/repository/updates/branch-name.ts b/lib/workers/repository/updates/branch-name.ts index abcd703f5cbb9d..d7a0845f8497fe 100644 --- a/lib/workers/repository/updates/branch-name.ts +++ b/lib/workers/repository/updates/branch-name.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import cleanGitRef from 'clean-git-ref'; import hasha from 'hasha'; import slugify from 'slugify'; @@ -38,7 +38,7 @@ export function generateBranchName(update: RenovateConfig): void { logger.debug( `Dependency ${update.depName} is part of group ${update.groupName}` ); - update.groupSlug = slugify(update.groupSlug || update.groupName, { + update.groupSlug = slugify(update.groupSlug ?? update.groupName, { lower: true, }); if (update.updateType === 'major' && update.separateMajorMinor) { @@ -52,8 +52,8 @@ export function generateBranchName(update: RenovateConfig): void { if (update.updateType === 'patch' && update.separateMinorPatch) { update.groupSlug = `patch-${update.groupSlug}`; } - update.branchTopic = update.group!.branchTopic || update.branchTopic; - update.branchName = update.group!.branchName || update.branchName; + update.branchTopic = update.group!.branchTopic ?? update.branchTopic; + update.branchName = update.group!.branchName ?? update.branchName; } if (update.hashedBranchLength) { @@ -83,7 +83,7 @@ export function generateBranchName(update: RenovateConfig): void { const hash = hasha(hashInput); - update.branchName = update.branchPrefix + hash.slice(0, hashLength); + update.branchName = `${update.branchPrefix}${hash.slice(0, hashLength)}`; } else { update.branchName = template.compile(update.branchName!, update); diff --git a/lib/workers/repository/updates/branchify.ts b/lib/workers/repository/updates/branchify.ts index 739cb1a7900298..409662b1099f20 100644 --- a/lib/workers/repository/updates/branchify.ts +++ b/lib/workers/repository/updates/branchify.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +// TODO #7154 import type { Merge } from 'type-fest'; import type { RenovateConfig, ValidationMessage } from '../../../config/types'; import { addMeta, logger, removeMeta } from '../../../logger'; diff --git a/package.json b/package.json index 89f568e33b60d7..51115456ebe5ac 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "ls-lint": "ls-lint", "markdown-lint": "markdownlint-cli2", "markdown-lint-fix": "markdownlint-cli2-fix", - "null-check": "run-s generate:* \"tsc --noEmit -p tsconfig.strict.json {@}\" --", + "strict-check": "run-s generate:* \"tsc --noEmit -p tsconfig.strict.json {@}\" --", "prepare": "run-s prepare:*", "prepare:husky": "husky install", "prepare:generate": "run-s generate:*", @@ -45,7 +45,7 @@ "release:prepare": "node -r ts-node/register/transpile-only -- tools/generate-docs.ts", "release:publish": "node tools/release.mjs", "start": "node -r ts-node/register/transpile-only -- lib/renovate.ts", - "test": "run-s lint test-schema type-check null-check jest", + "test": "run-s lint test-schema type-check strict-check jest", "test-dirty": "git diff --exit-code", "test-e2e": "npm pack && cd test/e2e && yarn install --no-lockfile --ignore-optional --prod && yarn test", "test-schema": "run-s create-json-schema", diff --git a/tsconfig.app.json b/tsconfig.app.json index 2c829289c8551e..01612b0cf5c494 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -3,7 +3,6 @@ "compilerOptions": { "declaration": true, "resolveJsonModule": false, - "noImplicitAny": false, "sourceMap": true, "inlineSources": true, "importHelpers": true, diff --git a/tsconfig.json b/tsconfig.json index 8b013189c8dd52..718277526aa8d1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "strict": true, - "noImplicitAny": false /* TODO: fix me */, - "strictNullChecks": false /* TODO: fix me */, + "noImplicitAny": true, + "strictNullChecks": true, "outDir": "./dist", /* https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping */ "target": "es2020", diff --git a/tsconfig.strict.json b/tsconfig.strict.json index a4aad68848c2b9..67b031600b4a9f 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -1,8 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "strictNullChecks": true, - "noImplicitAny": true + /* TODO add new checks */ }, "exclude": [ // tsconfig.json