From e68ec31a8fde83e5d16028a0c5560dd25b5594cb Mon Sep 17 00:00:00 2001 From: Yash-Singh1 Date: Thu, 11 Nov 2021 10:37:50 -0800 Subject: [PATCH] Fix lint warnings --- src/diagrams/class/svgDraw.js | 15 +++++++++++---- src/diagrams/common/common.js | 10 +++++++++- src/diagrams/flowchart/styles.js | 18 +++++++++++++++++- src/logger.js | 12 +++++------- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/diagrams/class/svgDraw.js b/src/diagrams/class/svgDraw.js index 9fbc65465..b174ebeb8 100644 --- a/src/diagrams/class/svgDraw.js +++ b/src/diagrams/class/svgDraw.js @@ -146,7 +146,10 @@ export const drawEdge = function (elem, path, relation, conf) { /** * Renders a class diagram + * * @param {SVGSVGElement} elem The element to draw it into + * @param classDef + * @param conf * @todo Add more information in the JSDOC here */ export const drawClass = function (elem, classDef, conf) { @@ -389,10 +392,11 @@ const buildLegacyDisplay = function (text) { /** * Adds a for a member in a diagram + * * @param {SVGElement} textEl The element to append to * @param {string} txt The member * @param {boolean} isFirst - * @param {{ padding: string; textHeight: string; }} conf The configuration for the member + * @param {{ padding: string; textHeight: string }} conf The configuration for the member */ const addTspan = function (textEl, txt, isFirst, conf) { let member = parseMember(txt); @@ -410,9 +414,11 @@ const addTspan = function (textEl, txt, isFirst, conf) { /** * Makes generics in typescript syntax + * * @example Array of array of strings in typescript syntax - * // returns "Array>" - * parseGenericTypes("Array~Array~string~~"); + * // returns "Array>" + * parseGenericTypes('Array~Array~string~~'); + * * @param {string} text The text to convert * @returns {string} The converted string */ @@ -431,7 +437,8 @@ const parseGenericTypes = function (text) { /** * Gives the styles for a classifier - * @param {"+" | "-" | "#" | "~" | "*" | "$"} classifier The classifier string + * + * @param {'+' | '-' | '#' | '~' | '*' | '$'} classifier The classifier string * @returns {string} Styling for the classifier */ const parseClassifier = function (classifier) { diff --git a/src/diagrams/common/common.js b/src/diagrams/common/common.js index 94769194a..8a5edbc55 100644 --- a/src/diagrams/common/common.js +++ b/src/diagrams/common/common.js @@ -2,6 +2,7 @@ import DOMPurify from 'dompurify'; /** * Gets the number of lines in a string + * * @param {string | undefined} s The string to check the lines for * @returns {number} The number of lines in that string */ @@ -14,6 +15,7 @@ export const getRows = (s) => { /** * Removes script tags from a text + * * @param {string} txt The text to sanitize * @returns {string} The safer text */ @@ -84,6 +86,7 @@ export const lineBreakRegex = //gi; /** * Whether or not a text has any linebreaks + * * @param {string} text The text to test * @returns {boolean} Whether or not the text has breaks */ @@ -93,8 +96,9 @@ export const hasBreaks = (text) => { /** * Splits on
tags + * * @param {string} text Text to split - * @returns {Array} List of lines as strings + * @returns {string[]} List of lines as strings */ export const splitBreaks = (text) => { return text.split(lineBreakRegex); @@ -102,6 +106,7 @@ export const splitBreaks = (text) => { /** * Converts placeholders to linebreaks in HTML + * * @param {string} s HTML with placeholders * @returns {string} HTML with breaks instead of placeholders */ @@ -111,6 +116,7 @@ const placeholderToBreak = (s) => { /** * Opposite of `placeholderToBreak`, converts breaks to placeholders + * * @param {string} s HTML string * @returns {string} String with placeholders */ @@ -120,6 +126,7 @@ const breakToPlaceholder = (s) => { /** * Gets the current URL + * * @param {boolean} useAbsolute Whether to return the absolute URL or not * @returns {string} The current URL */ @@ -141,6 +148,7 @@ const getUrl = (useAbsolute) => { /** * Converts a string/boolean into a boolean + * * @param {string | boolean} val String or boolean to convert * @returns {boolean} The result from the input */ diff --git a/src/diagrams/flowchart/styles.js b/src/diagrams/flowchart/styles.js index 130a1d7bc..abaecb0b4 100644 --- a/src/diagrams/flowchart/styles.js +++ b/src/diagrams/flowchart/styles.js @@ -1,6 +1,22 @@ /** * Returns the styles given options - * @param {{ fontFamily: string; nodeTextColor: string; textColor: string; titleColor: string; mainBkg: string; nodeBorder: string; arrowheadColor: string; lineColor: string; edgeLabelBackground: string; clusterBkg: string; clusterBorder: string; tertiaryColor: string; border2: string; }} options The options for the styles + * + * @param {{ + * fontFamily: string; + * nodeTextColor: string; + * textColor: string; + * titleColor: string; + * mainBkg: string; + * nodeBorder: string; + * arrowheadColor: string; + * lineColor: string; + * edgeLabelBackground: string; + * clusterBkg: string; + * clusterBorder: string; + * tertiaryColor: string; + * border2: string; + * }} options + * The options for the styles * @returns {string} The resulting styles */ const getStyles = (options) => diff --git a/src/logger.js b/src/logger.js index de829de6e..0e44efe75 100644 --- a/src/logger.js +++ b/src/logger.js @@ -1,12 +1,8 @@ import moment from 'moment-mini'; -/** - * @typedef {"debug" | "info" | "warn" | "error" | "fatal"} LogLevel A log level - */ +/** @typedef {'debug' | 'info' | 'warn' | 'error' | 'fatal'} LogLevel A log level */ -/** - * @type {Object} - */ +/** @type {object} */ export const LEVELS = { debug: 1, info: 2, @@ -25,7 +21,8 @@ export const log = { /** * Sets a log level - * @param {LogLevel} [level="fatal"] The level to set the logging to + * + * @param {LogLevel} [level="fatal"] The level to set the logging to. Default is `"fatal"` */ export const setLogLevel = function (level = 'fatal') { if (isNaN(level)) { @@ -69,6 +66,7 @@ export const setLogLevel = function (level = 'fatal') { /** * Returns a format with the timestamp and the log level + * * @param {LogLevel} level The level for the log format * @returns {string} The format with the timestamp and log level */