mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Fix lint warnings
This commit is contained in:
parent
d6782bced8
commit
e68ec31a8f
@ -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 <tspan> 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 <caption>Array of array of strings in typescript syntax</caption>
|
||||
* // returns "Array<Array<string>>"
|
||||
* parseGenericTypes("Array~Array~string~~");
|
||||
* // returns "Array<Array<string>>"
|
||||
* 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) {
|
||||
|
@ -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 = /<br\s*\/?>/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 <br> tags
|
||||
*
|
||||
* @param {string} text Text to split
|
||||
* @returns {Array<string>} 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
|
||||
*/
|
||||
|
@ -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) =>
|
||||
|
@ -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<LogLevel, number>}
|
||||
*/
|
||||
/** @type {object<LogLevel, number>} */
|
||||
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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user