fix linting

This commit is contained in:
mviswanathsai 2024-03-05 19:03:44 +05:30
parent e0c4e25b76
commit 8fb3b504a0
No known key found for this signature in database
GPG Key ID: 87DE7BD64227C60A
6 changed files with 1800 additions and 1798 deletions

View File

@ -1,88 +1,88 @@
import { isLabeled } from '../functions/is-labeled';
import { isPullRequest } from '../functions/is-pull-request';
import { Assignee } from '../interfaces/assignee';
import { IIssue, OctokitIssue } from '../interfaces/issue';
import { IIssuesProcessorOptions } from '../interfaces/issues-processor-options';
import { ILabel } from '../interfaces/label';
import { IMilestone } from '../interfaces/milestone';
import { IsoDateString } from '../types/iso-date-string';
import { Operations } from './operations';
import {isLabeled} from '../functions/is-labeled';
import {isPullRequest} from '../functions/is-pull-request';
import {Assignee} from '../interfaces/assignee';
import {IIssue, OctokitIssue} from '../interfaces/issue';
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
import {ILabel} from '../interfaces/label';
import {IMilestone} from '../interfaces/milestone';
import {IsoDateString} from '../types/iso-date-string';
import {Operations} from './operations';
export class Issue implements IIssue {
readonly title: string;
readonly number: number;
created_at: IsoDateString;
updated_at: IsoDateString;
readonly draft: boolean;
readonly labels: ILabel[];
readonly pull_request: object | null | undefined;
readonly state: string | 'closed' | 'open';
readonly locked: boolean;
readonly milestone?: IMilestone | null;
readonly assignees: Assignee[];
isStale: boolean;
isRotten: boolean;
markedStaleThisRun: boolean;
markedRottenThisRun: boolean;
operations = new Operations();
private readonly _options: IIssuesProcessorOptions;
readonly title: string;
readonly number: number;
created_at: IsoDateString;
updated_at: IsoDateString;
readonly draft: boolean;
readonly labels: ILabel[];
readonly pull_request: object | null | undefined;
readonly state: string | 'closed' | 'open';
readonly locked: boolean;
readonly milestone?: IMilestone | null;
readonly assignees: Assignee[];
isStale: boolean;
isRotten: boolean;
markedStaleThisRun: boolean;
markedRottenThisRun: boolean;
operations = new Operations();
private readonly _options: IIssuesProcessorOptions;
constructor(
options: Readonly<IIssuesProcessorOptions>,
issue: Readonly<OctokitIssue> | Readonly<IIssue>
) {
this._options = options;
this.title = issue.title;
this.number = issue.number;
this.created_at = issue.created_at;
this.updated_at = issue.updated_at;
this.draft = Boolean(issue.draft);
this.labels = mapLabels(issue.labels);
this.pull_request = issue.pull_request;
this.state = issue.state;
this.locked = issue.locked;
this.milestone = issue.milestone;
this.assignees = issue.assignees || [];
this.isStale = isLabeled(this, this.staleLabel);
this.isRotten = isLabeled(this, this.rottenLabel);
this.markedStaleThisRun = false;
this.markedRottenThisRun = false;
}
constructor(
options: Readonly<IIssuesProcessorOptions>,
issue: Readonly<OctokitIssue> | Readonly<IIssue>
) {
this._options = options;
this.title = issue.title;
this.number = issue.number;
this.created_at = issue.created_at;
this.updated_at = issue.updated_at;
this.draft = Boolean(issue.draft);
this.labels = mapLabels(issue.labels);
this.pull_request = issue.pull_request;
this.state = issue.state;
this.locked = issue.locked;
this.milestone = issue.milestone;
this.assignees = issue.assignees || [];
this.isStale = isLabeled(this, this.staleLabel);
this.isRotten = isLabeled(this, this.rottenLabel);
this.markedStaleThisRun = false;
this.markedRottenThisRun = false;
}
get isPullRequest(): boolean {
return isPullRequest(this);
}
get isPullRequest(): boolean {
return isPullRequest(this);
}
get staleLabel(): string {
return this._getStaleLabel();
}
get rottenLabel(): string {
return this._getRottenLabel();
}
get staleLabel(): string {
return this._getStaleLabel();
}
get rottenLabel(): string {
return this._getRottenLabel();
}
get hasAssignees(): boolean {
return this.assignees.length > 0;
}
get hasAssignees(): boolean {
return this.assignees.length > 0;
}
private _getStaleLabel(): string {
return this.isPullRequest
? this._options.stalePrLabel
: this._options.staleIssueLabel;
}
private _getRottenLabel(): string {
return this.isPullRequest
? this._options.rottenPrLabel
: this._options.rottenIssueLabel;
}
private _getStaleLabel(): string {
return this.isPullRequest
? this._options.stalePrLabel
: this._options.staleIssueLabel;
}
private _getRottenLabel(): string {
return this.isPullRequest
? this._options.rottenPrLabel
: this._options.rottenIssueLabel;
}
}
function mapLabels(labels: (string | ILabel)[] | ILabel[]): ILabel[] {
return labels.map(label => {
if (typeof label == 'string') {
return {
name: label
};
}
return label;
});
return labels.map(label => {
if (typeof label == 'string') {
return {
name: label
};
}
return label;
});
}

File diff suppressed because it is too large Load Diff

View File

@ -80,7 +80,6 @@ export class Statistics {
return this._incrementUndoRottenIssuesCount(increment);
}
setOperationsCount(operationsCount: Readonly<number>): Statistics {
this.operationsCount = operationsCount;

View File

@ -55,8 +55,8 @@ export enum Option {
LabelsToRemoveWhenUnstale = 'labels-to-remove-when-unstale',
LabelsToAddWhenUnstale = 'labels-to-add-when-unstale',
LabelsToRemoveWhenRotten = 'labels-to-remove-when-rotten',
LabelsToRemoveWhenUnrotten = 'labels-to-remove-when-unstale',
LabelsToAddWhenUnrotten = 'labels-to-add-when-unstale',
LabelsToRemoveWhenUnrotten = 'labels-to-remove-when-unrotten',
LabelsToAddWhenUnrotten = 'labels-to-add-when-unrotten',
IgnoreUpdates = 'ignore-updates',
IgnoreIssueUpdates = 'ignore-issue-updates',
IgnorePrUpdates = 'ignore-pr-updates',

View File

@ -1,70 +1,70 @@
import { IsoOrRfcDateString } from '../types/iso-or-rfc-date-string';
import {IsoOrRfcDateString} from '../types/iso-or-rfc-date-string';
export interface IIssuesProcessorOptions {
repoToken: string;
staleIssueMessage: string;
stalePrMessage: string;
rottenIssueMessage: string;
rottenPrMessage: string;
closeIssueMessage: string;
closePrMessage: string;
daysBeforeStale: number;
daysBeforeIssueStale: number; // Could be NaN
daysBeforePrStale: number; // Could be NaN
daysBeforeRotten: number;
daysBeforeIssueRotten: number; // Could be NaN
daysBeforePrRotten: number; // Could be NaN
daysBeforeClose: number;
daysBeforeIssueClose: number; // Could be NaN
daysBeforePrClose: number; // Could be NaN
staleIssueLabel: string;
rottenIssueLabel: string;
closeIssueLabel: string;
exemptIssueLabels: string;
stalePrLabel: string;
rottenPrLabel: string;
closePrLabel: string;
exemptPrLabels: string;
onlyLabels: string;
onlyIssueLabels: string;
onlyPrLabels: string;
anyOfLabels: string;
anyOfIssueLabels: string;
anyOfPrLabels: string;
operationsPerRun: number;
removeStaleWhenUpdated: boolean;
removeIssueStaleWhenUpdated: boolean | undefined;
removePrStaleWhenUpdated: boolean | undefined;
removeRottenWhenUpdated: boolean;
removeIssueRottenWhenUpdated: boolean | undefined;
removePrRottenWhenUpdated: boolean | undefined;
debugOnly: boolean;
ascending: boolean;
deleteBranch: boolean;
startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822
exemptMilestones: string;
exemptIssueMilestones: string;
exemptPrMilestones: string;
exemptAllMilestones: boolean;
exemptAllIssueMilestones: boolean | undefined;
exemptAllPrMilestones: boolean | undefined;
exemptAssignees: string;
exemptIssueAssignees: string;
exemptPrAssignees: string;
exemptAllAssignees: boolean;
exemptAllIssueAssignees: boolean | undefined;
exemptAllPrAssignees: boolean | undefined;
enableStatistics: boolean;
labelsToRemoveWhenStale: string;
labelsToRemoveWhenUnstale: string;
labelsToAddWhenUnstale: string;
labelsToRemoveWhenRotten: string;
labelsToRemoveWhenUnrotten: string;
labelsToAddWhenUnrotten: string;
ignoreUpdates: boolean;
ignoreIssueUpdates: boolean | undefined;
ignorePrUpdates: boolean | undefined;
exemptDraftPr: boolean;
closeIssueReason: string;
includeOnlyAssigned: boolean;
repoToken: string;
staleIssueMessage: string;
stalePrMessage: string;
rottenIssueMessage: string;
rottenPrMessage: string;
closeIssueMessage: string;
closePrMessage: string;
daysBeforeStale: number;
daysBeforeIssueStale: number; // Could be NaN
daysBeforePrStale: number; // Could be NaN
daysBeforeRotten: number;
daysBeforeIssueRotten: number; // Could be NaN
daysBeforePrRotten: number; // Could be NaN
daysBeforeClose: number;
daysBeforeIssueClose: number; // Could be NaN
daysBeforePrClose: number; // Could be NaN
staleIssueLabel: string;
rottenIssueLabel: string;
closeIssueLabel: string;
exemptIssueLabels: string;
stalePrLabel: string;
rottenPrLabel: string;
closePrLabel: string;
exemptPrLabels: string;
onlyLabels: string;
onlyIssueLabels: string;
onlyPrLabels: string;
anyOfLabels: string;
anyOfIssueLabels: string;
anyOfPrLabels: string;
operationsPerRun: number;
removeStaleWhenUpdated: boolean;
removeIssueStaleWhenUpdated: boolean | undefined;
removePrStaleWhenUpdated: boolean | undefined;
removeRottenWhenUpdated: boolean;
removeIssueRottenWhenUpdated: boolean | undefined;
removePrRottenWhenUpdated: boolean | undefined;
debugOnly: boolean;
ascending: boolean;
deleteBranch: boolean;
startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822
exemptMilestones: string;
exemptIssueMilestones: string;
exemptPrMilestones: string;
exemptAllMilestones: boolean;
exemptAllIssueMilestones: boolean | undefined;
exemptAllPrMilestones: boolean | undefined;
exemptAssignees: string;
exemptIssueAssignees: string;
exemptPrAssignees: string;
exemptAllAssignees: boolean;
exemptAllIssueAssignees: boolean | undefined;
exemptAllPrAssignees: boolean | undefined;
enableStatistics: boolean;
labelsToRemoveWhenStale: string;
labelsToRemoveWhenUnstale: string;
labelsToAddWhenUnstale: string;
labelsToRemoveWhenRotten: string;
labelsToRemoveWhenUnrotten: string;
labelsToAddWhenUnrotten: string;
ignoreUpdates: boolean;
ignoreIssueUpdates: boolean | undefined;
ignorePrUpdates: boolean | undefined;
exemptDraftPr: boolean;
closeIssueReason: string;
includeOnlyAssigned: boolean;
}

View File

@ -72,7 +72,9 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
),
daysBeforeIssueStale: parseFloat(core.getInput('days-before-issue-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')),
daysBeforeClose: parseInt(
core.getInput('days-before-close', {required: true})