fix: resolve vscode errors inside cards svg generation code (#4558)

Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
This commit is contained in:
Ophelia Goldstein
2025-10-11 22:40:33 +03:00
committed by GitHub
co-authored by Alexandr
parent 701068b8bc
commit 33f0c9153e
6 changed files with 25 additions and 13 deletions
+1
View File
@@ -96,6 +96,7 @@ const renderGistCard = (gistData, options = {}) => {
);
const languageName = language || "Unspecified";
// @ts-ignore
const languageColor = languageColors[languageName] || "#858585";
const svgLanguage = createLanguageNode(languageName, languageColor);
+1
View File
@@ -1,4 +1,5 @@
// @ts-check
import { Card } from "../common/Card.js";
import { getCardColors } from "../common/color.js";
import { I18n } from "../common/I18n.js";
+16 -11
View File
@@ -392,21 +392,24 @@ const renderStatsCard = (stats, options = {}) => {
// filter out hidden stats defined by user & create the text nodes
const statItems = Object.keys(STATS)
.filter((key) => !hide.includes(key))
.map((key, index) =>
.map((key, index) => {
// @ts-ignore
const stats = STATS[key];
// create the text nodes, and pass index so that we can calculate the line spacing
createTextNode({
icon: STATS[key].icon,
label: STATS[key].label,
value: STATS[key].value,
id: STATS[key].id,
unitSymbol: STATS[key].unitSymbol,
return createTextNode({
icon: stats.icon,
label: stats.label,
value: stats.value,
id: stats.id,
unitSymbol: stats.unitSymbol,
index,
showIcons: show_icons,
shiftValuePos: 79.01 + (isLongLocale ? 50 : 0),
bold: text_bold,
number_format,
}),
);
});
});
if (statItems.length === 0 && hide_rank) {
throw new CustomError(
@@ -541,14 +544,16 @@ const renderStatsCard = (stats, options = {}) => {
const labels = Object.keys(STATS)
.filter((key) => !hide.includes(key))
.map((key) => {
// @ts-ignore
const stats = STATS[key];
if (key === "commits") {
return `${i18n.t("statcard.commits")} ${getTotalCommitsYearLabel(
include_all_commits,
commits_year,
i18n,
)} : ${STATS[key].value}`;
)} : ${stats.value}`;
}
return `${STATS[key].label}: ${STATS[key].value}`;
return `${stats.label}: ${stats.value}`;
})
.join(", ");
+3
View File
@@ -1,4 +1,5 @@
// @ts-check
import { Card } from "../common/Card.js";
import { getCardColors } from "../common/color.js";
import { createProgressNode } from "../common/createProgressNode.js";
@@ -180,6 +181,7 @@ const trimTopLanguages = (topLangs, langs_count, hide) => {
// while filtering out
if (hide) {
hide.forEach((langName) => {
// @ts-ignore
langsToHide[lowercaseTrim(langName)] = true;
});
}
@@ -188,6 +190,7 @@ const trimTopLanguages = (topLangs, langs_count, hide) => {
langs = langs
.sort((a, b) => b.size - a.size)
.filter((lang) => {
// @ts-ignore
return !langsToHide[lowercaseTrim(lang.name)];
})
.slice(0, langsCount);
+2
View File
@@ -65,6 +65,7 @@ const formatLanguageValue = ({ display_format, lang }) => {
* @returns {string} The compact layout language SVG node.
*/
const createCompactLangNode = ({ lang, x, y, display_format }) => {
// @ts-ignore
const color = languageColors[lang.name] || "#858585";
const value = formatLanguageValue({ display_format, lang });
@@ -325,6 +326,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
// const progress = (width * lang.percent) / 100;
const progress = ((width - 25) * language.percent) / 100;
// @ts-ignore
const languageColor = languageColors[language.name] || "#858585";
const output = `
+2 -2
View File
@@ -68,8 +68,8 @@ const fallbackColor = (color, fallbackColor) => {
* @param {string=} args.bg_color Card background color.
* @param {string=} args.border_color Card border color.
* @param {string=} args.ring_color Card ring color.
* @param {keyof themes=} args.theme Card theme.
* @param {keyof themes=} args.fallbackTheme Fallback theme.
* @param {string=} args.theme Card theme.
* @param {string=} args.fallbackTheme Fallback theme.
* @returns {CardColors} Card colors.
*/
const getCardColors = ({