From 9b4bff00518e1eacf33fa9618c6156f42723bfd3 Mon Sep 17 00:00:00 2001
From: Michael Kriese <michael.kriese@visualon.de>
Date: Wed, 22 Jul 2020 07:45:57 +0200
Subject: [PATCH] fix(internal): fix linting (#6803)

---
 .eslintrc.js                                     |  1 +
 lib/config/presets/github/index.ts               |  2 +-
 lib/config/presets/gitlab/index.ts               |  2 +-
 lib/config/presets/local/index.spec.ts           | 16 ++++++++--------
 lib/config/presets/local/index.ts                |  2 +-
 lib/datasource/index.ts                          |  4 ++--
 lib/datasource/packagist/index.ts                |  2 +-
 lib/datasource/rubygems/releases.ts              |  2 +-
 lib/manager/gradle-wrapper/artifacts.ts          |  2 +-
 lib/platform/bitbucket-server/utils.ts           |  2 +-
 lib/platform/bitbucket/utils.ts                  |  2 +-
 lib/util/fs/proxies.ts                           | 14 +++++++-------
 lib/util/git/index.ts                            |  2 +-
 lib/util/http/bitbucket-server.ts                |  2 +-
 lib/util/http/bitbucket.ts                       |  2 +-
 lib/util/http/index.ts                           | 12 ++++++------
 lib/workers/branch/commit.ts                     |  2 +-
 lib/workers/pr/changelog/release-notes.ts        |  2 +-
 lib/workers/pr/changelog/source-github.ts        |  5 +----
 lib/workers/pr/changelog/source-gitlab.ts        |  2 +-
 .../repository/onboarding/branch/create.ts       |  2 +-
 21 files changed, 40 insertions(+), 42 deletions(-)

diff --git a/.eslintrc.js b/.eslintrc.js
index da919a5080..e718d2a85a 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -83,6 +83,7 @@ module.exports = {
     '@typescript-eslint/prefer-optional-chain': 2,
     '@typescript-eslint/prefer-nullish-coalescing': 2,
     curly: [2, 'all'],
+    'require-await': 2,
   },
   settings: {
     // https://github.com/benmosher/eslint-plugin-import/issues/1618
diff --git a/lib/config/presets/github/index.ts b/lib/config/presets/github/index.ts
index 027cfed7f1..71634e3359 100644
--- a/lib/config/presets/github/index.ts
+++ b/lib/config/presets/github/index.ts
@@ -37,7 +37,7 @@ export async function fetchJSONFile(
   }
 }
 
-export async function getPresetFromEndpoint(
+export function getPresetFromEndpoint(
   pkgName: string,
   filePreset: string,
   endpoint = Endpoint
diff --git a/lib/config/presets/gitlab/index.ts b/lib/config/presets/gitlab/index.ts
index 0e7f9d0c93..fa6f1aec1c 100644
--- a/lib/config/presets/gitlab/index.ts
+++ b/lib/config/presets/gitlab/index.ts
@@ -53,7 +53,7 @@ export async function fetchJSONFile(
   }
 }
 
-export async function getPresetFromEndpoint(
+export function getPresetFromEndpoint(
   pkgName: string,
   presetName: string,
   endpoint = Endpoint
diff --git a/lib/config/presets/local/index.spec.ts b/lib/config/presets/local/index.spec.ts
index acf2e8b4ed..82a24acc0a 100644
--- a/lib/config/presets/local/index.spec.ts
+++ b/lib/config/presets/local/index.spec.ts
@@ -17,26 +17,26 @@ describe(getName(__filename), () => {
   });
   describe('getPreset()', () => {
     it('throws for unsupported platform', async () => {
-      await expect(
-        local.getPreset({
+      await expect(async () => {
+        await local.getPreset({
           packageName: 'some/repo',
           presetName: 'default',
           baseConfig: {
             platform: 'unsupported-platform',
           },
-        })
-      ).rejects.toThrow();
+        });
+      }).rejects.toThrow();
     });
     it('throws for missing platform', async () => {
-      await expect(
-        local.getPreset({
+      await expect(async () => {
+        await local.getPreset({
           packageName: 'some/repo',
           presetName: 'default',
           baseConfig: {
             platform: undefined,
           },
-        })
-      ).rejects.toThrow();
+        });
+      }).rejects.toThrow();
     });
     it('forwards to gitlab', async () => {
       const content = await local.getPreset({
diff --git a/lib/config/presets/local/index.ts b/lib/config/presets/local/index.ts
index c501d1c237..9a98550c0b 100644
--- a/lib/config/presets/local/index.ts
+++ b/lib/config/presets/local/index.ts
@@ -6,7 +6,7 @@ import { Preset, PresetConfig } from '../common';
 import * as github from '../github';
 import * as gitlab from '../gitlab';
 
-export async function getPreset({
+export function getPreset({
   packageName: pkgName,
   presetName = 'default',
   baseConfig,
diff --git a/lib/datasource/index.ts b/lib/datasource/index.ts
index f52ec82090..dbae11adc2 100644
--- a/lib/datasource/index.ts
+++ b/lib/datasource/index.ts
@@ -55,7 +55,7 @@ async function getRegistryReleases(
   return res;
 }
 
-async function firstRegistry(
+function firstRegistry(
   config: GetReleasesInternalConfig,
   datasource: Datasource,
   registryUrls: string[]
@@ -278,7 +278,7 @@ export function supportsDigests(config: DigestConfig): boolean {
   return 'getDigest' in load(config.datasource);
 }
 
-export async function getDigest(
+export function getDigest(
   config: DigestConfig,
   value?: string
 ): Promise<string | null> {
diff --git a/lib/datasource/packagist/index.ts b/lib/datasource/packagist/index.ts
index 34a3b62c6a..932bd6ef48 100644
--- a/lib/datasource/packagist/index.ts
+++ b/lib/datasource/packagist/index.ts
@@ -287,7 +287,7 @@ async function packageLookup(
   }
 }
 
-export async function getReleases({
+export function getReleases({
   lookupName,
   registryUrl,
 }: GetReleasesConfig): Promise<ReleaseResult> {
diff --git a/lib/datasource/rubygems/releases.ts b/lib/datasource/rubygems/releases.ts
index c7458eb53e..b010ccf347 100644
--- a/lib/datasource/rubygems/releases.ts
+++ b/lib/datasource/rubygems/releases.ts
@@ -2,7 +2,7 @@ import { GetReleasesConfig, ReleaseResult } from '../common';
 import { getDependency } from './get';
 import { getRubygemsOrgDependency } from './get-rubygems-org';
 
-export async function getReleases({
+export function getReleases({
   lookupName,
   registryUrl,
 }: GetReleasesConfig): Promise<ReleaseResult | null> {
diff --git a/lib/manager/gradle-wrapper/artifacts.ts b/lib/manager/gradle-wrapper/artifacts.ts
index 389fa9a0bc..c359adddd9 100644
--- a/lib/manager/gradle-wrapper/artifacts.ts
+++ b/lib/manager/gradle-wrapper/artifacts.ts
@@ -112,7 +112,7 @@ export async function updateArtifacts({
     );
     const updateArtifactsResult = (
       await Promise.all(
-        artifactFileNames.map(async (fileProjectPath) =>
+        artifactFileNames.map((fileProjectPath) =>
           addIfUpdated(status, fileProjectPath)
         )
       )
diff --git a/lib/platform/bitbucket-server/utils.ts b/lib/platform/bitbucket-server/utils.ts
index ea90482844..764f450dba 100644
--- a/lib/platform/bitbucket-server/utils.ts
+++ b/lib/platform/bitbucket-server/utils.ts
@@ -41,7 +41,7 @@ const addMaxLength = (inputUrl: string, limit = 100): string => {
   return maxedUrl;
 };
 
-async function callApi<T>(
+function callApi<T>(
   apiUrl: string,
   method: string,
   options?: any
diff --git a/lib/platform/bitbucket/utils.ts b/lib/platform/bitbucket/utils.ts
index c52f13a29e..6bb0c63219 100644
--- a/lib/platform/bitbucket/utils.ts
+++ b/lib/platform/bitbucket/utils.ts
@@ -75,7 +75,7 @@ const addMaxLength = (inputUrl: string, pagelen = 100): string => {
   return maxedUrl;
 };
 
-async function callApi<T>(
+function callApi<T>(
   apiUrl: string,
   method: string,
   options?: any
diff --git a/lib/util/fs/proxies.ts b/lib/util/fs/proxies.ts
index 946707f666..0624325e06 100644
--- a/lib/util/fs/proxies.ts
+++ b/lib/util/fs/proxies.ts
@@ -19,7 +19,7 @@ export async function readFile(
   fileName: string,
   encoding: 'utf8'
 ): Promise<string>;
-export async function readFile(
+export function readFile(
   fileName: string,
   encoding?: string
 ): Promise<string | Buffer> {
@@ -27,7 +27,7 @@ export async function readFile(
 }
 
 // istanbul ignore next
-export async function writeFile(
+export function writeFile(
   fileName: string,
   fileContent: string
 ): Promise<void> {
@@ -35,7 +35,7 @@ export async function writeFile(
 }
 
 // istanbul ignore next
-export async function outputFile(
+export function outputFile(
   file: string,
   data: any,
   options?: WriteFileOptions | string
@@ -43,22 +43,22 @@ export async function outputFile(
   return fs.outputFile(file, data, options);
 }
 
-export async function remove(dir: string): Promise<void> {
+export function remove(dir: string): Promise<void> {
   return fs.remove(dir);
 }
 
 // istanbul ignore next
-export async function unlink(path: string | Buffer): Promise<void> {
+export function unlink(path: string | Buffer): Promise<void> {
   return fs.unlink(path);
 }
 
 // istanbul ignore next
-export async function exists(path: string): Promise<boolean> {
+export function exists(path: string): Promise<boolean> {
   return fs.pathExists(path);
 }
 
 // istanbul ignore next
-export async function pathExists(path: string): Promise<boolean> {
+export function pathExists(path: string): Promise<boolean> {
   return fs.pathExists(path);
 }
 
diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts
index 2bb3d71db1..05f056bfed 100644
--- a/lib/util/git/index.ts
+++ b/lib/util/git/index.ts
@@ -246,7 +246,7 @@ export async function initRepo(args: StorageConfig): Promise<void> {
 }
 
 // istanbul ignore next
-export async function getRepoStatus(): Promise<StatusResult> {
+export function getRepoStatus(): Promise<StatusResult> {
   return git.status();
 }
 
diff --git a/lib/util/http/bitbucket-server.ts b/lib/util/http/bitbucket-server.ts
index 6c7661feff..8be6add6b1 100644
--- a/lib/util/http/bitbucket-server.ts
+++ b/lib/util/http/bitbucket-server.ts
@@ -12,7 +12,7 @@ export class BitbucketServerHttp extends Http {
     super(PLATFORM_TYPE_BITBUCKET_SERVER, options);
   }
 
-  protected async request<T>(
+  protected request<T>(
     path: string,
     options?: InternalHttpOptions
   ): Promise<HttpResponse<T> | null> {
diff --git a/lib/util/http/bitbucket.ts b/lib/util/http/bitbucket.ts
index 428c541a42..cb8266da96 100644
--- a/lib/util/http/bitbucket.ts
+++ b/lib/util/http/bitbucket.ts
@@ -12,7 +12,7 @@ export class BitbucketHttp extends Http {
     super(PLATFORM_TYPE_BITBUCKET, options);
   }
 
-  protected async request<T>(
+  protected request<T>(
     url: string | URL,
     options?: InternalHttpOptions
   ): Promise<HttpResponse<T> | null> {
diff --git a/lib/util/http/index.ts b/lib/util/http/index.ts
index 04771ea64b..87e7239da2 100644
--- a/lib/util/http/index.ts
+++ b/lib/util/http/index.ts
@@ -149,42 +149,42 @@ export class Http<GetOptions = HttpOptions, PostOptions = HttpPostOptions> {
     return { ...res, body };
   }
 
-  async getJson<T = unknown>(
+  getJson<T = unknown>(
     url: string,
     options?: GetOptions
   ): Promise<HttpResponse<T>> {
     return this.requestJson<T>(url, { ...options });
   }
 
-  async headJson<T = unknown>(
+  headJson<T = unknown>(
     url: string,
     options?: GetOptions
   ): Promise<HttpResponse<T>> {
     return this.requestJson<T>(url, { ...options, method: 'head' });
   }
 
-  async postJson<T = unknown>(
+  postJson<T = unknown>(
     url: string,
     options?: PostOptions
   ): Promise<HttpResponse<T>> {
     return this.requestJson<T>(url, { ...options, method: 'post' });
   }
 
-  async putJson<T = unknown>(
+  putJson<T = unknown>(
     url: string,
     options?: PostOptions
   ): Promise<HttpResponse<T>> {
     return this.requestJson<T>(url, { ...options, method: 'put' });
   }
 
-  async patchJson<T = unknown>(
+  patchJson<T = unknown>(
     url: string,
     options?: PostOptions
   ): Promise<HttpResponse<T>> {
     return this.requestJson<T>(url, { ...options, method: 'patch' });
   }
 
-  async deleteJson<T = unknown>(
+  deleteJson<T = unknown>(
     url: string,
     options?: PostOptions
   ): Promise<HttpResponse<T>> {
diff --git a/lib/workers/branch/commit.ts b/lib/workers/branch/commit.ts
index 35ebdb58f2..4d57859b99 100644
--- a/lib/workers/branch/commit.ts
+++ b/lib/workers/branch/commit.ts
@@ -6,7 +6,7 @@ import { commitFiles } from '../../util/git';
 import { sanitize } from '../../util/sanitize';
 import { BranchConfig } from '../common';
 
-export async function commitFilesToBranch(
+export function commitFilesToBranch(
   config: BranchConfig
 ): Promise<string | null> {
   let updatedFiles = config.updatedPackageFiles.concat(config.updatedArtifacts);
diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts
index f01ffb3708..efcdb23cbe 100644
--- a/lib/workers/pr/changelog/release-notes.ts
+++ b/lib/workers/pr/changelog/release-notes.ts
@@ -249,7 +249,7 @@ export async function getReleaseNotesMdFileInner(
   }
 }
 
-export async function getReleaseNotesMdFile(
+export function getReleaseNotesMdFile(
   repository: string,
   apiBaseUrl: string
 ): Promise<{ changelogFile: string; changelogMd: string }> | null {
diff --git a/lib/workers/pr/changelog/source-github.ts b/lib/workers/pr/changelog/source-github.ts
index d5c9bc26cb..355006d7a9 100644
--- a/lib/workers/pr/changelog/source-github.ts
+++ b/lib/workers/pr/changelog/source-github.ts
@@ -42,10 +42,7 @@ async function getTagsInner(
   }
 }
 
-async function getTags(
-  endpoint: string,
-  repository: string
-): Promise<string[]> {
+function getTags(endpoint: string, repository: string): Promise<string[]> {
   const cacheKey = `getTags-${endpoint}-${repository}`;
   const cachedResult = memCache.get(cacheKey);
   // istanbul ignore if
diff --git a/lib/workers/pr/changelog/source-gitlab.ts b/lib/workers/pr/changelog/source-gitlab.ts
index 4631c56a83..912397dbe0 100644
--- a/lib/workers/pr/changelog/source-gitlab.ts
+++ b/lib/workers/pr/changelog/source-gitlab.ts
@@ -46,7 +46,7 @@ async function getTagsInner(
   }
 }
 
-async function getTags(
+function getTags(
   endpoint: string,
   versionScheme: string,
   repository: string
diff --git a/lib/workers/repository/onboarding/branch/create.ts b/lib/workers/repository/onboarding/branch/create.ts
index ff7ffc068e..615e332457 100644
--- a/lib/workers/repository/onboarding/branch/create.ts
+++ b/lib/workers/repository/onboarding/branch/create.ts
@@ -6,7 +6,7 @@ import { getOnboardingConfig } from './config';
 
 const defaultConfigFile = configFileNames[0];
 
-export async function createOnboardingBranch(
+export function createOnboardingBranch(
   config: Partial<RenovateConfig>
 ): Promise<string | null> {
   logger.debug('createOnboardingBranch()');
-- 
GitLab