diff --git a/scripts/preview-theme.js b/scripts/preview-theme.js
index e4422ecd0350a9..688d31690d9eb2 100644
--- a/scripts/preview-theme.js
+++ b/scripts/preview-theme.js
@@ -11,16 +11,16 @@ const OWNER = "anuraghazra";
const REPO = "github-readme-stats";
const COMMENT_TITLE = "Automated Theme Preview";
-function getPrNumber() {
+const getPrNumber = () => {
const pullRequest = github.context.payload.pull_request;
if (!pullRequest) {
return undefined;
}
return pullRequest.number;
-}
+};
-function findCommentPredicate(inputs, comment) {
+const findCommentPredicate = (inputs, comment) => {
return (
(inputs.commentAuthor && comment.user
? comment.user.login === inputs.commentAuthor
@@ -29,9 +29,9 @@ function findCommentPredicate(inputs, comment) {
? comment.body.includes(inputs.bodyIncludes)
: true)
);
-}
+};
-async function findComment(octokit, issueNumber) {
+const findComment = async (octokit, issueNumber) => {
const parameters = {
owner: OWNER,
repo: REPO,
@@ -52,28 +52,28 @@ async function findComment(octokit, issueNumber) {
);
if (comment) return comment;
}
-}
+};
-async function upsertComment(octokit, props) {
+const upsertComment = async (octokit, props) => {
if (props.comment_id !== undefined) {
await octokit.issues.updateComment(props);
} else {
await octokit.issues.createComment(props);
}
-}
+};
-function getWebAimLink(color1, color2) {
+const getWebAimLink = (color1, color2) => {
return `https://webaim.org/resources/contrastchecker/?fcolor=${color1}&bcolor=${color2}`;
-}
+};
-function getGrsLink(colors) {
+const getGrsLink = (colors) => {
const url = `https://github-readme-stats.vercel.app/api?username=anuraghazra`;
const colorString = Object.keys(colors)
.map((colorKey) => `${colorKey}=${colors[colorKey]}`)
.join("&");
return `${url}&${colorString}&show_icons=true`;
-}
+};
const themeContribGuidelines = `
\rHi, thanks for the theme contribution, please read our theme [contribution guidelines](https://github.com/anuraghazra/github-readme-stats/blob/master/CONTRIBUTING.md#themes-contribution).
@@ -82,7 +82,7 @@ const themeContribGuidelines = `
\r> Also note that if this theme is exclusively for your personal use, then instead of adding it to our theme collection you can use card [customization options](https://github.com/anuraghazra/github-readme-stats#customization)
`;
-async function run() {
+const run = async () => {
try {
const ccc = new ColorContrastChecker();
const warnings = [];
@@ -183,6 +183,6 @@ async function run() {
} catch (error) {
console.log(error);
}
-}
+};
run();
diff --git a/src/calculateRank.js b/src/calculateRank.js
index 742b9ab17509da..60fd02786acb6c 100644
--- a/src/calculateRank.js
+++ b/src/calculateRank.js
@@ -1,5 +1,5 @@
// https://stackoverflow.com/a/5263759/10629172
-function normalcdf(mean, sigma, to) {
+const normalcdf = (mean, sigma, to) => {
var z = (to - mean) / Math.sqrt(2 * sigma * sigma);
var t = 1 / (1 + 0.3275911 * Math.abs(z));
var a1 = 0.254829592;
@@ -14,9 +14,9 @@ function normalcdf(mean, sigma, to) {
sign = -1;
}
return (1 / 2) * (1 + sign * erf);
-}
+};
-function calculateRank({
+const calculateRank = ({
totalRepos,
totalCommits,
contributions,
@@ -24,7 +24,7 @@ function calculateRank({
prs,
issues,
stargazers,
-}) {
+}) => {
const COMMITS_OFFSET = 1.65;
const CONTRIBS_OFFSET = 1.65;
const ISSUES_OFFSET = 1;
@@ -72,6 +72,6 @@ function calculateRank({
})();
return { level, score: normalizedScore };
-}
+};
module.exports = calculateRank;
diff --git a/src/cards/top-languages-card.js b/src/cards/top-languages-card.js
index b2f5c362dd47fb..8ada66b58c0c9b 100644
--- a/src/cards/top-languages-card.js
+++ b/src/cards/top-languages-card.js
@@ -236,7 +236,7 @@ const useLanguages = (topLangs, hide, langs_count) => {
const renderTopLanguages = (topLangs, options = {}) => {
const {
hide_title,
- hide_border,
+ hide_border = false,
card_width,
title_color,
text_color,
diff --git a/src/common/utils.js b/src/common/utils.js
index 2ad18dddbc62aa..c798eba108459e 100644
--- a/src/common/utils.js
+++ b/src/common/utils.js
@@ -4,7 +4,7 @@ const wrap = require("word-wrap");
const themes = require("../../themes");
const toEmoji = require("emoji-name-map");
-/**
+/** Renders error message on the card.
* @param {string} message
* @param {string} secondaryMessage
* @returns {string}
@@ -32,38 +32,38 @@ const renderError = (message, secondaryMessage = "") => {
* @param {string} str
* @returns {string}
*/
-function encodeHTML(str) {
+const encodeHTML = (str) => {
return str
.replace(/[\u00A0-\u9999<>&](?!#)/gim, (i) => {
return "" + i.charCodeAt(0) + ";";
})
.replace(/\u0008/gim, "");
-}
+};
/**
* @param {number} num
*/
-function kFormatter(num) {
+const kFormatter = (num) => {
return Math.abs(num) > 999
? Math.sign(num) * parseFloat((Math.abs(num) / 1000).toFixed(1)) + "k"
: Math.sign(num) * Math.abs(num);
-}
+};
/**
* @param {string} hexColor
* @returns {boolean}
*/
-function isValidHexColor(hexColor) {
+const isValidHexColor = (hexColor) => {
return new RegExp(
/^([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{4})$/,
).test(hexColor);
-}
+};
/**
* @param {string} value
* @returns {boolean | string}
*/
-function parseBoolean(value) {
+const parseBoolean = (value) => {
if (value === "true") {
return true;
} else if (value === "false") {
@@ -71,40 +71,40 @@ function parseBoolean(value) {
} else {
return value;
}
-}
+};
/**
* @param {string} str
*/
-function parseArray(str) {
+const parseArray = (str) => {
if (!str) return [];
return str.split(",");
-}
+};
/**
* @param {number} number
* @param {number} min
* @param {number} max
*/
-function clampValue(number, min, max) {
+const clampValue = (number, min, max) => {
// @ts-ignore
if (Number.isNaN(parseInt(number))) return min;
return Math.max(min, Math.min(number, max));
-}
+};
/**
* @param {string[]} colors
*/
-function isValidGradient(colors) {
+const isValidGradient = (colors) => {
return isValidHexColor(colors[1]) && isValidHexColor(colors[2]);
-}
+};
/**
* @param {string} color
* @param {string} fallbackColor
* @returns {string | string[]}
*/
-function fallbackColor(color, fallbackColor) {
+const fallbackColor = (color, fallbackColor) => {
let colors = color.split(",");
let gradient = null;
@@ -116,13 +116,13 @@ function fallbackColor(color, fallbackColor) {
(gradient ? gradient : isValidHexColor(color) && `#${color}`) ||
fallbackColor
);
-}
+};
/**
* @param {import('axios').AxiosRequestConfig['data']} data
* @param {import('axios').AxiosRequestConfig['headers']} headers
*/
-function request(data, headers) {
+const request = (data, headers) => {
// @ts-ignore
return axios({
url: "https://api.github.com/graphql",
@@ -130,7 +130,7 @@ function request(data, headers) {
headers,
data,
});
-}
+};
/**
* @param {object} props
@@ -145,7 +145,7 @@ function request(data, headers) {
* Auto layout utility, allows us to layout things
* vertically or horizontally with proper gaping
*/
-function flexLayout({ items, gap, direction, sizes = [] }) {
+const flexLayout = ({ items, gap, direction, sizes = [] }) => {
let lastSize = 0;
// filter() for filtering out empty strings
return items.filter(Boolean).map((item, i) => {
@@ -157,7 +157,7 @@ function flexLayout({ items, gap, direction, sizes = [] }) {
lastSize += size + gap;
return `${item}`;
});
-}
+};
/**
* @typedef {object} CardColors
@@ -173,7 +173,7 @@ function flexLayout({ items, gap, direction, sizes = [] }) {
* returns theme based colors with proper overrides and defaults
* @param {CardColors} options
*/
-function getCardColors({
+const getCardColors = ({
title_color,
text_color,
icon_color,
@@ -181,7 +181,7 @@ function getCardColors({
border_color,
theme,
fallbackTheme = "default",
-}) {
+}) => {
const defaultTheme = themes[fallbackTheme];
const selectedTheme = themes[theme] || defaultTheme;
const defaultBorderColor =
@@ -212,7 +212,7 @@ function getCardColors({
);
return { titleColor, iconColor, textColor, bgColor, borderColor };
-}
+};
/**
* @param {string} text
@@ -220,7 +220,7 @@ function getCardColors({
* @param {number} maxLines
* @returns {string[]}
*/
-function wrapTextMultiline(text, width = 59, maxLines = 3) {
+const wrapTextMultiline = (text, width = 59, maxLines = 3) => {
const fullWidthComma = ",";
const encoded = encodeHTML(text);
const isChinese = encoded.includes(fullWidthComma);
@@ -245,7 +245,7 @@ function wrapTextMultiline(text, width = 59, maxLines = 3) {
// Remove empty lines if text fits in less than maxLines lines
const multiLineText = lines.filter(Boolean);
return multiLineText;
-}
+};
const noop = () => {};
// return console instance based on the environment
@@ -301,7 +301,7 @@ class MissingParamError extends Error {
* @param {number} fontSize
* @returns
*/
-function measureText(str, fontSize = 10) {
+const measureText = (str, fontSize = 10) => {
// prettier-ignore
const widths = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -333,7 +333,7 @@ function measureText(str, fontSize = 10) {
)
.reduce((cur, acc) => acc + cur) * fontSize
);
-}
+};
/** @param {string} name */
const lowercaseTrim = (name) => name.toLowerCase().trim();
@@ -344,7 +344,7 @@ const lowercaseTrim = (name) => name.toLowerCase().trim();
* @param {number} perChunk
* @returns {Array}
*/
-function chunkArray(arr, perChunk) {
+const chunkArray = (arr, perChunk) => {
return arr.reduce((resultArray, item, index) => {
const chunkIndex = Math.floor(index / perChunk);
@@ -356,19 +356,19 @@ function chunkArray(arr, perChunk) {
return resultArray;
}, []);
-}
+};
/**
*
* @param {string} str
* @returns {string}
*/
-function parseEmojis(str) {
+const parseEmojis = (str) => {
if (!str) throw new Error("[parseEmoji]: str argument not provided");
return str.replace(/:\w+:/gm, (emoji) => {
return toEmoji.get(emoji) || "";
});
-}
+};
module.exports = {
renderError,
diff --git a/src/fetchers/repo-fetcher.js b/src/fetchers/repo-fetcher.js
index 0bad5f2bd08fdf..c215f374112d7e 100644
--- a/src/fetchers/repo-fetcher.js
+++ b/src/fetchers/repo-fetcher.js
@@ -55,7 +55,7 @@ const urlExample = "/api/pin?username=USERNAME&repo=REPO_NAME";
* @param {string} reponame
* @returns {Promise}
*/
-async function fetchRepo(username, reponame) {
+const fetchRepo = async (username, reponame) => {
if (!username && !reponame) {
throw new MissingParamError(["username", "repo"], urlExample);
}
@@ -95,6 +95,6 @@ async function fetchRepo(username, reponame) {
starCount: data.organization.repository.stargazers.totalCount,
};
}
-}
+};
module.exports = fetchRepo;
diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js
index dc9be5bb4f89c4..b2754a32ea2f88 100644
--- a/src/fetchers/stats-fetcher.js
+++ b/src/fetchers/stats-fetcher.js
@@ -105,12 +105,12 @@ const totalCommitsFetcher = async (username) => {
* @param {boolean} include_all_commits
* @returns {Promise}
*/
-async function fetchStats(
+const fetchStats = async (
username,
count_private = false,
include_all_commits = false,
exclude_repo = [],
-) {
+) => {
if (!username) throw new MissingParamError(["username"]);
const stats = {
@@ -185,6 +185,6 @@ async function fetchStats(
});
return stats;
-}
+};
module.exports = fetchStats;
diff --git a/src/fetchers/top-languages-fetcher.js b/src/fetchers/top-languages-fetcher.js
index 7c4c8785c87f90..f826072cdbdec9 100644
--- a/src/fetchers/top-languages-fetcher.js
+++ b/src/fetchers/top-languages-fetcher.js
@@ -44,7 +44,7 @@ const fetcher = (variables, token) => {
* @param {string[]} exclude_repo
* @returns {Promise}
*/
-async function fetchTopLanguages(username, exclude_repo = []) {
+const fetchTopLanguages = async (username, exclude_repo = []) => {
if (!username) throw new MissingParamError(["username"]);
const res = await retryer(fetcher, { login: username });
@@ -102,6 +102,6 @@ async function fetchTopLanguages(username, exclude_repo = []) {
}, {});
return topLangs;
-}
+};
module.exports = fetchTopLanguages;
diff --git a/src/translations.js b/src/translations.js
index 31b2d218d5486b..302cdb35422b22 100644
--- a/src/translations.js
+++ b/src/translations.js
@@ -354,9 +354,9 @@ const wakatimeCardLocales = {
const availableLocales = Object.keys(repoCardLocales["repocard.archived"]);
-function isLocaleAvailable(locale) {
+const isLocaleAvailable = (locale) => {
return availableLocales.includes(locale.toLowerCase());
-}
+};
module.exports = {
isLocaleAvailable,