From 8879c7fe2e393e158b661604dc96d444cf1291d1 Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov Date: Tue, 12 Sep 2023 10:24:07 +0300 Subject: [PATCH] refactor: fix createProgressNode function jsdoc and enable ts-check (#3211) --- src/cards/top-languages-card.js | 6 ++++-- src/cards/wakatime-card.js | 2 +- src/common/createProgressNode.js | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cards/top-languages-card.js b/src/cards/top-languages-card.js index f2fda70..7ff1007 100644 --- a/src/cards/top-languages-card.js +++ b/src/cards/top-languages-card.js @@ -201,7 +201,7 @@ const trimTopLanguages = (topLangs, langs_count, hide) => { * @param {number} props.width The card width * @param {string} props.color Color of the programming language. * @param {string} props.name Name of the programming language. - * @param {string} props.progress Usage of the programming language in percentage. + * @param {number} props.progress Usage of the programming language in percentage. * @param {number} props.index Index of the programming language. * @returns {string} Programming language SVG node. */ @@ -329,7 +329,9 @@ const renderNormalLayout = (langs, width, totalLanguageSize) => { width, name: lang.name, color: lang.color || DEFAULT_LANG_COLOR, - progress: ((lang.size / totalLanguageSize) * 100).toFixed(2), + progress: parseFloat( + ((lang.size / totalLanguageSize) * 100).toFixed(2), + ), index, }); }), diff --git a/src/cards/wakatime-card.js b/src/cards/wakatime-card.js index e3f5433..187af7e 100644 --- a/src/cards/wakatime-card.js +++ b/src/cards/wakatime-card.js @@ -95,7 +95,7 @@ const createLanguageTextNode = ({ langs, y }) => { * @param {string} args.label The label of the text node item. * @param {string} args.value The value of the text node item. * @param {number} args.index The index of the text node item. - * @param {string} args.percent Percentage of the text node item. + * @param {number} args.percent Percentage of the text node item. * @param {boolean=} args.hideProgress Whether to hide the progress bar. * @param {string} args.progressBarColor The color of the progress bar. * @param {string} args.progressBarBackgroundColor The color of the progress bar background. diff --git a/src/common/createProgressNode.js b/src/common/createProgressNode.js index 2825583..2d7303a 100644 --- a/src/common/createProgressNode.js +++ b/src/common/createProgressNode.js @@ -1,3 +1,5 @@ +// @ts-check + import { clampValue } from "./utils.js"; /** @@ -8,7 +10,7 @@ import { clampValue } from "./utils.js"; * @param {number} createProgressNodeParams.y Y-axis position. * @param {number} createProgressNodeParams.width Width of progress bar. * @param {string} createProgressNodeParams.color Progress color. - * @param {string} createProgressNodeParams.progress Progress value. + * @param {number} createProgressNodeParams.progress Progress value. * @param {string} createProgressNodeParams.progressBarBackgroundColor Progress bar bg color. * @param {number} createProgressNodeParams.delay Delay before animation starts. * @returns {string} Progress node.