Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"curly": ["error", "all"],
"default-case": 1,
"eol-last": ["warn", "always"],
"eqeqeq": ["error", "smart"],
"indent": ["warn", 4, {
"SwitchCase": 1
}],
Expand All @@ -55,6 +56,7 @@
"objectsInObjects": true,
"arraysInObjects": true
}],
"object-shorthand": ["warn", "consistent"],
"quotes": ["warn", "double", {
"avoidEscape": false
}],
Expand Down
20 changes: 10 additions & 10 deletions src/class/issuesComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ export default class IssuesComment {
* @returns {Promise<void>}
*/
public async userPRsComment(): Promise<void> {
if (this.context.payload.comment.body.toLowerCase() == "ready to merge") {
if (this.context.payload.comment.body.toLowerCase() === "ready to merge") {
await this.context.octokit.pulls.get({
repo: this.context.payload.repository.name,
owner: this.context.payload.repository.owner.login,
pull_number: this.context.payload.issue.number
}).then(async (res) => {
if (res.data.mergeable_state.toLowerCase() == "clean" || res.data.mergeable == true) {
if (this.context.payload.issue.user.login == this.context.payload.comment.user.login) {
if (res.data.mergeable_state.toLowerCase() === "clean" || res.data.mergeable === true) {
if (this.context.payload.issue.user.login === this.context.payload.comment.user.login) {
let i: number;
for (i = 0; i < this.context.payload.issue.labels.length; i++) {
if (this.context.payload.issue.labels[i].name == "Approved") {
if (this.context.payload.issue.labels[i].name === "Approved") {
console.log("Merging");
await this.context.octokit.pulls.merge({
repo: this.context.payload.repository.name,
Expand All @@ -53,7 +53,7 @@ export default class IssuesComment {
})
);
break;
} else if (this.context.payload.issue.labels[i].name == "Requested Changes") {
} else if (this.context.payload.issue.labels[i].name === "Requested Changes") {
console.log("PRs Blocked");
await this.context.octokit.issues.createComment(
this.context.issue({
Expand All @@ -68,7 +68,7 @@ export default class IssuesComment {
} else {
return;
}
} else if (res.data.mergeable_state.toLowerCase() == "dirty" || res.data.mergeable == false) {
} else if (res.data.mergeable_state.toLowerCase() === "dirty" || res.data.mergeable === false) {
await this.context.octokit.issues.createComment(
this.context.issue({
body: `Merging blocked because PRs has merge conflict! @${this.context.payload.comment.user.login}`
Expand All @@ -84,8 +84,8 @@ export default class IssuesComment {
});
}

if (this.context.payload.comment.body.toLowerCase() == "merge") {
if (this.context.payload.sender.login == this.context.payload.repository.owner.login) {
if (this.context.payload.comment.body.toLowerCase() === "merge") {
if (this.context.payload.sender.login === this.context.payload.repository.owner.login) {
await this.context.octokit.pulls.merge({
repo: this.context.payload.repository.name,
owner: this.context.payload.repository.owner.login,
Expand Down Expand Up @@ -140,8 +140,8 @@ export default class IssuesComment {
* @returns {Promise<void>}
*/
public async botPRsComment(): Promise<void> {
if (this.context.payload.comment.body.toLowerCase() == "merge") {
if (this.context.payload.sender.login == this.context.payload.repository.owner.login) {
if (this.context.payload.comment.body.toLowerCase() === "merge") {
if (this.context.payload.sender.login === this.context.payload.repository.owner.login) {
await this.context.octokit.pulls.merge({
repo: this.context.payload.repository.name,
owner: this.context.payload.repository.owner.login,
Expand Down
2 changes: 1 addition & 1 deletion src/class/prsOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default class PullRequestOpen {
*/
public async open(): Promise<void> {

if (this.context.payload.sender.login != this.context.payload.repository.owner.login) {
if (this.context.payload.sender.login !== this.context.payload.repository.owner.login) {
const propened = this.context.issue({
body: `Hello @${this.context.payload.sender.login} Thank you for submitting Pull Request, please wait for next notification after we review your Pull Request`
});
Expand Down
56 changes: 28 additions & 28 deletions src/class/prsReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,51 +68,51 @@ export default class PullRequestReview {
* @returns {Promise<void>}
*/
public async userPRs(): Promise<void> {
if (this.context.payload.sender.login == this.context.payload.repository.owner.login) {
if (this.context.payload.sender.login === this.context.payload.repository.owner.login) {
// Owner
if (this.context.payload.review.state == "approved") {
if (this.context.payload.review.state === "approved") {
const reviewMessage = `@${this.context.payload.pull_request.user.login} your pull request has been approved by @${this.context.payload.review.user.login}, please type \`Ready to merge\` for merging`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Requested Changes")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Requested Changes")) {
await this.createReview(reviewMessage, ["Approved"], ["Requested Changes", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Approved"], ["Pending"]);
}
} else if (this.context.payload.review.state == "changes_requested") {
} else if (this.context.payload.review.state === "changes_requested") {
const reviewMessage = `Pull request has requested changes by @${this.context.payload.review.user.login}. PING! @${this.context.payload.pull_request.user.login} Please address their comments before I'm merging this PR, thanks!`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Approved")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Approved")) {
await this.createReview(reviewMessage, ["Requested Changes"], ["Approved", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Requested Changes"], ["Pending"]);
}
}
} else if (this.context.payload.pull_request.author_association == "MEMBER" || this.context.payload.pull_request.author_association == "COLLABORATOR") {
if (this.context.payload.review.state == "approved") {
} else if (this.context.payload.pull_request.author_association === "MEMBER" || this.context.payload.pull_request.author_association === "COLLABORATOR") {
if (this.context.payload.review.state === "approved") {
const reviewMessage = `@${this.context.payload.pull_request.user.login} your pull request has been approved by \`[MAINTAINER]\`@${this.context.payload.review.user.login}, please type \`Ready to merge\` for merging`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Requested Changes")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Requested Changes")) {
await this.createReview(reviewMessage, ["Approved"], ["Requested Changes", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Approved"], ["Pending"]);
}
} else if (this.context.payload.review.state == "changes_requested") {
} else if (this.context.payload.review.state === "changes_requested") {
const reviewMessage = `Pull request has requested changes by @${this.context.payload.review.user.login}. PING! @${this.context.payload.pull_request.user.login} Please address their comments before I'm merging this PR, thanks!`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Approved")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Approved")) {
await this.createReview(reviewMessage, ["Requested Changes"], ["Approved", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Requested Changes"], ["Pending"]);
}
}
} else {
// Others Approved
if (this.context.payload.review.state == "approved") {
if (this.context.payload.review.state === "approved") {
const reviewMessage = `@${this.context.payload.pull_request.user.login} your pull request has been approved by @${this.context.payload.review.user.login}, even though please wait for the \`MAINTAINERS\`/\`CODEOWNERS\` to review`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Requested Changes")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Requested Changes")) {
await this.createReview(reviewMessage, ["Others Approved"], ["Requested Changes", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Others Approved"], ["Pending"]);
}
} else if (this.context.payload.review.state == "changes_requested") {
} else if (this.context.payload.review.state === "changes_requested") {
const reviewMessage = `Pull request has requested changes by @${this.context.payload.review.user.login}. PING! @${this.context.payload.pull_request.user.login} Please address their comments before I'm merging this PR, thanks!`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Others Approved")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Others Approved")) {
await this.createReview(reviewMessage, ["Requested Changes"], ["Others Approved", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Requested Changes"], ["Pending"]);
Expand All @@ -127,51 +127,51 @@ export default class PullRequestReview {
* @returns {Promise<void>}
*/
public async botPRs(): Promise<void> {
if (this.context.payload.sender.login == this.context.payload.repository.owner.login) {
if (this.context.payload.sender.login === this.context.payload.repository.owner.login) {
// Owner
if (this.context.payload.review.state == "approved") {
if (this.context.payload.review.state === "approved") {
const reviewMessage = `@${this.context.payload.pull_request.user.login} Pull request has been approved by \`[OWNER]\`@${this.context.payload.review.user.login}, please type \`Merge\` for merging @${this.context.payload.review.user.login}`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Requested Changes")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Requested Changes")) {
await this.createReview(reviewMessage, ["Approved"], ["Requested Changes", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Approved"], ["Pending"]);
}
} else if (this.context.payload.review.state == "changes_requested") {
} else if (this.context.payload.review.state === "changes_requested") {
const reviewMessage = `@${this.context.payload.pull_request.user.login} your pull request has requested changes by \`[OWNER]\`@${this.context.payload.review.user.login}. Please address their comments before I'm merging this PR, thanks!`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Approved")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Approved")) {
await this.createReview(reviewMessage, ["Requested Changes"], ["Approved", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Requested Changes"], ["Pending"]);
}
}
} else if (this.context.payload.pull_request.author_association == "MEMBER" || this.context.payload.pull_request.author_association == "COLLABORATOR") {
if (this.context.payload.review.state == "approved") {
} else if (this.context.payload.pull_request.author_association === "MEMBER" || this.context.payload.pull_request.author_association === "COLLABORATOR") {
if (this.context.payload.review.state === "approved") {
const reviewMessage = `@${this.context.payload.pull_request.user.login} Pull request has been approved by \`[MAINTAINER]\`@${this.context.payload.review.user.login}, please type \`Merge\` for merging @${this.context.payload.review.user.login}`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Requested Changes")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Requested Changes")) {
await this.createReview(reviewMessage, ["Approved"], ["Requested Changes", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Approved"], ["Pending"]);
}
} else if (this.context.payload.review.state == "changes_requested") {
} else if (this.context.payload.review.state === "changes_requested") {
const reviewMessage = `Pull request has requested changes by \`[MAINTAINER]\`@${this.context.payload.review.user.login}. PING! @${this.context.payload.pull_request.user.login} Please address their comments before I"m merging this PR, thanks!`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Approved")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Approved")) {
await this.createReview(reviewMessage, ["Requested Changes"], ["Approved", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Requested Changes"], ["Pending"]);
}
}
} else {
// Others Approved
if (this.context.payload.review.state == "approved") {
if (this.context.payload.review.state === "approved") {
const reviewMessage = `@${this.context.payload.pull_request.user.login} your pull request has been approved by @${this.context.payload.review.user.login}, even though please wait for the \`MAINTAINERS\`/\`CODEOWNERS\` to review`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Requested Changes")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Requested Changes")) {
await this.createReview(reviewMessage, ["Others Approved"], ["Requested Changes", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Others Approved"], ["Pending"]);
}
} else if (this.context.payload.review.state == "changes_requested") {
} else if (this.context.payload.review.state === "changes_requested") {
const reviewMessage = `Pull request has requested changes by @${this.context.payload.review.user.login}. PING! @${this.context.payload.pull_request.user.login} Please address their comments before I'm merging this PR, thanks!`;
if (this.context.payload.pull_request.labels.find((a) => a.name == "Others Approved")) {
if (this.context.payload.pull_request.labels.find((a) => a.name === "Others Approved")) {
await this.createReview(reviewMessage, ["Requested Changes"], ["Others Approved", "Pending"]);
} else {
await this.createReview(reviewMessage, ["Requested Changes"], ["Pending"]);
Expand Down
8 changes: 4 additions & 4 deletions src/class/prsStale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default class PRsStale {
const currentRepo = res.data[i].base.repo.name;
const currentOwner = res.data[i].base.repo.owner.login;
const currentPRs = res.data[i].number;
if (res.data[i].state.toLowerCase() == "open" && res.data[i].draft == false) {
if (res.data[i].user?.type.toLowerCase() == "user") {
if (res.data[i].state.toLowerCase() === "open" && res.data[i].draft === false) {
if (res.data[i].user?.type.toLowerCase() === "user") {
await octokit.rest.pulls.listCommits({
owner: currentOwner,
repo: currentRepo,
Expand All @@ -53,7 +53,7 @@ export default class PRsStale {
pull_number: currentPRs,
state: "closed"
}).then(async (res) => {
if (res.data.labels.find((a) => a.name == "Stale")) {
if (res.data.labels.find((a) => a.name === "Stale")) {
await octokit.rest.issues.addLabels({
owner: res.data.base.repo.owner.login,
repo: res.data.base.repo.name,
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class PRsStale {
repo: currentRepo,
pull_number: currentPRs
}).then(async (res) => {
if (res.data.labels.find((a) => a.name == "Stale")) {
if (res.data.labels.find((a) => a.name === "Stale")) {
return;
} else {
const prsReviewers: string[] = [];
Expand Down
Loading