From 5896d9cb37447151f2e13d0b8570bc1618dfbca4 Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Mon, 5 Oct 2020 18:12:01 +0200 Subject: [PATCH] chore(eslint): fixing some eslint warnings (#7382) Co-authored-by: Michael Kriese --- .eslintrc.js | 3 --- lib/datasource/git-submodules/index.ts | 2 +- lib/datasource/index.ts | 6 +++--- lib/datasource/packagist/index.ts | 6 +++--- lib/util/cache/repository/index.ts | 2 +- lib/workers/pr/body/updates-table.ts | 2 +- lib/workers/pr/changelog/release-notes.ts | 8 ++++---- lib/workers/pr/changelog/source-github.ts | 2 +- lib/workers/pr/changelog/source-gitlab.ts | 2 +- lib/workers/pr/code-owners.spec.ts | 2 +- lib/workers/repository/process/extract-update.spec.ts | 3 ++- lib/workers/repository/process/extract-update.ts | 2 +- lib/workers/repository/updates/generate.ts | 2 +- 13 files changed, 20 insertions(+), 22 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8dbbd5f9c6c0db..d53c730b04d746 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -42,7 +42,6 @@ module.exports = { 'prefer-destructuring': 0, 'prefer-template': 0, 'no-underscore-dangle': 0, - // 'no-unused-vars': 2, 'sort-imports': [ 'error', @@ -69,9 +68,7 @@ module.exports = { ], // TODO: fix lint - '@typescript-eslint/camelcase': 0, // disabled until ?? '@typescript-eslint/no-explicit-any': 0, - '@typescript-eslint/no-floating-promises': 2, '@typescript-eslint/no-non-null-assertion': 2, '@typescript-eslint/no-unused-vars': [ 2, diff --git a/lib/datasource/git-submodules/index.ts b/lib/datasource/git-submodules/index.ts index 530796a489d342..730e81fd52e1ab 100644 --- a/lib/datasource/git-submodules/index.ts +++ b/lib/datasource/git-submodules/index.ts @@ -51,4 +51,4 @@ export async function getReleases({ export const getDigest = ( config: DigestConfig, newValue?: string -): Promise => new Promise((resolve) => resolve(newValue)); +): Promise => Promise.resolve(newValue); diff --git a/lib/datasource/index.ts b/lib/datasource/index.ts index 7dbc356cef5ac5..2aa1554f0d5886 100644 --- a/lib/datasource/index.ts +++ b/lib/datasource/index.ts @@ -220,10 +220,10 @@ function getRawReleases( registryUrls )}`; // By returning a Promise and reusing it, we should only fetch each package at most once - const cachedResult = memCache.get(cacheKey); + const cachedResult = memCache.get>(cacheKey); // istanbul ignore if - if (cachedResult) { - return cachedResult as Promise; + if (cachedResult !== undefined) { + return cachedResult; } const promisedRes = fetchReleases(config); memCache.set(cacheKey, promisedRes); diff --git a/lib/datasource/packagist/index.ts b/lib/datasource/packagist/index.ts index 46b9e157482bf9..175914a9c69d18 100644 --- a/lib/datasource/packagist/index.ts +++ b/lib/datasource/packagist/index.ts @@ -204,10 +204,10 @@ async function getAllPackages(regUrl: string): Promise { function getAllCachedPackages(regUrl: string): Promise { const cacheKey = `packagist-${regUrl}`; - const cachedResult = memCache.get(cacheKey); + const cachedResult = memCache.get>(cacheKey); // istanbul ignore if - if (cachedResult) { - return cachedResult as Promise; + if (cachedResult !== undefined) { + return cachedResult; } const promisedRes = getAllPackages(regUrl); memCache.set(cacheKey, promisedRes); diff --git a/lib/util/cache/repository/index.ts b/lib/util/cache/repository/index.ts index 3c9899127f0e6e..bed1781ca9c2c7 100644 --- a/lib/util/cache/repository/index.ts +++ b/lib/util/cache/repository/index.ts @@ -8,7 +8,7 @@ import { RepoInitConfig } from '../../../workers/repository/init/common'; export interface BaseBranchCache { sha: string; // branch commit sha configHash: string; // object hash of config - packageFiles: PackageFile[]; // extract result + packageFiles: Record; // extract result } export interface BranchUpgradeCache { diff --git a/lib/workers/pr/body/updates-table.ts b/lib/workers/pr/body/updates-table.ts index e5bb000e7d42a1..d969556831096d 100644 --- a/lib/workers/pr/body/updates-table.ts +++ b/lib/workers/pr/body/updates-table.ts @@ -8,7 +8,7 @@ type TableDefinition = { }; function getTableDefinition(config: BranchConfig): TableDefinition[] { - const res = []; + const res: TableDefinition[] = []; for (const header of config.prBodyColumns) { const value = config.prBodyDefinitions[header]; res.push({ header, value }); diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts index f88d104bc8e10b..50228c5ca0fae0 100644 --- a/lib/workers/pr/changelog/release-notes.ts +++ b/lib/workers/pr/changelog/release-notes.ts @@ -42,9 +42,9 @@ export function getCachedReleaseList( repository: string ): Promise { const cacheKey = `getReleaseList-${apiBaseUrl}-${repository}`; - const cachedResult = memCache.get(cacheKey); + const cachedResult = memCache.get>(cacheKey); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } const promisedRes = getReleaseList(apiBaseUrl, repository); @@ -179,9 +179,9 @@ export async function getReleaseNotesMdFileInner( export function getReleaseNotesMdFile( repository: string, apiBaseUrl: string -): Promise | null { +): Promise { const cacheKey = `getReleaseNotesMdFile-${repository}-${apiBaseUrl}`; - const cachedResult = memCache.get(cacheKey); + const cachedResult = memCache.get>(cacheKey); // istanbul ignore if if (cachedResult !== undefined) { return cachedResult; diff --git a/lib/workers/pr/changelog/source-github.ts b/lib/workers/pr/changelog/source-github.ts index 8c8fcfca12a10d..fbb2fbca891e0c 100644 --- a/lib/workers/pr/changelog/source-github.ts +++ b/lib/workers/pr/changelog/source-github.ts @@ -16,7 +16,7 @@ function getCachedTags( repository: string ): Promise { const cacheKey = `getTags-${endpoint}-${repository}`; - const cachedResult = memCache.get(cacheKey); + const cachedResult = memCache.get>(cacheKey); // istanbul ignore if if (cachedResult !== undefined) { return cachedResult; diff --git a/lib/workers/pr/changelog/source-gitlab.ts b/lib/workers/pr/changelog/source-gitlab.ts index 53033122564304..e5a760fbb38abb 100644 --- a/lib/workers/pr/changelog/source-gitlab.ts +++ b/lib/workers/pr/changelog/source-gitlab.ts @@ -18,7 +18,7 @@ function getCachedTags( repository: string ): Promise { const cacheKey = `getTags-${endpoint}-${versionScheme}-${repository}`; - const cachedResult = memCache.get(cacheKey); + const cachedResult = memCache.get>(cacheKey); // istanbul ignore if if (cachedResult !== undefined) { return cachedResult; diff --git a/lib/workers/pr/code-owners.spec.ts b/lib/workers/pr/code-owners.spec.ts index d6999d28b38fac..8832dfddbd9f4d 100644 --- a/lib/workers/pr/code-owners.spec.ts +++ b/lib/workers/pr/code-owners.spec.ts @@ -74,7 +74,7 @@ describe('workers/pr/code-owners', () => { if (path === codeOwnerFilePath) { return Promise.resolve(['* @mike'].join('\n')); } - return Promise.resolve(null); + return Promise.resolve(null); }); git.getBranchFiles.mockResolvedValueOnce(['README.md']); const codeOwners = await codeOwnersForPr(pr); diff --git a/lib/workers/repository/process/extract-update.spec.ts b/lib/workers/repository/process/extract-update.spec.ts index 2ba50adbcb38f3..acb1409e498d1a 100644 --- a/lib/workers/repository/process/extract-update.spec.ts +++ b/lib/workers/repository/process/extract-update.spec.ts @@ -1,5 +1,6 @@ import hasha from 'hasha'; import { git, mocked } from '../../../../test/util'; +import { PackageFile } from '../../../manager/common'; import * as _repositoryCache from '../../../util/cache/repository'; import * as _branchify from '../updates/branchify'; import { extract, lookup, update } from './extract-update'; @@ -46,7 +47,7 @@ describe('workers/repository/process/extract-update', () => { expect(packageFiles).toMatchSnapshot(); }); it('uses repository cache', async () => { - const packageFiles = []; + const packageFiles: Record = {}; const config = { repoIsOnboarded: true, suppressNotifications: ['deprecationWarningIssues'], diff --git a/lib/workers/repository/process/extract-update.ts b/lib/workers/repository/process/extract-update.ts index f06fc4f1100b22..1b303a3bf4ee85 100644 --- a/lib/workers/repository/process/extract-update.ts +++ b/lib/workers/repository/process/extract-update.ts @@ -53,7 +53,7 @@ export async function extract( logger.debug('extract()'); const { baseBranch } = config; const baseBranchSha = getBranchCommit(baseBranch); - let packageFiles; + let packageFiles: Record; const cache = getCache(); const cachedExtract = cache?.scan?.[baseBranch]; const configHash = hasha(JSON.stringify(config)); diff --git a/lib/workers/repository/updates/generate.ts b/lib/workers/repository/updates/generate.ts index 22a51fe088901e..6ef1bd6e905d4f 100644 --- a/lib/workers/repository/updates/generate.ts +++ b/lib/workers/repository/updates/generate.ts @@ -9,7 +9,7 @@ import * as template from '../../../util/template'; import { BranchConfig, BranchUpgradeConfig } from '../../common'; import { formatCommitMessagePrefix } from '../util/commit-message'; -function isTypesGroup(branchUpgrades: any[]): boolean { +function isTypesGroup(branchUpgrades: BranchUpgradeConfig[]): boolean { return ( branchUpgrades.some(({ depName }) => depName?.startsWith('@types/')) && new Set(