From f0a1b64b15963114fd3976f8a77e4ff4134748c6 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov <zharinov@users.noreply.github.com> Date: Sun, 6 Feb 2022 18:42:11 +0300 Subject: [PATCH] refactor(datasource/orb): Enable strict null checks (#14042) --- lib/datasource/orb/index.ts | 20 ++++++++++---------- tsconfig.strict.json | 1 - 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/datasource/orb/index.ts b/lib/datasource/orb/index.ts index 59b9ff90b1..0c903b6ac0 100644 --- a/lib/datasource/orb/index.ts +++ b/lib/datasource/orb/index.ts @@ -36,6 +36,10 @@ export class OrbDatasource extends Datasource { lookupName, registryUrl, }: GetReleasesConfig): Promise<ReleaseResult | null> { + // istanbul ignore if + if (!registryUrl) { + return null; + } const url = `${registryUrl}graphql-unstable`; const body = { query, @@ -51,19 +55,15 @@ export class OrbDatasource extends Datasource { return null; } // Simplify response before caching and returning - const dep: ReleaseResult = { - releases: null, - }; - if (res.homeUrl?.length) { - dep.homepage = res.homeUrl; - } - dep.homepage = - dep.homepage || `https://circleci.com/developer/orbs/orb/${lookupName}`; - dep.releases = res.versions.map(({ version, createdAt }) => ({ + const homepage = res.homeUrl?.length + ? res.homeUrl + : `https://circleci.com/developer/orbs/orb/${lookupName}`; + const releases = res.versions.map(({ version, createdAt }) => ({ version, - releaseTimestamp: createdAt || null, + releaseTimestamp: createdAt ?? null, })); + const dep = { homepage, releases }; logger.trace({ dep }, 'dep'); return dep; } diff --git a/tsconfig.strict.json b/tsconfig.strict.json index b7bbf39761..fee429149b 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -118,7 +118,6 @@ "lib/datasource/nuget/index.ts", "lib/datasource/nuget/v2.ts", "lib/datasource/nuget/v3.ts", - "lib/datasource/orb/index.ts", "lib/datasource/packagist/index.ts", "lib/datasource/pod/index.ts", "lib/datasource/pypi/index.ts", -- GitLab