diff --git a/.eslintrc.js b/.eslintrc.js index 72f2ce598f782b1156018bfe4be07233c0daf669..ffb596076a199d1da66c1ab47573eb3957511636 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -95,7 +95,7 @@ module.exports = { }, ], '@typescript-eslint/prefer-optional-chain': 2, - '@typescript-eslint/prefer-nullish-coalescing': 1, // TODO: Temporary (#7154) + '@typescript-eslint/prefer-nullish-coalescing': 2, curly: [2, 'all'], 'require-await': 2, // next 2 rules disabled due to https://github.com/microsoft/TypeScript/issues/20024 diff --git a/lib/config/massage.ts b/lib/config/massage.ts index 1b7eb50f58119e670eacbb82cbf60383f095d0a5..ef3fff325a9ec79f21217f7856fccd3af32aea68 100644 --- a/lib/config/massage.ts +++ b/lib/config/massage.ts @@ -62,7 +62,7 @@ export function massageConfig(config: RenovateConfig): RenovateConfig { delete newRule[newKey]; } }); - newRule.matchUpdateTypes = rule.matchUpdateTypes || []; + newRule.matchUpdateTypes = rule.matchUpdateTypes ?? []; newRule.matchUpdateTypes.push(key); newRule = { ...newRule, ...val }; newRules.push(newRule); diff --git a/lib/config/migrate-validate.ts b/lib/config/migrate-validate.ts index b9e58ffb2dc5b75da1e7d3e6753d8f1c14ea285b..97433b7e923c10d12a9416cca075df444c5a673b 100644 --- a/lib/config/migrate-validate.ts +++ b/lib/config/migrate-validate.ts @@ -36,9 +36,9 @@ export async function migrateAndValidate( if (is.nonEmptyArray(errors)) { logger.info({ errors }, 'Found renovate config errors'); } - massagedConfig.errors = (config.errors || []).concat(errors); + massagedConfig.errors = (config.errors ?? []).concat(errors); if (!config.repoIsOnboarded) { - massagedConfig.warnings = (config.warnings || []).concat(warnings); + massagedConfig.warnings = (config.warnings ?? []).concat(warnings); } return massagedConfig; } catch (err) /* istanbul ignore next */ { diff --git a/lib/config/presets/index.ts b/lib/config/presets/index.ts index 506c7f042c2dfb4f8637f0d3f9541ca124b16dd7..64594367e69c4c6f14fe26c822d1cb694a04f13d 100644 --- a/lib/config/presets/index.ts +++ b/lib/config/presets/index.ts @@ -181,9 +181,9 @@ export function parsePreset(input: string): ParsedPreset { throw new Error(PRESET_INVALID); } ({ repo, presetPath, presetName, tag } = - nonScopedPresetWithSubdirRegex.exec(str)?.groups || {}); + nonScopedPresetWithSubdirRegex.exec(str)?.groups ?? {}); } else { - ({ repo, presetName, tag } = gitPresetRegex.exec(str)?.groups || {}); + ({ repo, presetName, tag } = gitPresetRegex.exec(str)?.groups ?? {}); if (presetSource === 'npm' && !repo.startsWith('renovate-config-')) { repo = `renovate-config-${repo}`; @@ -270,7 +270,7 @@ export async function resolveConfigPresets( ): Promise<AllConfig> { let ignorePresets = clone(_ignorePresets); if (!ignorePresets || ignorePresets.length === 0) { - ignorePresets = inputConfig.ignorePresets || []; + ignorePresets = inputConfig.ignorePresets ?? []; } logger.trace( { config: inputConfig, existingPresets }, diff --git a/lib/modules/datasource/conan/index.ts b/lib/modules/datasource/conan/index.ts index 66a479686e7a1c0dc79717846e09c914e688a44f..2889565e559719e54cef057befec09ef24c0efcb 100644 --- a/lib/modules/datasource/conan/index.ts +++ b/lib/modules/datasource/conan/index.ts @@ -44,7 +44,7 @@ export class ConanDatasource extends Datasource { json: true, }) as ConanYAML; return { - releases: Object.keys(doc?.versions || {}).map((version) => ({ + releases: Object.keys(doc?.versions ?? {}).map((version) => ({ version, })), }; @@ -80,7 +80,7 @@ export class ConanDatasource extends Datasource { logger.trace({ lookupUrl }, 'Got conan api result'); const dep: ReleaseResult = { releases: [] }; - for (const resultString of Object.values(versions.results || {})) { + for (const resultString of Object.values(versions.results ?? {})) { const fromMatch = conanDatasourceRegex.exec(resultString); if (fromMatch?.groups?.version && fromMatch?.groups?.userChannel) { const version = fromMatch.groups.version; diff --git a/lib/modules/datasource/git-tags/index.ts b/lib/modules/datasource/git-tags/index.ts index e2df233bd81376a4b0c9d6c35d05a020e33a7831..e8773274f6147e18d1239418e2c2f967ddce589b 100644 --- a/lib/modules/datasource/git-tags/index.ts +++ b/lib/modules/datasource/git-tags/index.ts @@ -49,7 +49,7 @@ export class GitTagsDatasource extends GitDatasource { newValue?: string ): Promise<string | null> { const rawRefs = await this.getRawRefs({ packageName }); - const findValue = newValue || 'HEAD'; + const findValue = newValue ?? 'HEAD'; const ref = rawRefs?.find((rawRef) => rawRef.value === findValue); if (ref) { return ref.hash; diff --git a/lib/modules/datasource/go/releases-goproxy.ts b/lib/modules/datasource/go/releases-goproxy.ts index 585476c29ae09175ee4a04cc5ab5056e71dbc08f..27dced5604d6b55972451d219b60023b2e440b8c 100644 --- a/lib/modules/datasource/go/releases-goproxy.ts +++ b/lib/modules/datasource/go/releases-goproxy.ts @@ -172,7 +172,7 @@ export class GoProxyDatasource extends Datasource { static parsedNoproxy: Record<string, RegExp | null> = {}; static parseNoproxy( - input: unknown = process.env.GONOPROXY || process.env.GOPRIVATE + input: unknown = process.env.GONOPROXY ?? process.env.GOPRIVATE ): RegExp | null { if (!is.string(input)) { return null; diff --git a/lib/modules/datasource/npm/get.ts b/lib/modules/datasource/npm/get.ts index d2b418dda5969113ce99ce9ef63a36288119ced9..109b9e94857cc4b9cf7b7d32458768c8cc55e540 100644 --- a/lib/modules/datasource/npm/get.ts +++ b/lib/modules/datasource/npm/get.ts @@ -88,8 +88,8 @@ export async function getDependency( } const latestVersion = res.versions[res['dist-tags']?.latest ?? '']; - res.repository = res.repository || latestVersion?.repository; - res.homepage = res.homepage || latestVersion?.homepage; + res.repository ??= latestVersion?.repository; + res.homepage ??= latestVersion?.homepage; const { sourceUrl, sourceDirectory } = getPackageSource(res.repository); diff --git a/lib/modules/datasource/pypi/index.ts b/lib/modules/datasource/pypi/index.ts index be28036a106522016923260412eed4113947e6f0..dae80c60cd99ccca68dc6ae131b01de5d926be87 100644 --- a/lib/modules/datasource/pypi/index.ts +++ b/lib/modules/datasource/pypi/index.ts @@ -23,7 +23,7 @@ export class PypiDatasource extends Datasource { override readonly customRegistrySupport = true; override readonly defaultRegistryUrls = [ - process.env.PIP_INDEX_URL || 'https://pypi.org/pypi/', + process.env.PIP_INDEX_URL ?? 'https://pypi.org/pypi/', ]; override readonly defaultVersioning = pep440.id; @@ -146,7 +146,7 @@ export class PypiDatasource extends Datasource { if (dep.releases) { const versions = Object.keys(dep.releases); dependency.releases = versions.map((version) => { - const releases = dep.releases?.[version] || []; + const releases = dep.releases?.[version] ?? []; const { upload_time: releaseTimestamp } = releases[0] || {}; const isDeprecated = releases.some(({ yanked }) => yanked); const result: Release = { @@ -260,7 +260,7 @@ export class PypiDatasource extends Datasource { } const versions = Object.keys(releases); dependency.releases = versions.map((version) => { - const versionReleases = releases[version] || []; + const versionReleases = releases[version] ?? []; const isDeprecated = versionReleases.some(({ yanked }) => yanked); const result: Release = { version }; if (isDeprecated) { diff --git a/lib/modules/manager/bazel/extract.ts b/lib/modules/manager/bazel/extract.ts index 8e95883a8b525e0b3d2ed7bb3205982dc6465eb7..8dd033bb0d19147c42fe56bfbcf35fcd54c0350f 100644 --- a/lib/modules/manager/bazel/extract.ts +++ b/lib/modules/manager/bazel/extract.ts @@ -254,7 +254,7 @@ export function extractPackageFile( (currentValue || commit) ) { dep.depName = depName; - dep.currentValue = currentValue || commit?.substring(0, 7); + dep.currentValue = currentValue ?? commit?.substring(0, 7); dep.datasource = GoDatasource.id; dep.packageName = importpath; if (remote) { diff --git a/lib/modules/manager/bazel/update.ts b/lib/modules/manager/bazel/update.ts index d91bb9095168b9a57a50ddbe08c26a9700ed9637..93933e48b8627e11e1dbe33322824a178b0f7bfb 100644 --- a/lib/modules/manager/bazel/update.ts +++ b/lib/modules/manager/bazel/update.ts @@ -93,7 +93,7 @@ export async function updateDependency({ }: UpdateDependencyConfig<BazelManagerData>): Promise<string | null> { try { logger.debug( - `bazel.updateDependency(): ${upgrade.newValue || upgrade.newDigest}` + `bazel.updateDependency(): ${upgrade.newValue ?? upgrade.newDigest}` ); let newDef: string | undefined; if (upgrade.depType === 'container_pull' && upgrade.managerData?.def) { diff --git a/lib/modules/manager/bundler/extract.ts b/lib/modules/manager/bundler/extract.ts index e61e0816a10bf80905a6f8fc3d08fb0b2abae3be..858c6a5ff81a8ee7ce0c264d30f700a734e67f6f 100644 --- a/lib/modules/manager/bundler/extract.ts +++ b/lib/modules/manager/bundler/extract.ts @@ -25,7 +25,7 @@ export async function extractPackageFile( let sourceMatch: RegExpMatchArray | null = null; for (const delimiter of delimiters) { sourceMatch = - sourceMatch || + sourceMatch ?? regEx(`^source ${delimiter}([^${delimiter}]+)${delimiter}\\s*$`).exec( line ); diff --git a/lib/modules/manager/composer/artifacts.ts b/lib/modules/manager/composer/artifacts.ts index 0ac7c6ef0a77a7e9da84d5270b0b2a7661844d95..821366d7189ac1e51e6d2f5886ef822669a0a159 100644 --- a/lib/modules/manager/composer/artifacts.ts +++ b/lib/modules/manager/composer/artifacts.ts @@ -47,13 +47,13 @@ function getAuthJson(): string | null { .findAll({ hostType: PlatformId.Gitlab }) ?.forEach((gitlabHostRule) => { if (gitlabHostRule?.token) { - const host = gitlabHostRule.resolvedHost || 'gitlab.com'; - authJson['gitlab-token'] = authJson['gitlab-token'] || {}; + const host = gitlabHostRule.resolvedHost ?? 'gitlab.com'; + authJson['gitlab-token'] = authJson['gitlab-token'] ?? {}; authJson['gitlab-token'][host] = gitlabHostRule.token; // https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token authJson['gitlab-domains'] = [ host, - ...(authJson['gitlab-domains'] || []), + ...(authJson['gitlab-domains'] ?? []), ]; } }); @@ -63,10 +63,10 @@ function getAuthJson(): string | null { ?.forEach((hostRule) => { const { resolvedHost, username, password, token } = hostRule; if (resolvedHost && username && password) { - authJson['http-basic'] = authJson['http-basic'] || {}; + authJson['http-basic'] = authJson['http-basic'] ?? {}; authJson['http-basic'][resolvedHost] = { username, password }; } else if (resolvedHost && token) { - authJson.bearer = authJson.bearer || {}; + authJson.bearer = authJson.bearer ?? {}; authJson.bearer[resolvedHost] = token; } }); diff --git a/lib/modules/manager/docker-compose/extract.ts b/lib/modules/manager/docker-compose/extract.ts index 503d65f7d50b603c4d16f11fe82a08bf3063547d..0e8bfddb50abe2cc8d5a1dc411f34ab51aa08612 100644 --- a/lib/modules/manager/docker-compose/extract.ts +++ b/lib/modules/manager/docker-compose/extract.ts @@ -64,7 +64,7 @@ export function extractPackageFile( // since docker-compose spec version 1.27, the 'version' key has // become optional and can no longer be used to differentiate // between v1 and v2. - const services = config.services || config; + const services = config.services ?? config; // Image name/tags for services are only eligible for update if they don't // use variables and if the image is not built locally diff --git a/lib/modules/manager/gradle/extract/catalog.ts b/lib/modules/manager/gradle/extract/catalog.ts index 1a556836964e12e58489e20938e5003d267181a9..61a30646a851a8580668e4f9584b8c2a5e577933 100644 --- a/lib/modules/manager/gradle/extract/catalog.ts +++ b/lib/modules/manager/gradle/extract/catalog.ts @@ -233,8 +233,8 @@ export function parseCatalog( content: string ): PackageDependency<GradleManagerData>[] { const tomlContent = parse(content) as GradleCatalog; - const versions = tomlContent.versions || {}; - const libs = tomlContent.libraries || {}; + const versions = tomlContent.versions ?? {}; + const libs = tomlContent.libraries ?? {}; const libStartIndex = content.indexOf('libraries'); const libSubContent = content.slice(libStartIndex); const versionStartIndex = content.indexOf('versions'); @@ -254,7 +254,7 @@ export function parseCatalog( extractedDeps.push(dependency); } - const plugins = tomlContent.plugins || {}; + const plugins = tomlContent.plugins ?? {}; const pluginsStartIndex = content.indexOf('[plugins]'); const pluginsSubContent = content.slice(pluginsStartIndex); for (const pluginName of Object.keys(plugins)) { diff --git a/lib/modules/manager/leiningen/extract.ts b/lib/modules/manager/leiningen/extract.ts index ba22abc15de38bfca205919bf6a2f855b7e02a63..0f89e5b465a8458001f2d62a254639e8261175c5 100644 --- a/lib/modules/manager/leiningen/extract.ts +++ b/lib/modules/manager/leiningen/extract.ts @@ -127,7 +127,7 @@ function extractLeinRepos(content: string): string[] { } const repoSectionContent = repoContent.slice(0, endIdx); const matches = - repoSectionContent.match(regEx(/"https?:\/\/[^"]*"/g)) || []; + repoSectionContent.match(regEx(/"https?:\/\/[^"]*"/g)) ?? []; const urls = matches.map((x) => x.replace(regEx(/^"/), '').replace(regEx(/"$/), '') ); diff --git a/lib/modules/manager/mix/extract.ts b/lib/modules/manager/mix/extract.ts index 5b69f71f5f508f9c84e8f9251d2634306964ab72..c8b0815f65356a36b77c36f4c1db3f7776f09812 100644 --- a/lib/modules/manager/mix/extract.ts +++ b/lib/modules/manager/mix/extract.ts @@ -57,7 +57,7 @@ export async function extractPackageFile( } const res: PackageFile = { deps }; const lockFileName = - (await findLocalSiblingOrParent(fileName, 'mix.lock')) || 'mix.lock'; + (await findLocalSiblingOrParent(fileName, 'mix.lock')) ?? 'mix.lock'; // istanbul ignore if if (await localPathExists(lockFileName)) { res.lockFiles = [lockFileName]; diff --git a/lib/modules/manager/nuget/artifacts.ts b/lib/modules/manager/nuget/artifacts.ts index aef764c406b20957089d3cf57da2ada07aa5877e..f5c89bc99b87898e417b9189f06845b2727b5693 100644 --- a/lib/modules/manager/nuget/artifacts.ts +++ b/lib/modules/manager/nuget/artifacts.ts @@ -35,7 +35,7 @@ async function addSourceCmds( nugetConfigFile: string ): Promise<string[]> { const registries = - (await getConfiguredRegistries(packageFileName)) || getDefaultRegistries(); + (await getConfiguredRegistries(packageFileName)) ?? getDefaultRegistries(); const result: string[] = []; for (const registry of registries) { const { username, password } = hostRules.find({ diff --git a/lib/modules/manager/poetry/update-locked.ts b/lib/modules/manager/poetry/update-locked.ts index 0bda7b89e7575708960d1e60620726afa220382f..a582b11675c5c0221112a0a254594474d3927e13 100644 --- a/lib/modules/manager/poetry/update-locked.ts +++ b/lib/modules/manager/poetry/update-locked.ts @@ -10,7 +10,7 @@ export function updateLockedDependency( logger.debug( `poetry.updateLockedDependency: ${depName}@${currentVersion} -> ${newVersion} [${lockFile}]` ); - const locked = extractLockFileEntries(lockFileContent || ''); + const locked = extractLockFileEntries(lockFileContent ?? ''); if (depName && locked[depName] === newVersion) { return { status: 'already-updated' }; } diff --git a/lib/modules/manager/regex/strategies.ts b/lib/modules/manager/regex/strategies.ts index 211eef7c6e33560fe73a092726ae301203a4e990..13f07260e011a18c7917c9aeadd6a9034525ae08 100644 --- a/lib/modules/manager/regex/strategies.ts +++ b/lib/modules/manager/regex/strategies.ts @@ -79,7 +79,7 @@ export function handleRecursive( packageFile, config, index + 1, - mergeGroups(combinedGroups, match.groups || {}) + mergeGroups(combinedGroups, match.groups ?? {}) ); }) .filter(is.truthy); diff --git a/lib/modules/manager/regex/utils.ts b/lib/modules/manager/regex/utils.ts index 772c52ccb596540cbfa23221a9ecf26696fbab35..9efd4946cc4ce87208130fedfa9252b7fd877b7a 100644 --- a/lib/modules/manager/regex/utils.ts +++ b/lib/modules/manager/regex/utils.ts @@ -24,7 +24,7 @@ export function createDependency( config: CustomExtractConfig, dep?: PackageDependency ): PackageDependency | null { - const dependency = dep || {}; + const dependency = dep ?? {}; const { groups, replaceString } = extractionTemplate; function updateDependency(field: ValidMatchFields, value: string): void { diff --git a/lib/modules/manager/setup-cfg/extract.ts b/lib/modules/manager/setup-cfg/extract.ts index fde51f973733f26538579236273df40a1167cae8..2b458fb180c6f37140a4404c2ed25f4c7c2131d7 100644 --- a/lib/modules/manager/setup-cfg/extract.ts +++ b/lib/modules/manager/setup-cfg/extract.ts @@ -6,12 +6,12 @@ import { PypiDatasource } from '../../datasource/pypi'; import type { PackageDependency, PackageFile, Result } from '../types'; function getSectionName(str: string): string { - const [, sectionName] = regEx(/^\[\s*([^\s]+)\s*]\s*$/).exec(str) || []; + const [, sectionName] = regEx(/^\[\s*([^\s]+)\s*]\s*$/).exec(str) ?? []; return sectionName; } function getSectionRecord(str: string): string { - const [, sectionRecord] = regEx(/^([^\s]+)\s+=/).exec(str) || []; + const [, sectionRecord] = regEx(/^([^\s]+)\s+=/).exec(str) ?? []; return sectionRecord; } @@ -62,7 +62,7 @@ function parseDep( const [lineNoEnvMarkers] = line.split(';').map((part) => part.trim()); const packageMatches = - pkgValRegex.exec(lineNoEnvMarkers) || pkgRegex.exec(lineNoEnvMarkers); + pkgValRegex.exec(lineNoEnvMarkers) ?? pkgRegex.exec(lineNoEnvMarkers); if (!packageMatches) { return null; diff --git a/lib/modules/manager/terraform/extract/kubernetes.ts b/lib/modules/manager/terraform/extract/kubernetes.ts index dee54e8fb0e29eeefda74dd41f01d5b7f6aeff88..b7cb79b3d68d8404b83ea50d68205f13d6bdfcd3 100644 --- a/lib/modules/manager/terraform/extract/kubernetes.ts +++ b/lib/modules/manager/terraform/extract/kubernetes.ts @@ -31,8 +31,8 @@ export function extractTerraformKubernetesResource( // 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; if (line.match(regEx(/^\s*(?:init_)?container(?:\s*\{|$)/s))) { diff --git a/lib/modules/manager/terraform/required-version.ts b/lib/modules/manager/terraform/required-version.ts index 9b6063e5489b709c0d2623fc2dc208368ce3e21a..f958217bc3b4ffe7975c60cb9d4ad932ab40e89e 100644 --- a/lib/modules/manager/terraform/required-version.ts +++ b/lib/modules/manager/terraform/required-version.ts @@ -21,8 +21,8 @@ export function extractTerraformRequiredVersion( const line = lines[lineNumber]; // `{` will be counted wit +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); diff --git a/lib/modules/platform/bitbucket/index.spec.ts b/lib/modules/platform/bitbucket/index.spec.ts index 306a5d385f834f8aef708501d63912d4a3ff0f0c..b9fdcfb80eefab5415d3805bfd6c886880652ce9 100644 --- a/lib/modules/platform/bitbucket/index.spec.ts +++ b/lib/modules/platform/bitbucket/index.spec.ts @@ -50,9 +50,9 @@ describe('modules/platform/bitbucket/index', () => { repoResp?: any, existingScope?: httpMock.Scope ): Promise<httpMock.Scope> { - const repository = config?.repository || 'some/repo'; + const repository = config?.repository ?? 'some/repo'; - const scope = existingScope || httpMock.scope(baseUrl); + const scope = existingScope ?? httpMock.scope(baseUrl); scope.get(`/2.0/repositories/${repository}`).reply(200, { owner: {}, diff --git a/lib/modules/platform/gitlab/index.spec.ts b/lib/modules/platform/gitlab/index.spec.ts index 2a5467d18e64c0f20ae666b0e7f48027ee7ba782..4292c28de1a775f0f4c11702b356c582f90a1067 100644 --- a/lib/modules/platform/gitlab/index.spec.ts +++ b/lib/modules/platform/gitlab/index.spec.ts @@ -180,7 +180,7 @@ describe('modules/platform/gitlab/index', () => { const justRepo = repo.split('/').slice(0, 2).join('/'); scope.get(`/api/v4/projects/${encodeURIComponent(repo)}`).reply( 200, - repoResp || { + repoResp ?? { default_branch: 'master', http_url_to_repo: `https://gitlab.com/${justRepo}.git`, } diff --git a/lib/modules/versioning/conan/range.ts b/lib/modules/versioning/conan/range.ts index 769fcc69cb464b31d5cd44155abd9c644f9da006..11e77a84422758b75251e12ad86b1ce83fedf7c4 100644 --- a/lib/modules/versioning/conan/range.ts +++ b/lib/modules/versioning/conan/range.ts @@ -89,7 +89,7 @@ export function fixParsedRange(range: string): any { major, }; - let full = `${operator || ''}${major}`; + let full = `${operator ?? ''}${major}`; if (minor) { NewSemVer.minor = minor; full = `${full}.${minor}`; diff --git a/lib/modules/versioning/node/schedule.ts b/lib/modules/versioning/node/schedule.ts index b346b5af2ebb17241e9d778336c46fb08f9e9fc9..fb45860c0042653b2f988ff3d995141f8d6c99ce 100644 --- a/lib/modules/versioning/node/schedule.ts +++ b/lib/modules/versioning/node/schedule.ts @@ -31,7 +31,7 @@ for (const version of Object.keys(nodeSchedule)) { export function findScheduleForCodename( codename: string ): NodeJsScheduleWithVersion | null { - return nodeCodenames.get(codename?.toUpperCase()) || null; + return nodeCodenames.get(codename?.toUpperCase()) ?? null; } export function findScheduleForVersion(version: string): NodeJsSchedule | null { diff --git a/lib/modules/versioning/pep440/range.ts b/lib/modules/versioning/pep440/range.ts index ca7efbad6ce5e349e43dd8eb78cc5fada8da74d9..ab112037079b310eb35c574432532edcca0f7346 100644 --- a/lib/modules/versioning/pep440/range.ts +++ b/lib/modules/versioning/pep440/range.ts @@ -70,7 +70,7 @@ function getFutureVersion( ): number[] { const toRelease: number[] = parseVersion(newVersion)?.release ?? []; const baseRelease: number[] = - parseVersion(baseVersion || newVersion)?.release ?? []; + parseVersion(baseVersion ?? newVersion)?.release ?? []; return baseRelease.map((_, index) => { const toPart: number = toRelease[index] ?? 0; if (index < policy) { diff --git a/lib/util/package-rules.ts b/lib/util/package-rules.ts index 64932b25108c391f41d3ca03f7223dea30f7e50a..5447e82fd2a9a5283677ea8bc98d758c2f268d76 100644 --- a/lib/util/package-rules.ts +++ b/lib/util/package-rules.ts @@ -29,25 +29,25 @@ function matchesRule( manager, datasource, } = inputConfig; - const unconstrainedValue = lockedVersion && is.undefined(currentValue); + const unconstrainedValue = !!lockedVersion && is.undefined(currentValue); // Setting empty arrays simplifies our logic later - const matchFiles = packageRule.matchFiles || []; - const matchPaths = packageRule.matchPaths || []; - const matchLanguages = packageRule.matchLanguages || []; - const matchBaseBranches = packageRule.matchBaseBranches || []; - const matchManagers = packageRule.matchManagers || []; - const matchDatasources = packageRule.matchDatasources || []; - const matchDepTypes = packageRule.matchDepTypes || []; - const matchPackageNames = packageRule.matchPackageNames || []; - let matchPackagePatterns = packageRule.matchPackagePatterns || []; - const matchPackagePrefixes = packageRule.matchPackagePrefixes || []; - const excludePackageNames = packageRule.excludePackageNames || []; - const excludePackagePatterns = packageRule.excludePackagePatterns || []; - const excludePackagePrefixes = packageRule.excludePackagePrefixes || []; - const matchSourceUrlPrefixes = packageRule.matchSourceUrlPrefixes || []; - const matchSourceUrls = packageRule.matchSourceUrls || []; - const matchCurrentVersion = packageRule.matchCurrentVersion || null; - const matchUpdateTypes = packageRule.matchUpdateTypes || []; + const matchFiles = packageRule.matchFiles ?? []; + const matchPaths = packageRule.matchPaths ?? []; + const matchLanguages = packageRule.matchLanguages ?? []; + const matchBaseBranches = packageRule.matchBaseBranches ?? []; + const matchManagers = packageRule.matchManagers ?? []; + const matchDatasources = packageRule.matchDatasources ?? []; + const matchDepTypes = packageRule.matchDepTypes ?? []; + const matchPackageNames = packageRule.matchPackageNames ?? []; + let matchPackagePatterns = packageRule.matchPackagePatterns ?? []; + const matchPackagePrefixes = packageRule.matchPackagePrefixes ?? []; + const excludePackageNames = packageRule.excludePackageNames ?? []; + const excludePackagePatterns = packageRule.excludePackagePatterns ?? []; + const excludePackagePrefixes = packageRule.excludePackagePrefixes ?? []; + const matchSourceUrlPrefixes = packageRule.matchSourceUrlPrefixes ?? []; + const matchSourceUrls = packageRule.matchSourceUrls ?? []; + const matchCurrentVersion = packageRule.matchCurrentVersion ?? null; + const matchUpdateTypes = packageRule.matchUpdateTypes ?? []; let positiveMatch = false; // Massage a positive patterns patch if an exclude one is present if ( @@ -269,7 +269,7 @@ function matchesRule( const compareVersion = currentValue && version.isVersion(currentValue) ? currentValue // it's a version so we can match against it - : lockedVersion || currentVersion; // need to match against this currentVersion, if available + : lockedVersion ?? currentVersion; // need to match against this currentVersion, if available if (compareVersion) { // istanbul ignore next if (version.isVersion(compareVersion)) { @@ -298,7 +298,7 @@ export function applyPackageRules<T extends PackageRuleInputConfig>( inputConfig: T ): T { let config = { ...inputConfig }; - const packageRules = config.packageRules || []; + const packageRules = config.packageRules ?? []; logger.trace( { dependency: config.depName, packageRules }, `Checking against ${packageRules.length} packageRules` diff --git a/lib/workers/global/limits.ts b/lib/workers/global/limits.ts index 6e410dd2204dcbc3ad87eb973570f020fafcbd6e..c81c2d5d1f16fa7c5467518167675bdac5cf1179 100644 --- a/lib/workers/global/limits.ts +++ b/lib/workers/global/limits.ts @@ -25,7 +25,7 @@ export function setMaxLimit(key: Limit, val: unknown): void { } export function incLimitedValue(key: Limit, incBy = 1): void { - const limit = limits.get(key) || { max: null, current: 0 }; + const limit = limits.get(key) ?? { max: null, current: 0 }; limits.set(key, { ...limit, current: limit.current + incBy, diff --git a/lib/workers/repository/cache.ts b/lib/workers/repository/cache.ts index 49f0deb3bf61a103672b50f6da4588c792c71506..c651af91a704352c399ca5fac4d10b9a63d7edf6 100644 --- a/lib/workers/repository/cache.ts +++ b/lib/workers/repository/cache.ts @@ -49,7 +49,7 @@ async function generateBranchCache( ): Promise<BranchCache | null> { const { branchName } = branch; try { - const sha = getBranchCommit(branchName) || null; + const sha = getBranchCommit(branchName) ?? null; let prNo = null; let parentSha = null; if (sha) { diff --git a/lib/workers/repository/update/pr/body/index.ts b/lib/workers/repository/update/pr/body/index.ts index 7e277179127c9cea5d91a1d0bad8e40d97bf6160..4afbf92cf75939a8b011fb5824089e4d465ded7a 100644 --- a/lib/workers/repository/update/pr/body/index.ts +++ b/lib/workers/repository/update/pr/body/index.ts @@ -21,7 +21,7 @@ function massageUpdateMetadata(config: BranchConfig): void { dependencyUrl, } = upgrade; let depNameLinked = upgrade.depName; - const primaryLink = homepage || sourceUrl || dependencyUrl; + const primaryLink = homepage ?? sourceUrl ?? dependencyUrl; if (primaryLink) { depNameLinked = `[${depNameLinked}](${primaryLink})`; } diff --git a/lib/workers/repository/update/pr/code-owners.ts b/lib/workers/repository/update/pr/code-owners.ts index 80f3daeb2c1ad56669612dc5431ee1332baf5f75..081fa6797e0a0a8cc1feeb247c4cf8ea374d346c 100644 --- a/lib/workers/repository/update/pr/code-owners.ts +++ b/lib/workers/repository/update/pr/code-owners.ts @@ -9,9 +9,9 @@ export async function codeOwnersForPr(pr: Pr): Promise<string[]> { logger.debug('Searching for CODEOWNERS file'); try { const codeOwnersFile = - (await readLocalFile('CODEOWNERS', 'utf8')) || - (await readLocalFile('.github/CODEOWNERS', 'utf8')) || - (await readLocalFile('.gitlab/CODEOWNERS', 'utf8')) || + (await readLocalFile('CODEOWNERS', 'utf8')) ?? + (await readLocalFile('.github/CODEOWNERS', 'utf8')) ?? + (await readLocalFile('.gitlab/CODEOWNERS', 'utf8')) ?? (await readLocalFile('docs/CODEOWNERS', 'utf8')); if (!codeOwnersFile) { diff --git a/lib/workers/repository/update/pr/index.ts b/lib/workers/repository/update/pr/index.ts index ce4f4cf7d2d476eb2a8299e0a8a89f756b34c937..33a6adabbded1ba157efba6abcb16dca8b6a6863 100644 --- a/lib/workers/repository/update/pr/index.ts +++ b/lib/workers/repository/update/pr/index.ts @@ -180,7 +180,7 @@ export async function ensurePr( for (const upgrade of upgrades) { const upgradeKey = `${upgrade.depType}-${upgrade.depName}-${ upgrade.manager - }-${upgrade.currentVersion || upgrade.currentValue}-${upgrade.newVersion}`; + }-${upgrade.currentVersion ?? upgrade.currentValue}-${upgrade.newVersion}`; if (processedUpgrades.includes(upgradeKey)) { continue; } diff --git a/test/website-docs.spec.ts b/test/website-docs.spec.ts index 98195ba353ce3be833f828abe60bbdb239e2cb7d..a856acf2d55fc302cde71d89755302f919e8d593 100644 --- a/test/website-docs.spec.ts +++ b/test/website-docs.spec.ts @@ -42,7 +42,7 @@ describe('website-docs', () => { .sort(); const selfHostExpectedOptions = options - .filter((option) => option.globalOnly || option.stage === 'global') + .filter((option) => !!option.globalOnly || option.stage === 'global') .map((option) => option.name) .sort();