diff --git a/.eslintrc.json b/.eslintrc.json
index 0236a06..9ec7f29 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -195,7 +195,7 @@
// "no-lonely-if": "warn",
"no-mixed-spaces-and-tabs": "warn",
"no-multiple-empty-lines": "warn",
- // "no-negated-condition": "off",
+ "no-negated-condition": "warn",
// "no-nested-ternary": "warn",
// "no-new-object": "warn",
// "no-plusplus": "off",
diff --git a/scripts/close-stale-theme-prs.js b/scripts/close-stale-theme-prs.js
index 3b513f1..4f2c936 100644
--- a/scripts/close-stale-theme-prs.js
+++ b/scripts/close-stale-theme-prs.js
@@ -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) {
diff --git a/scripts/generate-theme-doc.js b/scripts/generate-theme-doc.js
index f39ef5c..524ddec 100644
--- a/scripts/generate-theme-doc.js
+++ b/scripts/generate-theme-doc.js
@@ -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) {
diff --git a/scripts/preview-theme.js b/scripts/preview-theme.js
index fd55d57..65f37a4 100644
--- a/scripts/preview-theme.js
+++ b/scripts/preview-theme.js
@@ -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);
}
diff --git a/src/cards/stats-card.js b/src/cards/stats-card.js
index 88e7531..5f57205 100644
--- a/src/cards/stats-card.js
+++ b/src/cards/stats-card.js
@@ -163,7 +163,7 @@ const getStyles = ({
.bold { font-weight: 700 }
.icon {
fill: ${iconColor};
- display: ${!!show_icons ? "block" : "none"};
+ display: ${show_icons ? "block" : "none"};
}
.rank-circle-rim {
diff --git a/src/cards/top-languages-card.js b/src/cards/top-languages-card.js
index 9593f98..758bd34 100644
--- a/src/cards/top-languages-card.js
+++ b/src/cards/top-languages-card.js
@@ -383,14 +383,14 @@ const renderCompactLayout = (langs, width, totalLanguageSize, hideProgress) => {
return `
${
- !hideProgress
- ? `
-
-
-
- ${compactProgressBar}
- `
- : ""
+ hideProgress
+ ? ""
+ : `
+
+
+
+ ${compactProgressBar}
+ `
}
${createLanguageTextNode({
diff --git a/src/cards/wakatime-card.js b/src/cards/wakatime-card.js
index 5dbee54..a6a203d 100644
--- a/src/cards/wakatime-card.js
+++ b/src/cards/wakatime-card.js
@@ -315,11 +315,11 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
: noCodingActivityNode({
// @ts-ignore
color: textColor,
- text: !stats.is_coding_activity_visible
- ? i18n.t("wakatimecard.notpublic")
- : stats.is_other_usage_visible
- ? i18n.t("wakatimecard.nocodingactivity")
- : i18n.t("wakatimecard.nocodedetails"),
+ text: stats.is_coding_activity_visible
+ ? stats.is_other_usage_visible
+ ? i18n.t("wakatimecard.nocodingactivity")
+ : i18n.t("wakatimecard.nocodedetails")
+ : i18n.t("wakatimecard.notpublic"),
})
}
`;
@@ -344,11 +344,11 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
noCodingActivityNode({
// @ts-ignore
color: textColor,
- text: !stats.is_coding_activity_visible
- ? i18n.t("wakatimecard.notpublic")
- : stats.is_other_usage_visible
- ? i18n.t("wakatimecard.nocodingactivity")
- : i18n.t("wakatimecard.nocodedetails"),
+ text: stats.is_coding_activity_visible
+ ? stats.is_other_usage_visible
+ ? i18n.t("wakatimecard.nocodingactivity")
+ : i18n.t("wakatimecard.nocodedetails")
+ : i18n.t("wakatimecard.notpublic"),
}),
],
gap: lheight,
diff --git a/src/common/Card.js b/src/common/Card.js
index 408ace9..d32da56 100644
--- a/src/common/Card.js
+++ b/src/common/Card.js
@@ -39,9 +39,9 @@ class Card {
// returns theme based colors with proper overrides and defaults
this.colors = colors;
this.title =
- customTitle !== undefined
- ? encodeHTML(customTitle)
- : encodeHTML(defaultTitle);
+ customTitle === undefined
+ ? encodeHTML(defaultTitle)
+ : encodeHTML(customTitle);
this.css = "";
diff --git a/src/common/utils.js b/src/common/utils.js
index 95d683c..4fb473e 100644
--- a/src/common/utils.js
+++ b/src/common/utils.js
@@ -415,7 +415,7 @@ const wrapTextMultiline = (text, width = 59, maxLines = 3) => {
const noop = () => {};
// return console instance based on the environment
const logger =
- process.env.NODE_ENV !== "test" ? console : { log: noop, error: noop };
+ process.env.NODE_ENV === "test" ? { log: noop, error: noop } : console;
const ONE_MINUTE = 60;
const FIVE_MINUTES = 300;
diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js
index 1d6aebf..115cd50 100644
--- a/src/fetchers/stats-fetcher.js
+++ b/src/fetchers/stats-fetcher.js
@@ -89,7 +89,7 @@ const GRAPHQL_STATS_QUERY = `
* @returns {Promise} Axios response.
*/
const fetcher = (variables, token) => {
- const query = !variables.after ? GRAPHQL_STATS_QUERY : GRAPHQL_REPOS_QUERY;
+ const query = variables.after ? GRAPHQL_REPOS_QUERY : GRAPHQL_STATS_QUERY;
return request(
{
query,
@@ -138,10 +138,10 @@ const statsFetcher = async ({
// Store stats data.
const repoNodes = res.data.data.user.repositories.nodes;
- if (!stats) {
- stats = res;
- } else {
+ if (stats) {
stats.data.data.user.repositories.nodes.push(...repoNodes);
+ } else {
+ stats = res;
}
// Disable multi page fetching on public Vercel instance due to rate limits.