fix linting
This commit is contained in:
parent
e0c4e25b76
commit
8fb3b504a0
@ -1,12 +1,12 @@
|
|||||||
import { isLabeled } from '../functions/is-labeled';
|
import {isLabeled} from '../functions/is-labeled';
|
||||||
import { isPullRequest } from '../functions/is-pull-request';
|
import {isPullRequest} from '../functions/is-pull-request';
|
||||||
import { Assignee } from '../interfaces/assignee';
|
import {Assignee} from '../interfaces/assignee';
|
||||||
import { IIssue, OctokitIssue } from '../interfaces/issue';
|
import {IIssue, OctokitIssue} from '../interfaces/issue';
|
||||||
import { IIssuesProcessorOptions } from '../interfaces/issues-processor-options';
|
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||||
import { ILabel } from '../interfaces/label';
|
import {ILabel} from '../interfaces/label';
|
||||||
import { IMilestone } from '../interfaces/milestone';
|
import {IMilestone} from '../interfaces/milestone';
|
||||||
import { IsoDateString } from '../types/iso-date-string';
|
import {IsoDateString} from '../types/iso-date-string';
|
||||||
import { Operations } from './operations';
|
import {Operations} from './operations';
|
||||||
|
|
||||||
export class Issue implements IIssue {
|
export class Issue implements IIssue {
|
||||||
readonly title: string;
|
readonly title: string;
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { context, getOctokit } from '@actions/github';
|
import {context, getOctokit} from '@actions/github';
|
||||||
import { GitHub } from '@actions/github/lib/utils';
|
import {GitHub} from '@actions/github/lib/utils';
|
||||||
import { Option } from '../enums/option';
|
import {Option} from '../enums/option';
|
||||||
import { getHumanizedDate } from '../functions/dates/get-humanized-date';
|
import {getHumanizedDate} from '../functions/dates/get-humanized-date';
|
||||||
import { isDateMoreRecentThan } from '../functions/dates/is-date-more-recent-than';
|
import {isDateMoreRecentThan} from '../functions/dates/is-date-more-recent-than';
|
||||||
import { isValidDate } from '../functions/dates/is-valid-date';
|
import {isValidDate} from '../functions/dates/is-valid-date';
|
||||||
import { isBoolean } from '../functions/is-boolean';
|
import {isBoolean} from '../functions/is-boolean';
|
||||||
import { isLabeled } from '../functions/is-labeled';
|
import {isLabeled} from '../functions/is-labeled';
|
||||||
import { cleanLabel } from '../functions/clean-label';
|
import {cleanLabel} from '../functions/clean-label';
|
||||||
import { shouldMarkWhenStale } from '../functions/should-mark-when-stale';
|
import {shouldMarkWhenStale} from '../functions/should-mark-when-stale';
|
||||||
import { wordsToList } from '../functions/words-to-list';
|
import {wordsToList} from '../functions/words-to-list';
|
||||||
import { IComment } from '../interfaces/comment';
|
import {IComment} from '../interfaces/comment';
|
||||||
import { IIssueEvent } from '../interfaces/issue-event';
|
import {IIssueEvent} from '../interfaces/issue-event';
|
||||||
import { IIssuesProcessorOptions } from '../interfaces/issues-processor-options';
|
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
|
||||||
import { IPullRequest } from '../interfaces/pull-request';
|
import {IPullRequest} from '../interfaces/pull-request';
|
||||||
import { Assignees } from './assignees';
|
import {Assignees} from './assignees';
|
||||||
import { IgnoreUpdates } from './ignore-updates';
|
import {IgnoreUpdates} from './ignore-updates';
|
||||||
import { ExemptDraftPullRequest } from './exempt-draft-pull-request';
|
import {ExemptDraftPullRequest} from './exempt-draft-pull-request';
|
||||||
import { Issue } from './issue';
|
import {Issue} from './issue';
|
||||||
import { IssueLogger } from './loggers/issue-logger';
|
import {IssueLogger} from './loggers/issue-logger';
|
||||||
import { Logger } from './loggers/logger';
|
import {Logger} from './loggers/logger';
|
||||||
import { Milestones } from './milestones';
|
import {Milestones} from './milestones';
|
||||||
import { StaleOperations } from './stale-operations';
|
import {StaleOperations} from './stale-operations';
|
||||||
import { Statistics } from './statistics';
|
import {Statistics} from './statistics';
|
||||||
import { LoggerService } from '../services/logger.service';
|
import {LoggerService} from '../services/logger.service';
|
||||||
import { OctokitIssue } from '../interfaces/issue';
|
import {OctokitIssue} from '../interfaces/issue';
|
||||||
import { retry } from '@octokit/plugin-retry';
|
import {retry} from '@octokit/plugin-retry';
|
||||||
import { IState } from '../interfaces/state/state';
|
import {IState} from '../interfaces/state/state';
|
||||||
import { IRateLimit } from '../interfaces/rate-limit';
|
import {IRateLimit} from '../interfaces/rate-limit';
|
||||||
import { RateLimit } from './rate-limit';
|
import {RateLimit} from './rate-limit';
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Handle processing of issues for staleness/closure.
|
* Handle processing of issues for staleness/closure.
|
||||||
@ -52,7 +52,8 @@ export class IssuesProcessor {
|
|||||||
|
|
||||||
issueLogger.info(
|
issueLogger.info(
|
||||||
LoggerService.cyan(consumedOperationsCount),
|
LoggerService.cyan(consumedOperationsCount),
|
||||||
`operation${consumedOperationsCount > 1 ? 's' : ''
|
`operation${
|
||||||
|
consumedOperationsCount > 1 ? 's' : ''
|
||||||
} consumed for this $$type`
|
} consumed for this $$type`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -256,7 +257,6 @@ export class IssuesProcessor {
|
|||||||
? this._getDaysBeforePrStale()
|
? this._getDaysBeforePrStale()
|
||||||
: this._getDaysBeforeIssueStale();
|
: this._getDaysBeforeIssueStale();
|
||||||
|
|
||||||
|
|
||||||
if (issue.state === 'closed') {
|
if (issue.state === 'closed') {
|
||||||
issueLogger.info(`Skipping this $$type because it is closed`);
|
issueLogger.info(`Skipping this $$type because it is closed`);
|
||||||
IssuesProcessor._endIssueProcessing(issue);
|
IssuesProcessor._endIssueProcessing(issue);
|
||||||
@ -368,7 +368,6 @@ export class IssuesProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check if the issue is stale, if not, check if it is rotten and then log the findings.
|
// Check if the issue is stale, if not, check if it is rotten and then log the findings.
|
||||||
if (issue.isStale) {
|
if (issue.isStale) {
|
||||||
issueLogger.info(`This $$type includes a stale label`);
|
issueLogger.info(`This $$type includes a stale label`);
|
||||||
@ -376,8 +375,7 @@ export class IssuesProcessor {
|
|||||||
issueLogger.info(`This $$type does not include a stale label`);
|
issueLogger.info(`This $$type does not include a stale label`);
|
||||||
if (issue.isRotten) {
|
if (issue.isRotten) {
|
||||||
issueLogger.info(`This $$type includes a rotten label`);
|
issueLogger.info(`This $$type includes a rotten label`);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issueLogger.info(`This $$type does not include a rotten label`);
|
issueLogger.info(`This $$type does not include a rotten label`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -495,8 +493,7 @@ export class IssuesProcessor {
|
|||||||
closeMessage,
|
closeMessage,
|
||||||
closeLabel
|
closeLabel
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const shouldIgnoreUpdates: boolean = new IgnoreUpdates(
|
const shouldIgnoreUpdates: boolean = new IgnoreUpdates(
|
||||||
this.options,
|
this.options,
|
||||||
issue
|
issue
|
||||||
@ -587,7 +584,7 @@ export class IssuesProcessor {
|
|||||||
labelsToAddWhenUnrotten,
|
labelsToAddWhenUnrotten,
|
||||||
labelsToRemoveWhenUnrotten,
|
labelsToRemoveWhenUnrotten,
|
||||||
labelsToRemoveWhenRotten,
|
labelsToRemoveWhenRotten,
|
||||||
skipRottenMessage,
|
skipRottenMessage
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,7 +721,7 @@ export class IssuesProcessor {
|
|||||||
) {
|
) {
|
||||||
const issueLogger: IssueLogger = new IssueLogger(issue);
|
const issueLogger: IssueLogger = new IssueLogger(issue);
|
||||||
|
|
||||||
var issueHasClosed: boolean = false
|
let issueHasClosed: boolean = false;
|
||||||
|
|
||||||
// We can get the label creation date from the getLableCreationDate function
|
// We can get the label creation date from the getLableCreationDate function
|
||||||
const markedStaleOn: string =
|
const markedStaleOn: string =
|
||||||
@ -826,17 +823,15 @@ export class IssuesProcessor {
|
|||||||
`Stale $$type cannot be rotten or closed because days before rotten: ${daysBeforeRotten}, and days before close: ${daysBeforeClose}`
|
`Stale $$type cannot be rotten or closed because days before rotten: ${daysBeforeRotten}, and days before close: ${daysBeforeClose}`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issueLogger.info(
|
issueLogger.info(
|
||||||
`Closing issue without rottening it because days before $$type rotten: ${LoggerService.cyan(daysBeforeRotten)}`
|
`Closing issue without rottening it because days before $$type rotten: ${LoggerService.cyan(
|
||||||
|
daysBeforeRotten
|
||||||
|
)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
let issueHasUpdateInCloseWindow: boolean
|
const issueHasUpdateInCloseWindow: boolean =
|
||||||
issueHasUpdateInCloseWindow = IssuesProcessor._updatedSince(
|
IssuesProcessor._updatedSince(issue.updated_at, daysBeforeClose);
|
||||||
issue.updated_at,
|
|
||||||
daysBeforeClose
|
|
||||||
);
|
|
||||||
issueLogger.info(
|
issueLogger.info(
|
||||||
`$$type has been updated in the last ${daysBeforeClose} days: ${LoggerService.cyan(
|
`$$type has been updated in the last ${daysBeforeClose} days: ${LoggerService.cyan(
|
||||||
issueHasUpdateInCloseWindow
|
issueHasUpdateInCloseWindow
|
||||||
@ -887,8 +882,7 @@ export class IssuesProcessor {
|
|||||||
issue
|
issue
|
||||||
).shouldIgnoreUpdates();
|
).shouldIgnoreUpdates();
|
||||||
|
|
||||||
let shouldBeRotten: boolean;
|
const shouldBeRotten: boolean = !IssuesProcessor._updatedSince(
|
||||||
shouldBeRotten = !IssuesProcessor._updatedSince(
|
|
||||||
issue.updated_at,
|
issue.updated_at,
|
||||||
daysBeforeRotten
|
daysBeforeRotten
|
||||||
);
|
);
|
||||||
@ -914,7 +908,12 @@ export class IssuesProcessor {
|
|||||||
this._getDaysBeforeRottenUsedOptionName(issue)
|
this._getDaysBeforeRottenUsedOptionName(issue)
|
||||||
)} (${LoggerService.cyan(daysBeforeRotten)})`
|
)} (${LoggerService.cyan(daysBeforeRotten)})`
|
||||||
);
|
);
|
||||||
await this._markRotten(issue, rottenMessage, rottenLabel, skipMessage);
|
await this._markRotten(
|
||||||
|
issue,
|
||||||
|
rottenMessage,
|
||||||
|
rottenLabel,
|
||||||
|
skipMessage
|
||||||
|
);
|
||||||
issue.isRotten = true; // This issue is now considered rotten
|
issue.isRotten = true; // This issue is now considered rotten
|
||||||
issue.markedRottenThisRun = true;
|
issue.markedRottenThisRun = true;
|
||||||
issueLogger.info(`This $$type is now rotten`);
|
issueLogger.info(`This $$type is now rotten`);
|
||||||
@ -952,10 +951,9 @@ export class IssuesProcessor {
|
|||||||
labelsToRemoveWhenUnrotten,
|
labelsToRemoveWhenUnrotten,
|
||||||
labelsToRemoveWhenRotten,
|
labelsToRemoveWhenRotten,
|
||||||
closeMessage,
|
closeMessage,
|
||||||
closeLabel,
|
closeLabel
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private async _processRottenIssue(
|
private async _processRottenIssue(
|
||||||
issue: Issue,
|
issue: Issue,
|
||||||
@ -1054,7 +1052,9 @@ export class IssuesProcessor {
|
|||||||
);
|
);
|
||||||
await this._addLabelsWhenUnrotten(issue, labelsToAddWhenUnrotten);
|
await this._addLabelsWhenUnrotten(issue, labelsToAddWhenUnrotten);
|
||||||
|
|
||||||
issueLogger.info(`Skipping the process since the $$type is now un-rotten`);
|
issueLogger.info(
|
||||||
|
`Skipping the process since the $$type is now un-rotten`
|
||||||
|
);
|
||||||
|
|
||||||
return; // Nothing to do because it is no longer rotten
|
return; // Nothing to do because it is no longer rotten
|
||||||
}
|
}
|
||||||
@ -1237,7 +1237,6 @@ export class IssuesProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Close an issue based on staleness
|
// Close an issue based on staleness
|
||||||
private async _closeIssue(
|
private async _closeIssue(
|
||||||
issue: Issue,
|
issue: Issue,
|
||||||
@ -1357,7 +1356,8 @@ export class IssuesProcessor {
|
|||||||
issueLogger.warning(
|
issueLogger.warning(
|
||||||
`Deleting the branch "${LoggerService.cyan(
|
`Deleting the branch "${LoggerService.cyan(
|
||||||
branch
|
branch
|
||||||
)}" has skipped because it belongs to other repo ${pullRequest.head.repo.full_name
|
)}" has skipped because it belongs to other repo ${
|
||||||
|
pullRequest.head.repo.full_name
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1372,7 +1372,8 @@ export class IssuesProcessor {
|
|||||||
const issueLogger: IssueLogger = new IssueLogger(issue);
|
const issueLogger: IssueLogger = new IssueLogger(issue);
|
||||||
|
|
||||||
issueLogger.info(
|
issueLogger.info(
|
||||||
`${isSubStep ? LoggerService.white('├── ') : ''
|
`${
|
||||||
|
isSubStep ? LoggerService.white('├── ') : ''
|
||||||
}Removing the label "${LoggerService.cyan(label)}" from this $$type...`
|
}Removing the label "${LoggerService.cyan(label)}" from this $$type...`
|
||||||
);
|
);
|
||||||
this.removedLabelIssues.push(issue);
|
this.removedLabelIssues.push(issue);
|
||||||
@ -1391,12 +1392,14 @@ export class IssuesProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
issueLogger.info(
|
issueLogger.info(
|
||||||
`${isSubStep ? LoggerService.white('└── ') : ''
|
`${
|
||||||
|
isSubStep ? LoggerService.white('└── ') : ''
|
||||||
}The label "${LoggerService.cyan(label)}" was removed`
|
}The label "${LoggerService.cyan(label)}" was removed`
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
issueLogger.error(
|
issueLogger.error(
|
||||||
`${isSubStep ? LoggerService.white('└── ') : ''
|
`${
|
||||||
|
isSubStep ? LoggerService.white('└── ') : ''
|
||||||
}Error when removing the label: "${LoggerService.cyan(error.message)}"`
|
}Error when removing the label: "${LoggerService.cyan(error.message)}"`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1437,7 +1440,6 @@ export class IssuesProcessor {
|
|||||||
: this.options.daysBeforePrClose;
|
: this.options.daysBeforePrClose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private _getOnlyLabels(issue: Issue): string {
|
private _getOnlyLabels(issue: Issue): string {
|
||||||
if (issue.isPullRequest) {
|
if (issue.isPullRequest) {
|
||||||
if (this.options.onlyPrLabels !== '') {
|
if (this.options.onlyPrLabels !== '') {
|
||||||
@ -1523,7 +1525,6 @@ export class IssuesProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async _addLabelsWhenUnstale(
|
private async _addLabelsWhenUnstale(
|
||||||
issue: Issue,
|
issue: Issue,
|
||||||
labelsToAdd: Readonly<string>[]
|
labelsToAdd: Readonly<string>[]
|
||||||
|
@ -80,7 +80,6 @@ export class Statistics {
|
|||||||
return this._incrementUndoRottenIssuesCount(increment);
|
return this._incrementUndoRottenIssuesCount(increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setOperationsCount(operationsCount: Readonly<number>): Statistics {
|
setOperationsCount(operationsCount: Readonly<number>): Statistics {
|
||||||
this.operationsCount = operationsCount;
|
this.operationsCount = operationsCount;
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ export enum Option {
|
|||||||
LabelsToRemoveWhenUnstale = 'labels-to-remove-when-unstale',
|
LabelsToRemoveWhenUnstale = 'labels-to-remove-when-unstale',
|
||||||
LabelsToAddWhenUnstale = 'labels-to-add-when-unstale',
|
LabelsToAddWhenUnstale = 'labels-to-add-when-unstale',
|
||||||
LabelsToRemoveWhenRotten = 'labels-to-remove-when-rotten',
|
LabelsToRemoveWhenRotten = 'labels-to-remove-when-rotten',
|
||||||
LabelsToRemoveWhenUnrotten = 'labels-to-remove-when-unstale',
|
LabelsToRemoveWhenUnrotten = 'labels-to-remove-when-unrotten',
|
||||||
LabelsToAddWhenUnrotten = 'labels-to-add-when-unstale',
|
LabelsToAddWhenUnrotten = 'labels-to-add-when-unrotten',
|
||||||
IgnoreUpdates = 'ignore-updates',
|
IgnoreUpdates = 'ignore-updates',
|
||||||
IgnoreIssueUpdates = 'ignore-issue-updates',
|
IgnoreIssueUpdates = 'ignore-issue-updates',
|
||||||
IgnorePrUpdates = 'ignore-pr-updates',
|
IgnorePrUpdates = 'ignore-pr-updates',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { IsoOrRfcDateString } from '../types/iso-or-rfc-date-string';
|
import {IsoOrRfcDateString} from '../types/iso-or-rfc-date-string';
|
||||||
|
|
||||||
export interface IIssuesProcessorOptions {
|
export interface IIssuesProcessorOptions {
|
||||||
repoToken: string;
|
repoToken: string;
|
||||||
|
@ -72,7 +72,9 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
|||||||
),
|
),
|
||||||
daysBeforeIssueStale: parseFloat(core.getInput('days-before-issue-stale')),
|
daysBeforeIssueStale: parseFloat(core.getInput('days-before-issue-stale')),
|
||||||
daysBeforePrStale: parseFloat(core.getInput('days-before-pr-stale')),
|
daysBeforePrStale: parseFloat(core.getInput('days-before-pr-stale')),
|
||||||
daysBeforeIssueRotten: parseFloat(core.getInput('days-before-issue-rotten')),
|
daysBeforeIssueRotten: parseFloat(
|
||||||
|
core.getInput('days-before-issue-rotten')
|
||||||
|
),
|
||||||
daysBeforePrRotten: parseFloat(core.getInput('days-before-pr-rotten')),
|
daysBeforePrRotten: parseFloat(core.getInput('days-before-pr-rotten')),
|
||||||
daysBeforeClose: parseInt(
|
daysBeforeClose: parseInt(
|
||||||
core.getInput('days-before-close', {required: true})
|
core.getInput('days-before-close', {required: true})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user