mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-19 16:38:23 +00:00
refactor: enable curly eslint rule (#3137)
This commit is contained in:
parent
b611018476
commit
c42798b39e
14 changed files with 71 additions and 24 deletions
|
|
@ -39,7 +39,7 @@
|
|||
}],
|
||||
"block-scoped-var": "warn",
|
||||
"consistent-return": "error",
|
||||
// "curly": "error",
|
||||
"curly": "error",
|
||||
// "default-case": "warn",
|
||||
|
||||
// the dot goes with the property when doing multiline
|
||||
|
|
|
|||
|
|
@ -60,9 +60,12 @@ const generateLinks = (fn) => {
|
|||
};
|
||||
|
||||
const createTableItem = ({ link, label, isRepoCard }) => {
|
||||
if (!link || !label) return "";
|
||||
if (!link || !label) {
|
||||
return "";
|
||||
}
|
||||
return `\`${label}\` ![${link}][${link}${isRepoCard ? "_repo" : ""}]`;
|
||||
};
|
||||
|
||||
const generateTable = ({ isRepoCard }) => {
|
||||
const rows = [];
|
||||
const themesFiltered = Object.keys(themes).filter(
|
||||
|
|
|
|||
|
|
@ -75,7 +75,9 @@ class IncorrectJsonFormatError extends Error {
|
|||
* @returns {number} PR number.
|
||||
*/
|
||||
const getPrNumber = () => {
|
||||
if (process.env.MOCK_PR_NUMBER) return process.env.MOCK_PR_NUMBER; // For testing purposes.
|
||||
if (process.env.MOCK_PR_NUMBER) {
|
||||
return process.env.MOCK_PR_NUMBER; // For testing purposes.
|
||||
}
|
||||
|
||||
const pullRequest = github.context.payload.pull_request;
|
||||
if (!pullRequest) {
|
||||
|
|
|
|||
|
|
@ -358,7 +358,9 @@ const renderStatsCard = (stats, options = {}) => {
|
|||
card.setHideTitle(hide_title);
|
||||
card.setCSS(cssStyles);
|
||||
|
||||
if (disable_animations) card.disableAnimations();
|
||||
if (disable_animations) {
|
||||
card.disableAnimations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the right rank circle translation values such that the rank circle
|
||||
|
|
|
|||
|
|
@ -87,7 +87,9 @@ const polarToCartesian = (centerX, centerY, radius, angleInDegrees) => {
|
|||
const cartesianToPolar = (centerX, centerY, x, y) => {
|
||||
const radius = Math.sqrt(Math.pow(x - centerX, 2) + Math.pow(y - centerY, 2));
|
||||
let angleInDegrees = radiansToDegrees(Math.atan2(y - centerY, x - centerX));
|
||||
if (angleInDegrees < 0) angleInDegrees += 360;
|
||||
if (angleInDegrees < 0) {
|
||||
angleInDegrees += 360;
|
||||
}
|
||||
return { radius, angleInDegrees };
|
||||
};
|
||||
|
||||
|
|
@ -808,7 +810,9 @@ const renderTopLanguages = (topLangs, options = {}) => {
|
|||
colors,
|
||||
});
|
||||
|
||||
if (disable_animations) card.disableAnimations();
|
||||
if (disable_animations) {
|
||||
card.disableAnimations();
|
||||
}
|
||||
|
||||
card.setHideBorder(hide_border);
|
||||
card.setHideTitle(hide_title);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,9 @@ class Card {
|
|||
* @returns {string} The rendered card gradient.
|
||||
*/
|
||||
renderGradient() {
|
||||
if (typeof this.colors.bgColor !== "object") return "";
|
||||
if (typeof this.colors.bgColor !== "object") {
|
||||
return "";
|
||||
}
|
||||
|
||||
const gradients = this.colors.bgColor.slice(1);
|
||||
return typeof this.colors.bgColor === "object"
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@ const createLanguageNode = (langName, langColor) => {
|
|||
* @returns {string} Icon with label SVG object.
|
||||
*/
|
||||
const iconWithLabel = (icon, label, testid, iconSize) => {
|
||||
if (typeof label === "number" && label <= 0) return "";
|
||||
if (typeof label === "number" && label <= 0) {
|
||||
return "";
|
||||
}
|
||||
const iconSvg = `
|
||||
<svg
|
||||
class="icon"
|
||||
|
|
@ -124,7 +126,9 @@ const isValidHexColor = (hexColor) => {
|
|||
* @returns {boolean | undefined } The parsed value.
|
||||
*/
|
||||
const parseBoolean = (value) => {
|
||||
if (typeof value === "boolean") return value;
|
||||
if (typeof value === "boolean") {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (typeof value === "string") {
|
||||
if (value.toLowerCase() === "true") {
|
||||
|
|
@ -143,7 +147,9 @@ const parseBoolean = (value) => {
|
|||
* @returns {string[]} The array of strings.
|
||||
*/
|
||||
const parseArray = (str) => {
|
||||
if (!str) return [];
|
||||
if (!str) {
|
||||
return [];
|
||||
}
|
||||
return str.split(",");
|
||||
};
|
||||
|
||||
|
|
@ -157,7 +163,9 @@ const parseArray = (str) => {
|
|||
*/
|
||||
const clampValue = (number, min, max) => {
|
||||
// @ts-ignore
|
||||
if (Number.isNaN(parseInt(number))) return min;
|
||||
if (Number.isNaN(parseInt(number))) {
|
||||
return min;
|
||||
}
|
||||
return Math.max(min, Math.min(number, max));
|
||||
};
|
||||
|
||||
|
|
@ -501,7 +509,9 @@ const chunkArray = (arr, perChunk) => {
|
|||
* @returns {string} String with emoji parsed.
|
||||
*/
|
||||
const parseEmojis = (str) => {
|
||||
if (!str) throw new Error("[parseEmoji]: str argument not provided");
|
||||
if (!str) {
|
||||
throw new Error("[parseEmoji]: str argument not provided");
|
||||
}
|
||||
return str.replace(/:\w+:/gm, (emoji) => {
|
||||
return toEmoji.get(emoji) || "";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -57,10 +57,16 @@ const fetcher = async (variables, token) => {
|
|||
* @returns {Promise<GistData>} Gist data.
|
||||
*/
|
||||
const fetchGist = async (id) => {
|
||||
if (!id) throw new MissingParamError(["id"], "/api/gist?id=GIST_ID");
|
||||
if (!id) {
|
||||
throw new MissingParamError(["id"], "/api/gist?id=GIST_ID");
|
||||
}
|
||||
const res = await retryer(fetcher, { gistName: id });
|
||||
if (res.data.errors) throw new Error(res.data.errors[0].message);
|
||||
if (!res.data.data.viewer.gist) throw new Error("Gist not found");
|
||||
if (res.data.errors) {
|
||||
throw new Error(res.data.errors[0].message);
|
||||
}
|
||||
if (!res.data.data.viewer.gist) {
|
||||
throw new Error("Gist not found");
|
||||
}
|
||||
const data = res.data.data.viewer.gist;
|
||||
return {
|
||||
name: data.files[Object.keys(data.files)[0]].name,
|
||||
|
|
|
|||
|
|
@ -73,8 +73,12 @@ const fetchRepo = async (username, reponame) => {
|
|||
if (!username && !reponame) {
|
||||
throw new MissingParamError(["username", "repo"], urlExample);
|
||||
}
|
||||
if (!username) throw new MissingParamError(["username"], urlExample);
|
||||
if (!reponame) throw new MissingParamError(["repo"], urlExample);
|
||||
if (!username) {
|
||||
throw new MissingParamError(["username"], urlExample);
|
||||
}
|
||||
if (!reponame) {
|
||||
throw new MissingParamError(["repo"], urlExample);
|
||||
}
|
||||
|
||||
let res = await retryer(fetcher, { login: username, repo: reponame });
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,9 @@ const statsFetcher = async (username) => {
|
|||
while (hasNextPage) {
|
||||
const variables = { login: username, first: 100, after: endCursor };
|
||||
let res = await retryer(fetcher, variables);
|
||||
if (res.data.errors) return res;
|
||||
if (res.data.errors) {
|
||||
return res;
|
||||
}
|
||||
|
||||
// Store stats data.
|
||||
const repoNodes = res.data.data.user.repositories.nodes;
|
||||
|
|
@ -199,7 +201,9 @@ const fetchStats = async (
|
|||
include_all_commits = false,
|
||||
exclude_repo = [],
|
||||
) => {
|
||||
if (!username) throw new MissingParamError(["username"]);
|
||||
if (!username) {
|
||||
throw new MissingParamError(["username"]);
|
||||
}
|
||||
|
||||
const stats = {
|
||||
name: "",
|
||||
|
|
|
|||
|
|
@ -71,7 +71,9 @@ const fetchTopLanguages = async (
|
|||
size_weight = 1,
|
||||
count_weight = 0,
|
||||
) => {
|
||||
if (!username) throw new MissingParamError(["username"]);
|
||||
if (!username) {
|
||||
throw new MissingParamError(["username"]);
|
||||
}
|
||||
|
||||
const res = await retryer(fetcher, { login: username });
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import { CustomError, MissingParamError } from "../common/utils.js";
|
|||
* @returns {Promise<WakaTimeData>} WakaTime data response.
|
||||
*/
|
||||
const fetchWakatimeStats = async ({ username, api_domain }) => {
|
||||
if (!username) throw new MissingParamError(["username"]);
|
||||
if (!username) {
|
||||
throw new MissingParamError(["username"]);
|
||||
}
|
||||
|
||||
try {
|
||||
const { data } = await axios.get(
|
||||
|
|
|
|||
|
|
@ -10,8 +10,12 @@ const calculateCircleProgress = (value) => {
|
|||
const radius = 40;
|
||||
const c = Math.PI * (radius * 2);
|
||||
|
||||
if (value < 0) value = 0;
|
||||
if (value > 100) value = 100;
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
if (value > 100) {
|
||||
value = 100;
|
||||
}
|
||||
|
||||
return ((100 - value) / 100) * c;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -70,7 +70,9 @@ const langPercentFromDonutLayoutSvg = (d, centerX, centerY) => {
|
|||
cartesianToPolar(centerX, centerY, dTmp[0], dTmp[1]).angleInDegrees + 90;
|
||||
let startAngle =
|
||||
cartesianToPolar(centerX, centerY, dTmp[7], dTmp[8]).angleInDegrees + 90;
|
||||
if (startAngle > endAngle) startAngle -= 360;
|
||||
if (startAngle > endAngle) {
|
||||
startAngle -= 360;
|
||||
}
|
||||
return (endAngle - startAngle) / 3.6;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue