diff --git a/.eslintrc.js b/.eslintrc.js index da919a5080442b0835bc72ec6586284d6bde5c41..e718d2a85a2801dcf5aed6dfc47fe9bf256c118e 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 027cfed7f1e40142c28a002cc214fc91bcaa6977..71634e3359f7a52374b501abe6e55633865eb987 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 0e7f9d0c93fdbacfd57048b3e262b39abf154221..fa6f1aec1c7127fd58d37b84c4e982506829b457 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 acf2e8b4ed1fcbc27b6ad63a92df6c864ec8e058..82a24acc0a515e6fc9aa88838495e9d71723cd46 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 c501d1c2375936e4eb0b683dd7e115f9579887c0..9a98550c0b43dc0c40ecb94dd5e163a288b6422e 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 f52ec82090170dc9f46d868cff66e4cdfae42f40..dbae11adc25d56cc680ec79ab3c85b123bb236c8 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 34a3b62c6a620ff24e38305cb68d2b9bb8c53386..932bd6ef48f0d975c38b835253033818d5b2ec5a 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 c7458eb53e02f4fb749a30000c6cdb05cd601039..b010ccf347442d838ca793429442f2ffe4766b82 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 389fa9a0bcd6cf1070d89ee661fe37fdfafaee7f..c359adddd9fcb4703605a22a65ec0f20f8e3fe14 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 ea9048284491bee67ac823e234e1c9fbe04b1685..764f450dba2f90808cf7bc53a19d2854821fe717 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 c52f13a29e9f3350226f4d622ad2a11bfa9ab2b5..6bb0c632193d7d17e058b12b2be31bb4ecc67e1b 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 946707f666a7fc3141ec58fd20cac7d818dcfee5..0624325e060fcc5ec00196c3e94b1aba9b2924cc 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 2bb3d71db1ca0c1f27752272ac398c1afba334ba..05f056bfedebb8a4a56f1bc23e5cc072751e2017 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 6c7661feff65bbf45cc6026c082d7f76861a8d5d..8be6add6b1de1f55965e128d46de4951d154d8cc 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 428c541a421a1ba3026735015fd99799e5f09693..cb8266da9651f82b460e7434af51c56d10bc1e19 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 04771ea64bba6ac2f41ff917547abfe594875c51..87e7239da2f89b874ada933c04d9aec85ba22c74 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 35ebdb58f26809f540b236208d89c12dc8a86116..4d57859b995885ac1249e4884f60720ec5b410be 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 f01ffb3708f99c8ac53d5fbd6528185c4003d800..efcdb23cbe4badd36c6572ca571ee57f48101a2b 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 d5c9bc26cb964c69bd17a2f99fd72762316d13c7..355006d7a9fc1491c7cc148295097c2690073064 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 4631c56a839fd2bc15cf3c786b652de1303ad9ad..912397dbe02a1a5093f8d37641d94a865dbc125a 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 ff7ffc068e8358038ce418f4e58f0a46cae0879d..615e332457ab41d072e50be8d9eb75c7c62712e0 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()');