Skip to content

Commit 76033ba

Browse files
committed
update and lint TSDoc comments
1 parent 5dd995e commit 76033ba

File tree

4 files changed

+77
-32
lines changed

4 files changed

+77
-32
lines changed

.eslintrc.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"browser": true
99
},
1010
"parser": "@typescript-eslint/parser",
11-
"plugins": ["@typescript-eslint"],
11+
"plugins": [
12+
"@typescript-eslint",
13+
"eslint-plugin-tsdoc"
14+
],
1215
"rules": {
1316
"no-console": 2,
1417
"curly": 2,
@@ -37,7 +40,8 @@
3740
"no-trailing-spaces": 2,
3841
"space-before-blocks": 2,
3942
"spaced-comment": 1,
40-
"no-var": 2
43+
"no-var": 2,
44+
"tsdoc/syntax": "warn"
4145
},
4246
"overrides": [
4347
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"eslint-plugin-jest": "^27.1.6",
6666
"eslint-plugin-jest-dom": "^4.0.3",
6767
"eslint-plugin-prettier": "^4.2.1",
68+
"eslint-plugin-tsdoc": "^0.2.17",
6869
"jest": "^29.3.1",
6970
"jest-environment-jsdom": "^29.3.1",
7071
"minify": "^9.1.0",

src/scripts/chartist-plugin-tooltip.ts

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export interface Options {
1212
/**
1313
* Transformation function to be applied in combination with "currency".
1414
*
15-
* @param }value The original value.
16-
* @param options Plugin options.
15+
* @param value - The original value.
16+
* @param options - Plugin options.
1717
* @returns Tooltip value for output.
1818
*/
1919
currencyFormatCallback?: (value: string, options: Options) => string;
@@ -46,15 +46,15 @@ export interface Options {
4646
/**
4747
* Custom function to generate tooltip (entire HTML markup).
4848
*
49-
* @param meta Point's meta value.
50-
* @param value Point's value.
49+
* @param meta - Point's meta value.
50+
* @param value - Point's value.
5151
* @returns Tooltip markup.
5252
*/
5353
tooltipFnc?: (meta: string, value: string) => string;
5454
/**
5555
* Custom function to generate tooltip text (content only).
5656
*
57-
* @param value Point's value.
57+
* @param value - Point's value.
5858
* @returns Tooltip text.
5959
*/
6060
transformTooltipTextFnc?: (value: string) => string;
@@ -67,7 +67,7 @@ export interface Options {
6767
/**
6868
* Chartist.js plugin to display a data label on top of the points in a line chart.
6969
*/
70-
export function ChartistPluginTooltip<T extends BaseChart<any>>(
70+
export function ChartistPluginTooltip<T extends BaseChart>(
7171
chart: T,
7272
options?: Partial<Options>
7373
): void {
@@ -126,9 +126,7 @@ export function ChartistPluginTooltip<T extends BaseChart<any>>(
126126
tt.classList.add('chartist-tooltip');
127127
if ($options.class) {
128128
if (Array.isArray($options.class)) {
129-
$options.class.forEach(function (c: string) {
130-
tt?.classList.add(c);
131-
});
129+
$options.class.forEach((c: string): void => tt?.classList.add(c));
132130
} else {
133131
tt.classList.add($options.class);
134132
}
@@ -148,7 +146,7 @@ export function ChartistPluginTooltip<T extends BaseChart<any>>(
148146

149147
hide($toolTip);
150148

151-
$chart.addEventListener('mouseover', function (event: MouseEvent): void {
149+
$chart.addEventListener('mouseover', (event: MouseEvent): void => {
152150
if (!(event.target as HTMLElement).classList.contains(tooltipSelector)) {
153151
return;
154152
}
@@ -234,13 +232,13 @@ export function ChartistPluginTooltip<T extends BaseChart<any>>(
234232
}
235233
});
236234

237-
$chart.addEventListener('mouseout', function (event: MouseEvent) {
235+
$chart.addEventListener('mouseout', (event: MouseEvent): void => {
238236
if ((event.target as HTMLElement).classList.contains(tooltipSelector)) {
239237
$toolTip && hide($toolTip);
240238
}
241239
});
242240

243-
$chart.addEventListener('mousemove', function (event: MouseEvent): void {
241+
$chart.addEventListener('mousemove', (event: MouseEvent): void => {
244242
if (!$options.anchorToPoint && $toolTipIsShown) {
245243
setPosition(event);
246244
}
@@ -294,37 +292,48 @@ export function ChartistPluginTooltip<T extends BaseChart<any>>(
294292
}
295293

296294
/**
297-
* Shows the tooltip element, if not shown
298-
* @param element
295+
* Shows the tooltip element, if not shown.
296+
*
297+
* @param element - The HTML element to show
299298
*/
300-
function show(element: HTMLElement) {
299+
function show(element: HTMLElement): void {
301300
$toolTipIsShown = true;
302301
element.classList.add('tooltip-show');
303302
}
304303

305304
/**
306-
* Hides the tooltip element
307-
* @param element
305+
* Hides the tooltip element.
306+
*
307+
* @param element - The HTML element to hide
308308
*/
309-
function hide(element: HTMLElement) {
309+
function hide(element: HTMLElement): void {
310310
$toolTipIsShown = false;
311311
element.classList.remove('tooltip-show');
312312
}
313313

314-
function next(element: HTMLElement, className: string) {
314+
/**
315+
* Find the next element that has a specific class.
316+
*
317+
* @param element - Base element to start off the search
318+
* @param className - Class name to search for
319+
* @returns Matching HTML element of NULL, if none was found
320+
*/
321+
function next(element: HTMLElement, className: string): HTMLElement | null {
322+
let nextEl: HTMLElement | null = element;
315323
do {
316-
element = element.nextSibling as HTMLElement;
317-
} while (element && !element.classList.contains(className));
324+
nextEl = element.nextSibling as HTMLElement | null;
325+
} while (nextEl && !nextEl.classList.contains(className));
318326

319-
return element;
327+
return nextEl;
320328
}
321329

322330
/**
331+
* Get textual content of an element.
323332
*
324-
* @param element
325-
* @return string
333+
* @param element - HTML element to process
334+
* @returns Text content of the element
326335
*/
327-
function text(element: HTMLElement) {
328-
return element.innerText || element.textContent;
336+
function text(element: HTMLElement): string {
337+
return element.innerText || element.textContent || '';
329338
}
330339
}

yarn.lock

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,21 @@
599599
"@jridgewell/resolve-uri" "3.1.0"
600600
"@jridgewell/sourcemap-codec" "1.4.14"
601601

602+
"@microsoft/tsdoc-config@0.16.2":
603+
version "0.16.2"
604+
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc-config/-/tsdoc-config-0.16.2.tgz#b786bb4ead00d54f53839a458ce626c8548d3adf"
605+
integrity sha512-OGiIzzoBLgWWR0UdRJX98oYO+XKGf7tiK4Zk6tQ/E4IJqGCe7dvkTvgDZV5cFJUzLGDOjeAXrnZoA6QkVySuxw==
606+
dependencies:
607+
"@microsoft/tsdoc" "0.14.2"
608+
ajv "~6.12.6"
609+
jju "~1.4.0"
610+
resolve "~1.19.0"
611+
612+
"@microsoft/tsdoc@0.14.2":
613+
version "0.14.2"
614+
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.14.2.tgz#c3ec604a0b54b9a9b87e9735dfc59e1a5da6a5fb"
615+
integrity sha512-9b8mPpKrfeGRuhFH5iO1iwCLeIIsV6+H1sRfxbkoGXIyQE2BTsPd9zqSqQJ+pv5sJ/hT5M1zvOFL02MnEezFug==
616+
602617
"@nodelib/fs.scandir@2.1.5":
603618
version "2.1.5"
604619
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
@@ -951,7 +966,7 @@ aggregate-error@^4.0.0:
951966
clean-stack "^4.0.0"
952967
indent-string "^5.0.0"
953968

954-
ajv@^6.10.0, ajv@^6.12.4:
969+
ajv@^6.10.0, ajv@^6.12.4, ajv@~6.12.6:
955970
version "6.12.6"
956971
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
957972
integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==
@@ -1720,6 +1735,14 @@ eslint-plugin-prettier@^4.2.1:
17201735
dependencies:
17211736
prettier-linter-helpers "^1.0.0"
17221737

1738+
eslint-plugin-tsdoc@^0.2.17:
1739+
version "0.2.17"
1740+
resolved "https://registry.yarnpkg.com/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.17.tgz#27789495bbd8778abbf92db1707fec2ed3dfe281"
1741+
integrity sha512-xRmVi7Zx44lOBuYqG8vzTXuL6IdGOeF9nHX17bjJ8+VE6fsxpdGem0/SBTmAwgYMKYB1WBkqRJVQ+n8GK041pA==
1742+
dependencies:
1743+
"@microsoft/tsdoc" "0.14.2"
1744+
"@microsoft/tsdoc-config" "0.16.2"
1745+
17231746
eslint-scope@^5.1.1:
17241747
version "5.1.1"
17251748
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
@@ -2363,7 +2386,7 @@ is-callable@^1.1.3:
23632386
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"
23642387
integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==
23652388

2366-
is-core-module@^2.5.0, is-core-module@^2.9.0:
2389+
is-core-module@^2.1.0, is-core-module@^2.5.0, is-core-module@^2.9.0:
23672390
version "2.11.0"
23682391
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144"
23692392
integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==
@@ -2939,7 +2962,7 @@ jest@^29.3.1:
29392962
import-local "^3.0.2"
29402963
jest-cli "^29.3.1"
29412964

2942-
jju@^1.4.0:
2965+
jju@^1.4.0, jju@~1.4.0:
29432966
version "1.4.0"
29442967
resolved "https://registry.yarnpkg.com/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a"
29452968
integrity sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==
@@ -3542,7 +3565,7 @@ path-key@^3.0.0, path-key@^3.1.0:
35423565
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
35433566
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
35443567

3545-
path-parse@^1.0.7:
3568+
path-parse@^1.0.6, path-parse@^1.0.7:
35463569
version "1.0.7"
35473570
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
35483571
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
@@ -3876,6 +3899,14 @@ resolve@^1.10.0, resolve@^1.20.0, resolve@^1.22.1:
38763899
path-parse "^1.0.7"
38773900
supports-preserve-symlinks-flag "^1.0.0"
38783901

3902+
resolve@~1.19.0:
3903+
version "1.19.0"
3904+
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c"
3905+
integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==
3906+
dependencies:
3907+
is-core-module "^2.1.0"
3908+
path-parse "^1.0.6"
3909+
38793910
reusify@^1.0.4:
38803911
version "1.0.4"
38813912
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"

0 commit comments

Comments
 (0)