mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-19 16:38:23 +00:00
infra: enable no-negated-condition eslint rule (#3283)
* infra: enable no-negated-condition eslint rule * dev * dev
This commit is contained in:
parent
2567a6e580
commit
8278980d25
10 changed files with 59 additions and 59 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -383,14 +383,14 @@ const renderCompactLayout = (langs, width, totalLanguageSize, hideProgress) => {
|
|||
|
||||
return `
|
||||
${
|
||||
!hideProgress
|
||||
? `
|
||||
hideProgress
|
||||
? ""
|
||||
: `
|
||||
<mask id="rect-mask">
|
||||
<rect x="0" y="0" width="${offsetWidth}" height="8" fill="white" rx="5"/>
|
||||
</mask>
|
||||
${compactProgressBar}
|
||||
`
|
||||
: ""
|
||||
}
|
||||
<g transform="translate(0, ${hideProgress ? "0" : "25"})">
|
||||
${createLanguageTextNode({
|
||||
|
|
|
|||
|
|
@ -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
|
||||
text: stats.is_coding_activity_visible
|
||||
? stats.is_other_usage_visible
|
||||
? i18n.t("wakatimecard.nocodingactivity")
|
||||
: i18n.t("wakatimecard.nocodedetails"),
|
||||
: 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
|
||||
text: stats.is_coding_activity_visible
|
||||
? stats.is_other_usage_visible
|
||||
? i18n.t("wakatimecard.nocodingactivity")
|
||||
: i18n.t("wakatimecard.nocodedetails"),
|
||||
: i18n.t("wakatimecard.nocodedetails")
|
||||
: i18n.t("wakatimecard.notpublic"),
|
||||
}),
|
||||
],
|
||||
gap: lheight,
|
||||
|
|
|
|||
|
|
@ -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 = "";
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ const GRAPHQL_STATS_QUERY = `
|
|||
* @returns {Promise<AxiosResponse>} 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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue