From 043f877f29a83b8845f372379f9e1dc8aff101a3 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Tue, 9 Nov 2021 07:37:22 +0100 Subject: [PATCH] chore: eslint consistent-return --- .eslintrc.js | 1 + lib/datasource/cdnjs/index.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 658660bd8a..7162401f80 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -36,6 +36,7 @@ module.exports = { 'import/prefer-default-export': 0, // no benefit // other rules + 'consistent-return': 'error', 'no-negated-condition': 'error', 'no-param-reassign': 'error', 'sort-imports': [ diff --git a/lib/datasource/cdnjs/index.ts b/lib/datasource/cdnjs/index.ts index 7fbce6cb9f..8f3aa41dd2 100644 --- a/lib/datasource/cdnjs/index.ts +++ b/lib/datasource/cdnjs/index.ts @@ -25,6 +25,7 @@ export class CdnJsDatasource extends Datasource { // Each library contains multiple assets, so we cache at the library level instead of per-asset const library = lookupName.split('/')[0]; const url = `${registryUrl}libraries/${library}?fields=homepage,repository,assets`; + let result: ReleaseResult; try { const { assets, homepage, repository } = ( await this.http.getJson<CdnjsResponse>(url) @@ -37,7 +38,7 @@ export class CdnJsDatasource extends Datasource { .filter(({ files }) => files.includes(assetName)) .map(({ version, sri }) => ({ version, newDigest: sri[assetName] })); - const result: ReleaseResult = { releases }; + result = { releases }; if (homepage) { result.homepage = homepage; @@ -45,12 +46,12 @@ export class CdnJsDatasource extends Datasource { if (repository?.url) { result.sourceUrl = repository.url; } - return result; } catch (err) { if (err.statusCode !== 404) { throw new ExternalHostError(err); } this.handleGenericErrors(err); } + return result || null; } } -- GitLab