mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-19 21:05:16 +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-lonely-if": "warn",
|
||||||
"no-mixed-spaces-and-tabs": "warn",
|
"no-mixed-spaces-and-tabs": "warn",
|
||||||
"no-multiple-empty-lines": "warn",
|
"no-multiple-empty-lines": "warn",
|
||||||
// "no-negated-condition": "off",
|
"no-negated-condition": "warn",
|
||||||
// "no-nested-ternary": "warn",
|
// "no-nested-ternary": "warn",
|
||||||
// "no-new-object": "warn",
|
// "no-new-object": "warn",
|
||||||
// "no-plusplus": "off",
|
// "no-plusplus": "off",
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,9 @@ const run = async () => {
|
||||||
// Loop through all stale invalid theme pull requests and close them.
|
// Loop through all stale invalid theme pull requests and close them.
|
||||||
for (const prNumber of staleThemePRsNumbers) {
|
for (const prNumber of staleThemePRsNumbers) {
|
||||||
debug(`Closing #${prNumber} because it is stale...`);
|
debug(`Closing #${prNumber} because it is stale...`);
|
||||||
if (!dryRun) {
|
if (dryRun) {
|
||||||
|
debug("Dry run enabled, skipping...");
|
||||||
|
} else {
|
||||||
await octokit.rest.issues.createComment({
|
await octokit.rest.issues.createComment({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
|
|
@ -168,8 +170,6 @@ const run = async () => {
|
||||||
pull_number: prNumber,
|
pull_number: prNumber,
|
||||||
state: "closed",
|
state: "closed",
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
debug("Dry run enabled, skipping...");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ const createTableItem = ({ link, label, isRepoCard }) => {
|
||||||
const generateTable = ({ isRepoCard }) => {
|
const generateTable = ({ isRepoCard }) => {
|
||||||
const rows = [];
|
const rows = [];
|
||||||
const themesFiltered = Object.keys(themes).filter(
|
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) {
|
for (let i = 0; i < themesFiltered.length; i += 3) {
|
||||||
|
|
|
||||||
|
|
@ -172,20 +172,20 @@ const upsertComment = async (
|
||||||
body,
|
body,
|
||||||
) => {
|
) => {
|
||||||
let resp;
|
let resp;
|
||||||
if (commentId !== undefined) {
|
if (commentId === undefined) {
|
||||||
resp = await octokit.rest.issues.updateComment({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
comment_id: commentId,
|
|
||||||
body,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
resp = await octokit.rest.issues.createComment({
|
resp = await octokit.rest.issues.createComment({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
issue_number: issueNumber,
|
issue_number: issueNumber,
|
||||||
body,
|
body,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
resp = await octokit.rest.issues.updateComment({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
comment_id: commentId,
|
||||||
|
body,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return resp.data.html_url;
|
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.
|
.filter((x) => typeof x !== "string" || !!x.trim()); // Split json into array of strings and objects.
|
||||||
if (splitJson[0].replace(/\s+/g, "") === "},") {
|
if (splitJson[0].replace(/\s+/g, "") === "},") {
|
||||||
splitJson[0] = "},";
|
splitJson[0] = "},";
|
||||||
if (!/\s*}\s*,?\s*$/.test(splitJson[1])) {
|
if (/\s*}\s*,?\s*$/.test(splitJson[1])) {
|
||||||
splitJson.push(splitJson.shift());
|
|
||||||
} else {
|
|
||||||
splitJson.shift();
|
splitJson.shift();
|
||||||
|
} else {
|
||||||
|
splitJson.push(splitJson.shift());
|
||||||
}
|
}
|
||||||
parsedJson = splitJson.join("");
|
parsedJson = splitJson.join("");
|
||||||
}
|
}
|
||||||
|
|
@ -466,10 +466,7 @@ export const run = async () => {
|
||||||
// Check if the theme colors are valid.
|
// Check if the theme colors are valid.
|
||||||
debug("Theme preview body: Check if the theme colors are valid...");
|
debug("Theme preview body: Check if the theme colors are valid...");
|
||||||
let invalidColors = false;
|
let invalidColors = false;
|
||||||
if (!colors) {
|
if (colors) {
|
||||||
warnings.push("Theme colors are missing");
|
|
||||||
invalidColors = true;
|
|
||||||
} else {
|
|
||||||
const missingKeys = REQUIRED_COLOR_PROPS.filter(
|
const missingKeys = REQUIRED_COLOR_PROPS.filter(
|
||||||
(x) => !Object.keys(colors).includes(x),
|
(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) {
|
if (invalidColors) {
|
||||||
themeValid[theme] = false;
|
themeValid[theme] = false;
|
||||||
|
|
@ -597,7 +597,10 @@ export const run = async () => {
|
||||||
// Create or update theme-preview comment.
|
// Create or update theme-preview comment.
|
||||||
debug("Create or update theme-preview comment...");
|
debug("Create or update theme-preview comment...");
|
||||||
let comment_url;
|
let comment_url;
|
||||||
if (!DRY_RUN) {
|
if (DRY_RUN) {
|
||||||
|
info(`DRY_RUN: Comment body: ${commentBody}`);
|
||||||
|
comment_url = "";
|
||||||
|
} else {
|
||||||
comment_url = await upsertComment(
|
comment_url = await upsertComment(
|
||||||
OCTOKIT,
|
OCTOKIT,
|
||||||
PULL_REQUEST_ID,
|
PULL_REQUEST_ID,
|
||||||
|
|
@ -606,9 +609,6 @@ export const run = async () => {
|
||||||
comment?.id,
|
comment?.id,
|
||||||
commentBody,
|
commentBody,
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
info(`DRY_RUN: Comment body: ${commentBody}`);
|
|
||||||
comment_url = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change review state and add/remove `invalid` label based on theme PR validity.
|
// Change review state and add/remove `invalid` label based on theme PR validity.
|
||||||
|
|
@ -620,7 +620,10 @@ export const run = async () => {
|
||||||
const reviewReason = themesValid
|
const reviewReason = themesValid
|
||||||
? undefined
|
? undefined
|
||||||
: INVALID_REVIEW_COMMENT(comment_url);
|
: 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(
|
await addReview(
|
||||||
OCTOKIT,
|
OCTOKIT,
|
||||||
PULL_REQUEST_ID,
|
PULL_REQUEST_ID,
|
||||||
|
|
@ -637,13 +640,13 @@ export const run = async () => {
|
||||||
"invalid",
|
"invalid",
|
||||||
!themesValid,
|
!themesValid,
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
info(`DRY_RUN: Review state: ${reviewState}`);
|
|
||||||
info(`DRY_RUN: Review reason: ${reviewReason}`);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
debug("Set review state to `REQUEST_CHANGES` and add `invalid` label...");
|
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(
|
await addReview(
|
||||||
OCTOKIT,
|
OCTOKIT,
|
||||||
PULL_REQUEST_ID,
|
PULL_REQUEST_ID,
|
||||||
|
|
@ -662,9 +665,6 @@ export const run = async () => {
|
||||||
"invalid",
|
"invalid",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
info(`DRY_RUN: Review state: REQUEST_CHANGES`);
|
|
||||||
info(`DRY_RUN: Review reason: ${error.message}`);
|
|
||||||
}
|
}
|
||||||
setFailed(error.message);
|
setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ const getStyles = ({
|
||||||
.bold { font-weight: 700 }
|
.bold { font-weight: 700 }
|
||||||
.icon {
|
.icon {
|
||||||
fill: ${iconColor};
|
fill: ${iconColor};
|
||||||
display: ${!!show_icons ? "block" : "none"};
|
display: ${show_icons ? "block" : "none"};
|
||||||
}
|
}
|
||||||
|
|
||||||
.rank-circle-rim {
|
.rank-circle-rim {
|
||||||
|
|
|
||||||
|
|
@ -383,14 +383,14 @@ const renderCompactLayout = (langs, width, totalLanguageSize, hideProgress) => {
|
||||||
|
|
||||||
return `
|
return `
|
||||||
${
|
${
|
||||||
!hideProgress
|
hideProgress
|
||||||
? `
|
? ""
|
||||||
|
: `
|
||||||
<mask id="rect-mask">
|
<mask id="rect-mask">
|
||||||
<rect x="0" y="0" width="${offsetWidth}" height="8" fill="white" rx="5"/>
|
<rect x="0" y="0" width="${offsetWidth}" height="8" fill="white" rx="5"/>
|
||||||
</mask>
|
</mask>
|
||||||
${compactProgressBar}
|
${compactProgressBar}
|
||||||
`
|
`
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
<g transform="translate(0, ${hideProgress ? "0" : "25"})">
|
<g transform="translate(0, ${hideProgress ? "0" : "25"})">
|
||||||
${createLanguageTextNode({
|
${createLanguageTextNode({
|
||||||
|
|
|
||||||
|
|
@ -315,11 +315,11 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
||||||
: noCodingActivityNode({
|
: noCodingActivityNode({
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
color: textColor,
|
color: textColor,
|
||||||
text: !stats.is_coding_activity_visible
|
text: stats.is_coding_activity_visible
|
||||||
? i18n.t("wakatimecard.notpublic")
|
? stats.is_other_usage_visible
|
||||||
: stats.is_other_usage_visible
|
|
||||||
? i18n.t("wakatimecard.nocodingactivity")
|
? 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({
|
noCodingActivityNode({
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
color: textColor,
|
color: textColor,
|
||||||
text: !stats.is_coding_activity_visible
|
text: stats.is_coding_activity_visible
|
||||||
? i18n.t("wakatimecard.notpublic")
|
? stats.is_other_usage_visible
|
||||||
: stats.is_other_usage_visible
|
|
||||||
? i18n.t("wakatimecard.nocodingactivity")
|
? i18n.t("wakatimecard.nocodingactivity")
|
||||||
: i18n.t("wakatimecard.nocodedetails"),
|
: i18n.t("wakatimecard.nocodedetails")
|
||||||
|
: i18n.t("wakatimecard.notpublic"),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
gap: lheight,
|
gap: lheight,
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ class Card {
|
||||||
// returns theme based colors with proper overrides and defaults
|
// returns theme based colors with proper overrides and defaults
|
||||||
this.colors = colors;
|
this.colors = colors;
|
||||||
this.title =
|
this.title =
|
||||||
customTitle !== undefined
|
customTitle === undefined
|
||||||
? encodeHTML(customTitle)
|
? encodeHTML(defaultTitle)
|
||||||
: encodeHTML(defaultTitle);
|
: encodeHTML(customTitle);
|
||||||
|
|
||||||
this.css = "";
|
this.css = "";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ const wrapTextMultiline = (text, width = 59, maxLines = 3) => {
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
// return console instance based on the environment
|
// return console instance based on the environment
|
||||||
const logger =
|
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 ONE_MINUTE = 60;
|
||||||
const FIVE_MINUTES = 300;
|
const FIVE_MINUTES = 300;
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ const GRAPHQL_STATS_QUERY = `
|
||||||
* @returns {Promise<AxiosResponse>} Axios response.
|
* @returns {Promise<AxiosResponse>} Axios response.
|
||||||
*/
|
*/
|
||||||
const fetcher = (variables, token) => {
|
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(
|
return request(
|
||||||
{
|
{
|
||||||
query,
|
query,
|
||||||
|
|
@ -138,10 +138,10 @@ const statsFetcher = async ({
|
||||||
|
|
||||||
// Store stats data.
|
// Store stats data.
|
||||||
const repoNodes = res.data.data.user.repositories.nodes;
|
const repoNodes = res.data.data.user.repositories.nodes;
|
||||||
if (!stats) {
|
if (stats) {
|
||||||
stats = res;
|
|
||||||
} else {
|
|
||||||
stats.data.data.user.repositories.nodes.push(...repoNodes);
|
stats.data.data.user.repositories.nodes.push(...repoNodes);
|
||||||
|
} else {
|
||||||
|
stats = res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable multi page fetching on public Vercel instance due to rate limits.
|
// Disable multi page fetching on public Vercel instance due to rate limits.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue