Update of prettier, eslint and rules

This commit is contained in:
Knut Sveidqvist
2021-07-15 11:35:12 +02:00
parent 896c7eca57
commit 5399214ad8
80 changed files with 1192 additions and 1329 deletions

View File

@@ -13,7 +13,7 @@ import { interpolateToCurve, getStylesFromArray, configureSvgSize } from '../../
import flowChartShapes from './flowChartShapes';
const conf = {};
export const setConf = function(cnf) {
export const setConf = function (cnf) {
const keys = Object.keys(cnf);
for (let i = 0; i < keys.length; i++) {
conf[keys[i]] = cnf[keys[i]];
@@ -25,12 +25,12 @@ export const setConf = function(cnf) {
* @param vert Object containing the vertices.
* @param g The graph that is to be drawn.
*/
export const addVertices = function(vert, g, svgId) {
export const addVertices = function (vert, g, svgId) {
const svg = select(`[id="${svgId}"]`);
const keys = Object.keys(vert);
// Iterate through each item in the vertex object (containing all the vertices found) in the graph definition
keys.forEach(function(id) {
keys.forEach(function (id) {
const vertex = vert[id];
/**
@@ -54,8 +54,8 @@ export const addVertices = function(vert, g, svgId) {
const node = {
label: vertexText.replace(
/fa[lrsb]?:fa-[\w-]+/g,
s => `<i class='${s.replace(':', ' ')}'></i>`
)
(s) => `<i class='${s.replace(':', ' ')}'></i>`
),
};
vertexNode = addHtmlLabel(svg, node).node();
vertexNode.parentNode.removeChild(vertexNode);
@@ -143,7 +143,7 @@ export const addVertices = function(vert, g, svgId) {
ry: radious,
class: classStr,
style: styles.style,
id: flowDb.lookUpDomId(vertex.id)
id: flowDb.lookUpDomId(vertex.id),
});
});
};
@@ -153,7 +153,7 @@ export const addVertices = function(vert, g, svgId) {
* @param {Object} edges The edges to add to the graph
* @param {Object} g The graph object
*/
export const addEdges = function(edges, g) {
export const addEdges = function (edges, g) {
let cnt = 0;
let defaultStyle;
@@ -165,7 +165,7 @@ export const addEdges = function(edges, g) {
defaultLabelStyle = defaultStyles.labelStyle;
}
edges.forEach(function(edge) {
edges.forEach(function (edge) {
cnt++;
// Identify Link
@@ -232,7 +232,7 @@ export const addEdges = function(edges, g) {
edgeData.labelType = 'html';
edgeData.label = `<span id="L-${linkId}" class="edgeLabel L-${linkNameStart}' L-${linkNameEnd}">${edge.text.replace(
/fa[lrsb]?:fa-[\w-]+/g,
s => `<i class='${s.replace(':', ' ')}'></i>`
(s) => `<i class='${s.replace(':', ' ')}'></i>`
)}</span>`;
} else {
edgeData.labelType = 'text';
@@ -259,7 +259,7 @@ export const addEdges = function(edges, g) {
* Returns the all the styles from classDef statements in the graph definition.
* @returns {object} classDef styles
*/
export const getClasses = function(text) {
export const getClasses = function (text) {
log.info('Extracting classes');
flowDb.clear();
try {
@@ -279,7 +279,7 @@ export const getClasses = function(text) {
* @param text
* @param id
*/
export const draw = function(text, id) {
export const draw = function (text, id) {
log.info('Drawing flowchart');
flowDb.clear();
flowDb.setGen('gen-1');
@@ -306,16 +306,16 @@ export const draw = function(text, id) {
// Create the input mermaid.graph
const g = new graphlib.Graph({
multigraph: true,
compound: true
compound: true,
})
.setGraph({
rankdir: dir,
nodesep: nodeSpacing,
ranksep: rankSpacing,
marginx: 8,
marginy: 8
marginy: 8,
})
.setDefaultEdgeLabel(function() {
.setDefaultEdgeLabel(function () {
return {};
});
@@ -406,7 +406,7 @@ export const draw = function(text, id) {
const element = select('#' + id + ' g');
render(element, g);
element.selectAll('g.node').attr('title', function() {
element.selectAll('g.node').attr('title', function () {
return flowDb.getTooltip(this.id);
});
@@ -472,7 +472,7 @@ export const draw = function(text, id) {
// If node has a link, wrap it in an anchor SVG object.
const keys = Object.keys(vert);
keys.forEach(function(key) {
keys.forEach(function (key) {
const vertex = vert[key];
if (vertex.link) {
@@ -486,20 +486,20 @@ export const draw = function(text, id) {
link.setAttributeNS('http://www.w3.org/2000/svg', 'target', vertex.linkTarget);
}
const linkNode = node.insert(function() {
const linkNode = node.insert(function () {
return link;
}, ':first-child');
const shape = node.select('.label-container');
if (shape) {
linkNode.append(function() {
linkNode.append(function () {
return shape.node();
});
}
const label = node.select('.label');
if (label) {
linkNode.append(function() {
linkNode.append(function () {
return label.node();
});
}
@@ -513,5 +513,5 @@ export default {
addVertices,
addEdges,
getClasses,
draw
draw,
};