Skip to content

Commit

Permalink
chore: Fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed May 24, 2024
1 parent e094104 commit dfe223c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 263 deletions.
209 changes: 0 additions & 209 deletions packages/mermaid/src/dagre-wrapper/index-refactored.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const setConf = function (cnf) {
*/
export const addVertices = async function (vert, g, svgId, root, doc, diagObj) {
const svg = root.select(`[id="${svgId}"]`);
console.log('SVG:', svg, svg.node(), 'root:', root, root.node());
// console.log('SVG:', svg, svg.node(), 'root:', root, root.node());

const keys = vert.keys();

Expand Down
50 changes: 23 additions & 27 deletions packages/mermaid/src/diagrams/state/dataFetcher.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
import { getConfig } from '../../diagram-api/diagramAPI.js';
import { log } from '../../logger.js';
import common from '../common/common.js';
import { getConfig } from '../../diagram-api/diagramAPI.js';

import {
DEFAULT_DIAGRAM_DIRECTION,
STMT_STATE,
STMT_RELATION,
STMT_CLASSDEF,
STMT_APPLYCLASS,
CSS_DIAGRAM_CLUSTER,
CSS_DIAGRAM_CLUSTER_ALT,
CSS_DIAGRAM_NOTE,
CSS_DIAGRAM_STATE,
CSS_EDGE,
CSS_EDGE_NOTE_EDGE,
DEFAULT_NESTED_DOC_DIR,
DEFAULT_STATE_TYPE,
DIVIDER_TYPE,
G_EDGE_STYLE,
DOMID_STATE,
DOMID_TYPE_SPACER,
G_EDGE_ARROWHEADSTYLE,
G_EDGE_LABELPOS,
G_EDGE_LABELTYPE,
G_EDGE_STYLE,
G_EDGE_THICKNESS,
CSS_EDGE,
DEFAULT_NESTED_DOC_DIR,
NOTE,
NOTE_ID,
PARENT,
PARENT_ID,
SHAPE_DIVIDER,
SHAPE_GROUP,
CSS_DIAGRAM_CLUSTER,
CSS_DIAGRAM_CLUSTER_ALT,
CSS_DIAGRAM_STATE,
SHAPE_STATE_WITH_DESC,
SHAPE_STATE,
SHAPE_START,
SHAPE_END,
SHAPE_GROUP,
SHAPE_NOTE,
SHAPE_NOTEGROUP,
CSS_DIAGRAM_NOTE,
DOMID_TYPE_SPACER,
DOMID_STATE,
NOTE_ID,
PARENT_ID,
NOTE,
PARENT,
CSS_EDGE_NOTE_EDGE,
SHAPE_START,
SHAPE_STATE,
SHAPE_STATE_WITH_DESC,
STMT_RELATION,
STMT_STATE,
} from './stateCommon.js';

// List of nodes created from the parsed diagram statement items
Expand Down Expand Up @@ -241,7 +237,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
}

const newNode = nodeDb[itemId];
console.log('New Node:', newNode);
// console.log('New Node:', newNode);

// Save data for description and group so that for instance a statement without description overwrites
// one with description @todo TODO What does this mean? If important, add a test for it
Expand Down Expand Up @@ -387,7 +383,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
insertOrUpdateNode(nodes, nodeData);
}

console.log('Nodes:', nodes);
// console.log('Nodes:', nodes);
}
if (parsedItem.doc) {
log.trace('Adding nodes children ');
Expand Down
12 changes: 6 additions & 6 deletions packages/mermaid/src/diagrams/state/stateRenderer-v3-unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { CSS_DIAGRAM, DEFAULT_NESTED_DOC_DIR } from './stateCommon.js';
* Get the direction from the statement items.
* Look through all of the documents (docs) in the parsedItems
* Because is a _document_ direction, the default direction is not necessarily the same as the overall default _diagram_ direction.
* @param {object[]} parsedItem - the parsed statement item to look through
* @param [defaultDir] - the direction to use if none is found
* @returns {string}
* @param parsedItem - the parsed statement item to look through
* @param defaultDir - the direction to use if none is found
* @returns The direction to use
*/
const getDir = (parsedItem: any, defaultDir = DEFAULT_NESTED_DOC_DIR) => {
let dir = defaultDir;
Expand Down Expand Up @@ -69,13 +69,13 @@ export const draw = async function (text: string, id: string, _version: string,
data4Layout.direction = DIR;

// TODO: Should we move these two to baseConfig? These types are not there in StateConfig.
// @ts-expect-error
// @ts-expect-error TODO: Will be fixed after config refactor
data4Layout.nodeSpacing = conf?.nodeSpacing || 50;
// @ts-expect-error
// @ts-expect-error TODO: Will be fixed after config refactor
data4Layout.rankSpacing = conf?.rankSpacing || 50;
data4Layout.markers = ['barb'];
data4Layout.diagramId = id;
console.log('REF1:', data4Layout);
// console.log('REF1:', data4Layout);
await render(data4Layout, svg, element);
const padding = 8;
utils.insertTitle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export const adjustClustersAndEdges = (graph, depth) => {
clusterDb[e.w]
);
if (clusterDb[e.v] && clusterDb[e.w] && clusterDb[e.v] === clusterDb[e.w]) {
// cspell:ignore trixing
log.warn('Fixing and trixing link to self - removing XXX', e.v, e.w, e.name);
log.warn('Fixing and trixing - removing XXX', e.v, e.w, e.name);
v = getAnchorId(e.v);
Expand Down
20 changes: 0 additions & 20 deletions packages/mermaid/src/rendering-util/rendering-elements/edges.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,26 +375,6 @@ const cutPathAtIntersect = (_points, boundaryNode) => {
return points;
};

const calcOffset = function (src, dest, parentLookupDb) {
const ancestor = findCommonAncestor(src, dest, parentLookupDb);
if (ancestor === undefined || ancestor === 'root') {
return { x: 0, y: 0 };
}

const ancestorOffset = nodeDb[ancestor].offset;
return { x: ancestorOffset.posX, y: ancestorOffset.posY };
};

// Function to insert a midpoint
/**
*
* @param p1
* @param p2
*/
function insertMidpoint(p1, p2) {
return [(p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2];
}

/**
* Given an edge, this function will return the corner points of the edge. This is defined as:
* one point that has a previous point and a next point such as the angle between the previous
Expand Down

0 comments on commit dfe223c

Please sign in to comment.