Skip to content

Commit

Permalink
chore(eslint): fixing some eslint warnings (#7382)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <[email protected]>
  • Loading branch information
JamieMagee and viceice authored Oct 5, 2020
1 parent 526495f commit 5896d9c
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 22 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module.exports = {
'prefer-destructuring': 0,
'prefer-template': 0,
'no-underscore-dangle': 0,
// 'no-unused-vars': 2,

'sort-imports': [
'error',
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/git-submodules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ export async function getReleases({
export const getDigest = (
config: DigestConfig,
newValue?: string
): Promise<string> => new Promise((resolve) => resolve(newValue));
): Promise<string> => Promise.resolve(newValue);
6 changes: 3 additions & 3 deletions lib/datasource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Promise<ReleaseResult | null>>(cacheKey);
// istanbul ignore if
if (cachedResult) {
return cachedResult as Promise<ReleaseResult | null>;
if (cachedResult !== undefined) {
return cachedResult;
}
const promisedRes = fetchReleases(config);
memCache.set(cacheKey, promisedRes);
Expand Down
6 changes: 3 additions & 3 deletions lib/datasource/packagist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ async function getAllPackages(regUrl: string): Promise<AllPackages | null> {

function getAllCachedPackages(regUrl: string): Promise<AllPackages | null> {
const cacheKey = `packagist-${regUrl}`;
const cachedResult = memCache.get(cacheKey);
const cachedResult = memCache.get<Promise<AllPackages | null>>(cacheKey);
// istanbul ignore if
if (cachedResult) {
return cachedResult as Promise<AllPackages | null>;
if (cachedResult !== undefined) {
return cachedResult;
}
const promisedRes = getAllPackages(regUrl);
memCache.set(cacheKey, promisedRes);
Expand Down
2 changes: 1 addition & 1 deletion lib/util/cache/repository/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, PackageFile[]>; // extract result
}

export interface BranchUpgradeCache {
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/pr/body/updates-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
8 changes: 4 additions & 4 deletions lib/workers/pr/changelog/release-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export function getCachedReleaseList(
repository: string
): Promise<ChangeLogNotes[]> {
const cacheKey = `getReleaseList-${apiBaseUrl}-${repository}`;
const cachedResult = memCache.get(cacheKey);
const cachedResult = memCache.get<Promise<ChangeLogNotes[]>>(cacheKey);
// istanbul ignore if
if (cachedResult) {
if (cachedResult !== undefined) {
return cachedResult;
}
const promisedRes = getReleaseList(apiBaseUrl, repository);
Expand Down Expand Up @@ -179,9 +179,9 @@ export async function getReleaseNotesMdFileInner(
export function getReleaseNotesMdFile(
repository: string,
apiBaseUrl: string
): Promise<ChangeLogFile> | null {
): Promise<ChangeLogFile | null> {
const cacheKey = `getReleaseNotesMdFile-${repository}-${apiBaseUrl}`;
const cachedResult = memCache.get(cacheKey);
const cachedResult = memCache.get<Promise<ChangeLogFile | null>>(cacheKey);
// istanbul ignore if
if (cachedResult !== undefined) {
return cachedResult;
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/pr/changelog/source-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getCachedTags(
repository: string
): Promise<string[]> {
const cacheKey = `getTags-${endpoint}-${repository}`;
const cachedResult = memCache.get(cacheKey);
const cachedResult = memCache.get<Promise<string[]>>(cacheKey);
// istanbul ignore if
if (cachedResult !== undefined) {
return cachedResult;
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/pr/changelog/source-gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getCachedTags(
repository: string
): Promise<string[]> {
const cacheKey = `getTags-${endpoint}-${versionScheme}-${repository}`;
const cachedResult = memCache.get(cacheKey);
const cachedResult = memCache.get<Promise<string[]>>(cacheKey);
// istanbul ignore if
if (cachedResult !== undefined) {
return cachedResult;
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/pr/code-owners.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(null);
});
git.getBranchFiles.mockResolvedValueOnce(['README.md']);
const codeOwners = await codeOwnersForPr(pr);
Expand Down
3 changes: 2 additions & 1 deletion lib/workers/repository/process/extract-update.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -46,7 +47,7 @@ describe('workers/repository/process/extract-update', () => {
expect(packageFiles).toMatchSnapshot();
});
it('uses repository cache', async () => {
const packageFiles = [];
const packageFiles: Record<string, PackageFile[]> = {};
const config = {
repoIsOnboarded: true,
suppressNotifications: ['deprecationWarningIssues'],
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/process/extract-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function extract(
logger.debug('extract()');
const { baseBranch } = config;
const baseBranchSha = getBranchCommit(baseBranch);
let packageFiles;
let packageFiles: Record<string, PackageFile[]>;
const cache = getCache();
const cachedExtract = cache?.scan?.[baseBranch];
const configHash = hasha(JSON.stringify(config));
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/updates/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 5896d9c

Please sign in to comment.