infra: enable no-negated-condition eslint rule (#3283)

* infra: enable no-negated-condition eslint rule

* dev

* dev
This commit is contained in:
Alexandr Garbuzov
2023-10-15 21:38:32 +03:00
committed by GitHub
parent 2567a6e580
commit 8278980d25
10 changed files with 59 additions and 59 deletions
+3 -3
View File
@@ -155,7 +155,9 @@ const run = async () => {
// Loop through all stale invalid theme pull requests and close them.
for (const prNumber of staleThemePRsNumbers) {
debug(`Closing #${prNumber} because it is stale...`);
if (!dryRun) {
if (dryRun) {
debug("Dry run enabled, skipping...");
} else {
await octokit.rest.issues.createComment({
owner,
repo,
@@ -168,8 +170,6 @@ const run = async () => {
pull_number: prNumber,
state: "closed",
});
} else {
debug("Dry run enabled, skipping...");
}
}
} catch (error) {
+1 -1
View File
@@ -69,7 +69,7 @@ const createTableItem = ({ link, label, isRepoCard }) => {
const generateTable = ({ isRepoCard }) => {
const rows = [];
const themesFiltered = Object.keys(themes).filter(
(name) => name !== (!isRepoCard ? "default_repocard" : "default"),
(name) => name !== (isRepoCard ? "default" : "default_repocard"),
);
for (let i = 0; i < themesFiltered.length; i += 3) {
+27 -27
View File
@@ -172,20 +172,20 @@ const upsertComment = async (
body,
) => {
let resp;
if (commentId !== undefined) {
resp = await octokit.rest.issues.updateComment({
owner,
repo,
comment_id: commentId,
body,
});
} else {
if (commentId === undefined) {
resp = await octokit.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body,
});
} else {
resp = await octokit.rest.issues.updateComment({
owner,
repo,
comment_id: commentId,
body,
});
}
return resp.data.html_url;
};
@@ -341,10 +341,10 @@ const parseJSON = (json) => {
.filter((x) => typeof x !== "string" || !!x.trim()); // Split json into array of strings and objects.
if (splitJson[0].replace(/\s+/g, "") === "},") {
splitJson[0] = "},";
if (!/\s*}\s*,?\s*$/.test(splitJson[1])) {
splitJson.push(splitJson.shift());
} else {
if (/\s*}\s*,?\s*$/.test(splitJson[1])) {
splitJson.shift();
} else {
splitJson.push(splitJson.shift());
}
parsedJson = splitJson.join("");
}
@@ -466,10 +466,7 @@ export const run = async () => {
// Check if the theme colors are valid.
debug("Theme preview body: Check if the theme colors are valid...");
let invalidColors = false;
if (!colors) {
warnings.push("Theme colors are missing");
invalidColors = true;
} else {
if (colors) {
const missingKeys = REQUIRED_COLOR_PROPS.filter(
(x) => !Object.keys(colors).includes(x),
);
@@ -507,6 +504,9 @@ export const run = async () => {
}
}
}
} else {
warnings.push("Theme colors are missing");
invalidColors = true;
}
if (invalidColors) {
themeValid[theme] = false;
@@ -597,7 +597,10 @@ export const run = async () => {
// Create or update theme-preview comment.
debug("Create or update theme-preview comment...");
let comment_url;
if (!DRY_RUN) {
if (DRY_RUN) {
info(`DRY_RUN: Comment body: ${commentBody}`);
comment_url = "";
} else {
comment_url = await upsertComment(
OCTOKIT,
PULL_REQUEST_ID,
@@ -606,9 +609,6 @@ export const run = async () => {
comment?.id,
commentBody,
);
} else {
info(`DRY_RUN: Comment body: ${commentBody}`);
comment_url = "";
}
// Change review state and add/remove `invalid` label based on theme PR validity.
@@ -620,7 +620,10 @@ export const run = async () => {
const reviewReason = themesValid
? undefined
: INVALID_REVIEW_COMMENT(comment_url);
if (!DRY_RUN) {
if (DRY_RUN) {
info(`DRY_RUN: Review state: ${reviewState}`);
info(`DRY_RUN: Review reason: ${reviewReason}`);
} else {
await addReview(
OCTOKIT,
PULL_REQUEST_ID,
@@ -637,13 +640,13 @@ export const run = async () => {
"invalid",
!themesValid,
);
} else {
info(`DRY_RUN: Review state: ${reviewState}`);
info(`DRY_RUN: Review reason: ${reviewReason}`);
}
} catch (error) {
debug("Set review state to `REQUEST_CHANGES` and add `invalid` label...");
if (!DRY_RUN) {
if (DRY_RUN) {
info(`DRY_RUN: Review state: REQUEST_CHANGES`);
info(`DRY_RUN: Review reason: ${error.message}`);
} else {
await addReview(
OCTOKIT,
PULL_REQUEST_ID,
@@ -662,9 +665,6 @@ export const run = async () => {
"invalid",
true,
);
} else {
info(`DRY_RUN: Review state: REQUEST_CHANGES`);
info(`DRY_RUN: Review reason: ${error.message}`);
}
setFailed(error.message);
}