Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix lint issues #16779

Merged
merged 5 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/modules/datasource/crate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class CrateDatasource extends Datasource {
const host = url.hostname;
const hash = hasha(url.pathname, {
algorithm: 'sha256',
}).substr(0, 7);
}).substring(0, 7);

return `crate-registry-${proto}-${host}-${hash}`;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/modules/manager/npm/update/package-version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function bumpPackageVersion(
{ bumpVersion, currentValue },
'Checking if we should bump package.json version'
);
// TODO: types (#7154)
let newPjVersion: string | null;
let bumpedContent = content;
try {
Expand All @@ -33,7 +34,7 @@ export function bumpPackageVersion(
logger.debug({ newPjVersion });
bumpedContent = content.replace(
regEx(`(?<version>"version":\\s*")[^"]*`),
`$<version>${newPjVersion}`
`$<version>${newPjVersion!}`
);
if (bumpedContent === content) {
logger.debug('Version was already bumped');
Expand Down
3 changes: 2 additions & 1 deletion lib/modules/manager/pip_requirements/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export async function updateArtifacts({
for (const dep of updatedDeps) {
const hashLine = lines.find(
(line) =>
line.startsWith(`${dep.depName}==`) && line.includes('--hash=')
// TODO: types (#7154)
line.startsWith(`${dep.depName!}==`) && line.includes('--hash=')
);
if (hashLine) {
const depConstraint = hashLine.split(' ')[0];
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/pipenv/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function getPythonConstraint(
function getPipenvConstraint(
existingLockFileContent: string,
config: UpdateArtifactsConfig
): string | null {
): string {
const { constraints = {} } = config;
const { pipenv } = constraints;

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/pipenv/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function extractFromSection(
const specifierMatches = specifierRegex.exec(currentValue!);
if (!specifierMatches) {
logger.debug(
`Skipping dependency with malformed version specifier "${currentValue}".`
`Skipping dependency with malformed version specifier "${currentValue!}".`
);
skipReason = 'invalid-version';
}
Expand Down
3 changes: 2 additions & 1 deletion lib/modules/manager/poetry/update-locked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export function updateLockedDependency(
const { depName, currentVersion, newVersion, lockFile, lockFileContent } =
config;
logger.debug(
`poetry.updateLockedDependency: ${depName}@${currentVersion} -> ${newVersion} [${lockFile}]`
// TODO: types (#7154)
`poetry.updateLockedDependency: ${depName}@${currentVersion!} -> ${newVersion} [${lockFile}]`
);
const locked = extractLockFileEntries(lockFileContent ?? '');
if (depName && locked[depName] === newVersion) {
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/terraform/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function massageProviderLookupName(dep: PackageDependency): void {

// TODO #7154
if (!dep.packageName!.includes('/')) {
dep.packageName = `hashicorp/${dep.packageName}`;
dep.packageName = `hashicorp/${dep.packageName!}`;
}

// handle cases like `Telmate/proxmox`
Expand Down
8 changes: 5 additions & 3 deletions lib/modules/platform/azure/azure-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function getRefs(
repoId: string,
branchName?: string
): Promise<GitRef[]> {
logger.debug(`getRefs(${repoId}, ${branchName})`);
logger.debug(`getRefs(${repoId}, ${branchName!})`);
const azureApiGit = await azureApi.gitApi();
const refs = await azureApiGit.getRefs(
repoId,
Expand Down Expand Up @@ -123,7 +123,8 @@ export async function getMergeMethod(
const isRelevantScope = (scope: Scope): boolean => {
if (
scope.matchKind === 'DefaultBranch' &&
(!branchRef || branchRef === `refs/heads/${defaultBranch}`)
// TODO: types (#7154)
(!branchRef || branchRef === `refs/heads/${defaultBranch!}`)
) {
return true;
}
Expand All @@ -149,7 +150,8 @@ export async function getMergeMethod(
.map((p) => p.settings)[0];

logger.trace(
`getMergeMethod(${repoId}, ${project}, ${branchRef}) determining mergeMethod from matched policy:\n${JSON.stringify(
// TODO: types (#7154)
`getMergeMethod(${repoId}, ${project}, ${branchRef!}) determining mergeMethod from matched policy:\n${JSON.stringify(
policyConfigurations,
null,
4
Expand Down
12 changes: 8 additions & 4 deletions lib/modules/platform/azure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export async function getRepos(): Promise<string[]> {
logger.debug('Autodiscovering Azure DevOps repositories');
const azureApiGit = await azureApi.gitApi();
const repos = await azureApiGit.getRepositories();
// TODO: types (#7154)
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return repos.map((repo) => `${repo.project?.name}/${repo.name}`);
}

Expand Down Expand Up @@ -211,7 +213,8 @@ export async function initRepo({
hostType: defaults.hostType,
url: defaults.endpoint,
});
const manualUrl = `${defaults.endpoint}${encodeURIComponent(
// TODO: types (#7154)
const manualUrl = `${defaults.endpoint!}${encodeURIComponent(
projectName
)}/_git/${encodeURIComponent(repoName)}`;
const url = repo.remoteUrl ?? manualUrl;
Expand Down Expand Up @@ -514,7 +517,7 @@ export async function ensureComment({
topic,
content,
}: EnsureCommentConfig): Promise<boolean> {
logger.debug(`ensureComment(${number}, ${topic}, content)`);
logger.debug(`ensureComment(${number}, ${topic!}, content)`);
const header = topic ? `### ${topic}\n\n` : '';
const body = `${header}${sanitize(content)}`;
const azureApiGit = await azureApi.gitApi();
Expand Down Expand Up @@ -630,7 +633,7 @@ export async function setBranchStatus({
url: targetUrl,
}: BranchStatusConfig): Promise<void> {
logger.debug(
`setBranchStatus(${branchName}, ${context}, ${description}, ${state}, ${targetUrl})`
`setBranchStatus(${branchName}, ${context}, ${description}, ${state}, ${targetUrl!})`
);
const azureApiGit = await azureApi.gitApi();
const branch = await azureApiGit.getBranch(
Expand All @@ -656,7 +659,7 @@ export async function mergePr({
branchName,
id: pullRequestId,
}: MergePRConfig): Promise<boolean> {
logger.debug(`mergePr(${pullRequestId}, ${branchName})`);
logger.debug(`mergePr(${pullRequestId}, ${branchName!})`);
const azureApiGit = await azureApi.gitApi();

let pr = await azureApiGit.getPullRequestById(pullRequestId, config.project);
Expand Down Expand Up @@ -685,6 +688,7 @@ export async function mergePr({
`Updating PR ${pullRequestId} to status ${PullRequestStatus.Completed} (${
PullRequestStatus[PullRequestStatus.Completed]
}) with lastMergeSourceCommit ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
pr.lastMergeSourceCommit?.commitId
} using mergeStrategy ${mergeMethod} (${
GitPullRequestMergeStrategy[mergeMethod]
Expand Down
10 changes: 6 additions & 4 deletions lib/modules/platform/azure/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export function getGitStatusContextCombinedName(
return undefined;
}
const combinedName = `${context.genre ? `${context.genre}/` : ''}${
context.name
// TODO: types (#7154)
context.name!
}`;
logger.trace(`Got combined context name of ${combinedName}`);
return combinedName;
Expand Down Expand Up @@ -55,7 +56,7 @@ export function getBranchNameWithoutRefsheadsPrefix(
branchPath: string | undefined
): string | undefined {
if (!branchPath) {
logger.error(`getBranchNameWithoutRefsheadsPrefix(${branchPath})`);
logger.error(`getBranchNameWithoutRefsheadsPrefix(undefined)`);
return undefined;
}
if (!branchPath.startsWith('refs/heads/')) {
Expand All @@ -71,7 +72,7 @@ export function getBranchNameWithoutRefsPrefix(
branchPath?: string
): string | undefined {
if (!branchPath) {
logger.error(`getBranchNameWithoutRefsPrefix(${branchPath})`);
logger.error(`getBranchNameWithoutRefsPrefix(undefined)`);
return undefined;
}
if (!branchPath.startsWith('refs/')) {
Expand All @@ -90,7 +91,8 @@ const stateMap = {

export function getRenovatePRFormat(azurePr: GitPullRequest): AzurePr {
const number = azurePr.pullRequestId;
const displayNumber = `Pull Request #${number}`;
// TODO: types (#7154)
const displayNumber = `Pull Request #${number!}`;

const sourceBranch = getBranchNameWithoutRefsheadsPrefix(
azurePr.sourceRefName
Expand Down
18 changes: 12 additions & 6 deletions lib/modules/platform/bitbucket-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export async function findPr({
state = PrState.All,
refreshCache,
}: FindPRConfig): Promise<Pr | null> {
logger.debug(`findPr(${branchName}, "${prTitle}", "${state}")`);
logger.debug(`findPr(${branchName}, "${prTitle!}", "${state}")`);
const prList = await getPrList(refreshCache);
const pr = prList.find(isRelevantPr(branchName, prTitle, state));
if (pr) {
Expand Down Expand Up @@ -362,7 +362,8 @@ async function getStatus(

return (
await bitbucketServerHttp.getJson<utils.BitbucketCommitStatus>(
`./rest/build-status/1.0/commits/stats/${branchCommit}`,
// TODO: types (#7154)
`./rest/build-status/1.0/commits/stats/${branchCommit!}`,
{
useCache,
}
Expand Down Expand Up @@ -410,7 +411,8 @@ function getStatusCheck(
const branchCommit = git.getBranchCommit(branchName);

return utils.accumulateValues(
`./rest/build-status/1.0/commits/${branchCommit}`,
// TODO: types (#7154)
`./rest/build-status/1.0/commits/${branchCommit!}`,
'get',
{ useCache }
);
Expand Down Expand Up @@ -483,7 +485,8 @@ export async function setBranchStatus({
}

await bitbucketServerHttp.postJson(
`./rest/build-status/1.0/commits/${branchCommit}`,
// TODO: types (#7154)
`./rest/build-status/1.0/commits/${branchCommit!}`,
{ body }
);

Expand Down Expand Up @@ -936,15 +939,18 @@ export async function mergePr({
branchName,
id: prNo,
}: MergePRConfig): Promise<boolean> {
logger.debug(`mergePr(${prNo}, ${branchName})`);
logger.debug(`mergePr(${prNo}, ${branchName!})`);
// Used for "automerge" feature
try {
const pr = await getPr(prNo);
if (!pr) {
throw Object.assign(new Error(REPOSITORY_NOT_FOUND), { statusCode: 404 });
}
const { body } = await bitbucketServerHttp.postJson<{ version: number }>(
`./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/merge?version=${pr.version}`
// TODO: types (#7154)
`./rest/api/1.0/projects/${config.projectKey}/repos/${
config.repositorySlug
}/pull-requests/${prNo}/merge?version=${pr.version!}`
);
updatePrVersion(prNo, body.version);
} catch (err) {
Expand Down
14 changes: 9 additions & 5 deletions lib/modules/platform/gitea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ const platform: Platform = {
prTitle: title,
state = PrState.All,
}: FindPRConfig): Promise<Pr | null> {
logger.debug(`findPr(${branchName}, ${title}, ${state})`);
logger.debug(`findPr(${branchName}, ${title!}, ${state})`);
const prList = await platform.getPrList();
const pr = prList.find(
(p) =>
Expand Down Expand Up @@ -606,7 +606,8 @@ const platform: Platform = {
if (!issue) {
return null;
}
logger.debug(`Found Issue #${issue.number}`);
// TODO: types (#7154)
logger.debug(`Found Issue #${issue.number!}`);
// TODO #7154
return getIssue!(issue.number!);
},
Expand Down Expand Up @@ -656,7 +657,8 @@ const platform: Platform = {
// Close any duplicate issues
for (const issue of issues) {
if (issue.state === 'open' && issue.number !== activeIssue.number) {
logger.warn(`Closing duplicate Issue #${issue.number}`);
// TODO: types (#7154)
logger.warn(`Closing duplicate Issue #${issue.number!}`);
// TODO #7154
await helper.closeIssue(config.repository, issue.number!);
}
Expand All @@ -669,13 +671,15 @@ const platform: Platform = {
activeIssue.state === 'open'
) {
logger.debug(
`Issue #${activeIssue.number} is open and up to date - nothing to do`
// TODO: types (#7154)
`Issue #${activeIssue.number!} is open and up to date - nothing to do`
);
return null;
}

// Update issue body and re-open if enabled
logger.debug(`Updating Issue #${activeIssue.number}`);
// TODO: types (#7154)
logger.debug(`Updating Issue #${activeIssue.number!}`);
const existingIssue = await helper.updateIssue(
config.repository,
// TODO #7154
Expand Down
21 changes: 14 additions & 7 deletions lib/modules/platform/gitlab/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ function getRepoUrl(
const newPathname = pathname.slice(0, pathname.indexOf('/api'));
const url = URL.format({
protocol: protocol.slice(0, -1) || 'https',
auth: `oauth2:${opts.token}`,
// TODO: types (#7154)
auth: `oauth2:${opts.token!}`,
host,
pathname: newPathname + '/' + repository + '.git',
});
Expand All @@ -233,7 +234,8 @@ function getRepoUrl(

logger.debug({ url: res.body.http_url_to_repo }, `using http URL`);
const repoUrl = URL.parse(`${res.body.http_url_to_repo}`);
repoUrl.auth = `oauth2:${opts.token}`;
// TODO: types (#7154)
repoUrl.auth = `oauth2:${opts.token!}`;
return URL.format(repoUrl);
}

Expand Down Expand Up @@ -356,7 +358,10 @@ async function getStatus(
): Promise<GitlabBranchStatus[]> {
const branchSha = git.getBranchCommit(branchName);
try {
const url = `projects/${config.repository}/repository/commits/${branchSha}/statuses`;
// TODO: types (#7154)
const url = `projects/${
config.repository
}/repository/commits/${branchSha!}/statuses`;

return (
await gitlabApi.getJson<GitlabBranchStatus[]>(url, {
Expand Down Expand Up @@ -713,7 +718,7 @@ export async function findPr({
prTitle,
state = PrState.All,
}: FindPRConfig): Promise<Pr | null> {
logger.debug(`findPr(${branchName}, ${prTitle}, ${state})`);
logger.debug(`findPr(${branchName}, ${prTitle!}, ${state})`);
const prList = await getPrList();
return (
prList.find(
Expand Down Expand Up @@ -760,7 +765,8 @@ export async function setBranchStatus({
// First, get the branch commit SHA
const branchSha = git.getBranchCommit(branchName);
// Now, check the statuses for that commit
const url = `projects/${config.repository}/statuses/${branchSha}`;
// TODO: types (#7154)
const url = `projects/${config.repository}/statuses/${branchSha!}`;
let state = 'success';
if (renovateState === BranchStatus.yellow) {
state = 'pending';
Expand Down Expand Up @@ -1092,14 +1098,15 @@ export async function ensureComment({
let body: string;
let commentId: number | undefined;
let commentNeedsUpdating: boolean | undefined;
// TODO: types (#7154)
if (topic) {
logger.debug(`Ensuring comment "${massagedTopic}" in #${number}`);
logger.debug(`Ensuring comment "${massagedTopic!}" in #${number}`);
body = `### ${topic}\n\n${sanitizedContent}`;
body = body
.replace(regEx(/Pull Request/g), 'Merge Request')
.replace(regEx(/PR/g), 'MR');
comments.forEach((comment: { body: string; id: number }) => {
if (comment.body.startsWith(`### ${massagedTopic}\n\n`)) {
if (comment.body.startsWith(`### ${massagedTopic!}\n\n`)) {
commentId = comment.id;
commentNeedsUpdating = comment.body !== body;
}
Expand Down