chore: Fix eslint issues

This commit is contained in:
Sidharth Vinod
2024-06-30 01:19:11 +05:30
parent d9b2934a50
commit 1fad9e6eef
23 changed files with 73 additions and 56 deletions

View File

@@ -16,7 +16,7 @@
#### Defined in #### Defined in
[packages/mermaid/src/utils.ts:789](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L789) [packages/mermaid/src/utils.ts:785](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L785)
--- ---
@@ -26,7 +26,7 @@
#### Defined in #### Defined in
[packages/mermaid/src/utils.ts:787](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L787) [packages/mermaid/src/utils.ts:783](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L783)
--- ---
@@ -36,7 +36,7 @@
#### Defined in #### Defined in
[packages/mermaid/src/utils.ts:790](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L790) [packages/mermaid/src/utils.ts:786](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L786)
--- ---
@@ -46,4 +46,4 @@
#### Defined in #### Defined in
[packages/mermaid/src/utils.ts:785](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L785) [packages/mermaid/src/utils.ts:781](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/utils.ts#L781)

View File

@@ -44,7 +44,7 @@
#### Defined in #### Defined in
[packages/mermaid/src/Diagram.ts:9](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/Diagram.ts#L9) [packages/mermaid/src/Diagram.ts:10](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/Diagram.ts#L10)
## Variables ## Variables

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import type { Mocked } from 'vitest'; import type { Mocked } from 'vitest';
import type { SVG } from '../diagram-api/types.js'; import type { SVG } from '../diagram-api/types.js';
import { addEdgeMarkers } from './edgeMarker.js'; import { addEdgeMarkers } from './edgeMarker.js';

View File

@@ -26,12 +26,16 @@ const Identification = {
NON_IDENTIFYING: 'NON_IDENTIFYING', NON_IDENTIFYING: 'NON_IDENTIFYING',
IDENTIFYING: 'IDENTIFYING', IDENTIFYING: 'IDENTIFYING',
}; };
/**
* Add entity
* @param {string} name - The name of the entity
* @param {string | undefined} alias - The alias of the entity
*/
const addEntity = function (name, alias = undefined) { const addEntity = function (name, alias = undefined) {
if (!entities.has(name)) { if (!entities.has(name)) {
entities.set(name, { attributes: [], alias: alias }); entities.set(name, { attributes: [], alias });
log.info('Added new entity :', name); log.info('Added new entity :', name);
} else if (entities.has(name) && !entities.get(name).alias && alias) { } else if (!entities.get(name).alias && alias) {
entities.get(name).alias = alias; entities.get(name).alias = alias;
log.info(`Add alias '${alias}' to entity '${name}'`); log.info(`Add alias '${alias}' to entity '${name}'`);
} }

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import { addToRender } from './flowChartShapes.js'; import { addToRender } from './flowChartShapes.js';
describe('flowchart shapes', function () { describe('flowchart shapes', function () {

View File

@@ -420,14 +420,13 @@ export const draw = async function (text, id, _version, diagObj) {
log.info('Edges', edges); log.info('Edges', edges);
let i = 0; let i = 0;
for (i = subGraphs.length - 1; i >= 0; i--) { for (i = subGraphs.length - 1; i >= 0; i--) {
// for (let i = 0; i < subGraphs.length; i++) {
subG = subGraphs[i]; subG = subGraphs[i];
selectAll('cluster').append('text'); selectAll('cluster').append('text');
for (let j = 0; j < subG.nodes.length; j++) { for (const node of subG.nodes) {
log.info('Setting up subgraphs', subG.nodes[j], subG.id); log.info('Setting up subgraphs', node, subG.id);
g.setParent(subG.nodes[j], subG.id); g.setParent(node, subG.id);
} }
} }
await addVertices(vert, g, id, root, doc, diagObj); await addVertices(vert, g, id, root, doc, diagObj);

View File

@@ -339,14 +339,14 @@ export const draw = async function (text, id, _version, diagObj) {
selectAll('cluster').append('text'); selectAll('cluster').append('text');
for (let j = 0; j < subG.nodes.length; j++) { for (const node of subG.nodes) {
log.warn( log.warn(
'Setting subgraph', 'Setting subgraph',
subG.nodes[j], node,
diagObj.db.lookUpDomId(subG.nodes[j]), diagObj.db.lookUpDomId(node),
diagObj.db.lookUpDomId(subG.id) diagObj.db.lookUpDomId(subG.id)
); );
g.setParent(diagObj.db.lookUpDomId(subG.nodes[j]), diagObj.db.lookUpDomId(subG.id)); g.setParent(diagObj.db.lookUpDomId(node), diagObj.db.lookUpDomId(subG.id));
} }
} }
await addVertices(vert, g, id, root, doc, diagObj); await addVertices(vert, g, id, root, doc, diagObj);
@@ -429,8 +429,8 @@ export const draw = async function (text, id, _version, diagObj) {
te.attr('transform', `translate(${xPos + _width / 2}, ${yPos + 14})`); te.attr('transform', `translate(${xPos + _width / 2}, ${yPos + 14})`);
te.attr('id', id + 'Text'); te.attr('id', id + 'Text');
for (let j = 0; j < subG.classes.length; j++) { for (const className of subG.classes) {
clusterEl[0].classList.add(subG.classes[j]); clusterEl[0].classList.add(className);
} }
} }
} }

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import { addVertices, addEdges } from './flowRenderer.js'; import { addVertices, addEdges } from './flowRenderer.js';
import { setConfig } from '../../diagram-api/diagramAPI.js'; import { setConfig } from '../../diagram-api/diagramAPI.js';

View File

@@ -119,6 +119,7 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
return ((datum.data.value / sum) * 100).toFixed(0) + '%'; return ((datum.data.value / sum) * 100).toFixed(0) + '%';
}) })
.attr('transform', (datum: d3.PieArcDatum<D3Section>): string => { .attr('transform', (datum: d3.PieArcDatum<D3Section>): string => {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
return 'translate(' + labelArcGenerator.centroid(datum) + ')'; return 'translate(' + labelArcGenerator.centroid(datum) + ')';
}) })
.style('text-anchor', 'middle') .style('text-anchor', 'middle')

View File

@@ -1519,7 +1519,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
diagram.renderer.bounds.init(); diagram.renderer.bounds.init();
conf = diagram.db.getConfig(); conf = diagram.db.getConfig();
}); });
it('should handle a simple bound call', async () => { it('should handle a simple bound call', () => {
diagram.renderer.bounds.insert(100, 100, 200, 200); diagram.renderer.bounds.insert(100, 100, 200, 200);
const { bounds } = diagram.renderer.bounds.getBounds(); const { bounds } = diagram.renderer.bounds.getBounds();
@@ -1528,7 +1528,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(200); expect(bounds.stopx).toBe(200);
expect(bounds.stopy).toBe(200); expect(bounds.stopy).toBe(200);
}); });
it('should handle an expanding bound', async () => { it('should handle an expanding bound', () => {
diagram.renderer.bounds.insert(100, 100, 200, 200); diagram.renderer.bounds.insert(100, 100, 200, 200);
diagram.renderer.bounds.insert(25, 50, 300, 400); diagram.renderer.bounds.insert(25, 50, 300, 400);
@@ -1538,7 +1538,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(300); expect(bounds.stopx).toBe(300);
expect(bounds.stopy).toBe(400); expect(bounds.stopy).toBe(400);
}); });
it('should handle inserts within the bound without changing the outer bounds', async () => { it('should handle inserts within the bound without changing the outer bounds', () => {
diagram.renderer.bounds.insert(100, 100, 200, 200); diagram.renderer.bounds.insert(100, 100, 200, 200);
diagram.renderer.bounds.insert(25, 50, 300, 400); diagram.renderer.bounds.insert(25, 50, 300, 400);
diagram.renderer.bounds.insert(125, 150, 150, 200); diagram.renderer.bounds.insert(125, 150, 150, 200);
@@ -1549,7 +1549,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(300); expect(bounds.stopx).toBe(300);
expect(bounds.stopy).toBe(400); expect(bounds.stopy).toBe(400);
}); });
it('should handle a loop without expanding the area', async () => { it('should handle a loop without expanding the area', () => {
diagram.renderer.bounds.insert(25, 50, 300, 400); diagram.renderer.bounds.insert(25, 50, 300, 400);
diagram.renderer.bounds.verticalPos = 150; diagram.renderer.bounds.verticalPos = 150;
diagram.renderer.bounds.newLoop(); diagram.renderer.bounds.newLoop();
@@ -1570,7 +1570,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(300); expect(bounds.stopx).toBe(300);
expect(bounds.stopy).toBe(400); expect(bounds.stopy).toBe(400);
}); });
it('should handle multiple loops withtout expanding the bounds', async () => { it('should handle multiple loops withtout expanding the bounds', () => {
diagram.renderer.bounds.insert(100, 100, 1000, 1000); diagram.renderer.bounds.insert(100, 100, 1000, 1000);
diagram.renderer.bounds.verticalPos = 200; diagram.renderer.bounds.verticalPos = 200;
diagram.renderer.bounds.newLoop(); diagram.renderer.bounds.newLoop();
@@ -1601,7 +1601,7 @@ describe('when checking the bounds in a sequenceDiagram', function () {
expect(bounds.stopx).toBe(1000); expect(bounds.stopx).toBe(1000);
expect(bounds.stopy).toBe(1000); expect(bounds.stopy).toBe(1000);
}); });
it('should handle a loop that expands the area', async () => { it('should handle a loop that expands the area', () => {
diagram.renderer.bounds.insert(100, 100, 200, 200); diagram.renderer.bounds.insert(100, 100, 200, 200);
diagram.renderer.bounds.verticalPos = 200; diagram.renderer.bounds.verticalPos = 200;
diagram.renderer.bounds.newLoop(); diagram.renderer.bounds.newLoop();

View File

@@ -495,7 +495,7 @@ const drawMessage = async function (diagram, msgModel, lineStartY: number, diagO
} }
}; };
const addActorRenderingData = async function ( const addActorRenderingData = function (
diagram, diagram,
actors, actors,
createdActors: Map<string, any>, createdActors: Map<string, any>,
@@ -822,7 +822,7 @@ export const draw = async function (_text: string, id: string, _version: string,
actorKeys = actorKeys.filter((actorKey) => newActors.has(actorKey)); actorKeys = actorKeys.filter((actorKey) => newActors.has(actorKey));
} }
await addActorRenderingData(diagram, actors, createdActors, actorKeys, 0, messages, false); addActorRenderingData(diagram, actors, createdActors, actorKeys, 0, messages, false);
const loopWidths = await calculateLoopBounds(messages, actors, maxMessageWidthPerActor, diagObj); const loopWidths = await calculateLoopBounds(messages, actors, maxMessageWidthPerActor, diagObj);
// The arrow head definition is attached to the svg once // The arrow head definition is attached to the svg once
@@ -1076,7 +1076,7 @@ export const draw = async function (_text: string, id: string, _version: string,
box.stopx = box.startx + box.width; box.stopx = box.startx + box.width;
box.stopy = box.starty + box.height; box.stopy = box.starty + box.height;
box.stroke = 'rgb(0,0,0, 0.5)'; box.stroke = 'rgb(0,0,0, 0.5)';
await svgDraw.drawBox(diagram, box, conf); svgDraw.drawBox(diagram, box, conf);
} }
if (hasBoxes) { if (hasBoxes) {
@@ -1147,7 +1147,7 @@ async function getMaxMessageWidthPerActor(
actors: Map<string, any>, actors: Map<string, any>,
messages: any[], messages: any[],
diagObj: Diagram diagObj: Diagram
): Promise<{ [id: string]: number }> { ): Promise<Record<string, number>> {
const maxMessageWidthPerActor = {}; const maxMessageWidthPerActor = {};
for (const msg of messages) { for (const msg of messages) {
@@ -1581,7 +1581,7 @@ const calculateLoopBounds = async function (messages, actors, _maxWidthPerActor,
const lastActorActivationIdx = bounds.activations const lastActorActivationIdx = bounds.activations
.map((a) => a.actor) .map((a) => a.actor)
.lastIndexOf(msg.from); .lastIndexOf(msg.from);
delete bounds.activations.splice(lastActorActivationIdx, 1)[0]; bounds.activations.splice(lastActorActivationIdx, 1).splice(0, 1);
} }
break; break;
} }

View File

@@ -115,6 +115,7 @@ export const drawKatex = async function (elem, textData, msgModel = null) {
stopx = temp; stopx = temp;
} }
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
textElem.attr('x', Math.round(startx + Math.abs(startx - stopx) / 2 - dim.width / 2)); textElem.attr('x', Math.round(startx + Math.abs(startx - stopx) / 2 - dim.width / 2));
if (textData.class === 'loopText') { if (textData.class === 'loopText') {
textElem.attr('y', Math.round(starty)); textElem.attr('y', Math.round(starty));
@@ -325,7 +326,7 @@ export const fixLifeLineHeights = (diagram, actors, actorKeys, conf) => {
* @param {any} conf - DrawText implementation discriminator object * @param {any} conf - DrawText implementation discriminator object
* @param {boolean} isFooter - If the actor is the footer one * @param {boolean} isFooter - If the actor is the footer one
*/ */
const drawActorTypeParticipant = async function (elem, actor, conf, isFooter) { const drawActorTypeParticipant = function (elem, actor, conf, isFooter) {
const actorY = isFooter ? actor.stopy : actor.starty; const actorY = isFooter ? actor.stopy : actor.starty;
const center = actor.x + actor.width / 2; const center = actor.x + actor.width / 2;
const centerY = actorY + 5; const centerY = actorY + 5;
@@ -389,7 +390,7 @@ const drawActorTypeParticipant = async function (elem, actor, conf, isFooter) {
} }
} }
await _drawTextCandidateFunc(conf, hasKatex(actor.description))( _drawTextCandidateFunc(conf, hasKatex(actor.description))(
actor.description, actor.description,
g, g,
rect.x, rect.x,
@@ -410,7 +411,7 @@ const drawActorTypeParticipant = async function (elem, actor, conf, isFooter) {
return height; return height;
}; };
const drawActorTypeActor = async function (elem, actor, conf, isFooter) { const drawActorTypeActor = function (elem, actor, conf, isFooter) {
const actorY = isFooter ? actor.stopy : actor.starty; const actorY = isFooter ? actor.stopy : actor.starty;
const center = actor.x + actor.width / 2; const center = actor.x + actor.width / 2;
const centerY = actorY + 80; const centerY = actorY + 80;
@@ -491,7 +492,7 @@ const drawActorTypeActor = async function (elem, actor, conf, isFooter) {
const bounds = actElem.node().getBBox(); const bounds = actElem.node().getBBox();
actor.height = bounds.height; actor.height = bounds.height;
await _drawTextCandidateFunc(conf, hasKatex(actor.description))( _drawTextCandidateFunc(conf, hasKatex(actor.description))(
actor.description, actor.description,
actElem, actElem,
rect.x, rect.x,
@@ -514,12 +515,12 @@ export const drawActor = async function (elem, actor, conf, isFooter) {
} }
}; };
export const drawBox = async function (elem, box, conf) { export const drawBox = function (elem, box, conf) {
const boxplusTextGroup = elem.append('g'); const boxplusTextGroup = elem.append('g');
const g = boxplusTextGroup; const g = boxplusTextGroup;
drawBackgroundRect(g, box); drawBackgroundRect(g, box);
if (box.name) { if (box.name) {
await _drawTextCandidateFunc(conf)( _drawTextCandidateFunc(conf)(
box.name, box.name,
g, g,
box.x, box.x,

View File

@@ -362,8 +362,7 @@ const setupDoc = (g, parentParsedItem, doc, diagramStates, diagramDb, altFlag) =
const getDir = (parsedItem, defaultDir = DEFAULT_NESTED_DOC_DIR) => { const getDir = (parsedItem, defaultDir = DEFAULT_NESTED_DOC_DIR) => {
let dir = defaultDir; let dir = defaultDir;
if (parsedItem.doc) { if (parsedItem.doc) {
for (let i = 0; i < parsedItem.doc.length; i++) { for (const parsedItemDoc of parsedItem.doc) {
const parsedItemDoc = parsedItem.doc[i];
if (parsedItemDoc.stmt === 'dir') { if (parsedItemDoc.stmt === 'dir') {
dir = parsedItemDoc.value; dir = parsedItemDoc.value;
} }

View File

@@ -115,8 +115,7 @@ export const draw = function (text: string, id: string, version: string, diagObj
maxEventCount = Math.max(maxEventCount, task.events.length); maxEventCount = Math.max(maxEventCount, task.events.length);
//calculate maxEventLineLength //calculate maxEventLineLength
let maxEventLineLengthTemp = 0; let maxEventLineLengthTemp = 0;
for (let j = 0; j < task.events.length; j++) { for (const event of task.events) {
const event = task.events[j];
const eventNode = { const eventNode = {
descr: event, descr: event,
section: task.section, section: task.section,

View File

@@ -9,9 +9,9 @@ const allMarkdownTransformers: MarkdownOptions = {
light: 'github-light', light: 'github-light',
dark: 'github-dark', dark: 'github-dark',
}, },
// eslint-disable-next-line @typescript-eslint/no-misused-promises
config: async (md) => { config: (md) => {
await MermaidExample(md); MermaidExample(md);
}, },
}; };

View File

@@ -1,6 +1,6 @@
import type { MarkdownRenderer } from 'vitepress'; import type { MarkdownRenderer } from 'vitepress';
const MermaidExample = async (md: MarkdownRenderer) => { const MermaidExample = (md: MarkdownRenderer) => {
const defaultRenderer = md.renderer.rules.fence; const defaultRenderer = md.renderer.rules.fence;
if (!defaultRenderer) { if (!defaultRenderer) {

View File

@@ -35,7 +35,7 @@ export default {
const url = new URL(window.location.origin + to); const url = new URL(window.location.origin + to);
const newPath = getRedirect(url); const newPath = getRedirect(url);
if (newPath) { if (newPath) {
console.log(`Redirecting to ${newPath} from ${window.location}`); console.log(`Redirecting to ${newPath} from ${window.location.toString()}`);
// router.go isn't loading the ID properly. // router.go isn't loading the ID properly.
window.location.href = `/${newPath}`; window.location.href = `/${newPath}`;
} }

View File

@@ -49,12 +49,12 @@ export default defineConfig({
// TODO: will be fixed in the next vitepress release. // TODO: will be fixed in the next vitepress release.
name: 'fix-virtual', name: 'fix-virtual',
async resolveId(id: string) { resolveId(id: string) {
if (id === virtualModuleId) { if (id === virtualModuleId) {
return resolvedVirtualModuleId; return resolvedVirtualModuleId;
} }
}, },
async load(this, id: string) { load(this, id: string) {
if (id === resolvedVirtualModuleId) { if (id === resolvedVirtualModuleId) {
return `export default ${JSON.stringify({ return `export default ${JSON.stringify({
securityLevel: 'loose', securityLevel: 'loose',

View File

@@ -29,12 +29,11 @@ export const log: Record<keyof typeof LEVELS, typeof console.log> = {
* *
* @param level - The level to set the logging to. Default is `"fatal"` * @param level - The level to set the logging to. Default is `"fatal"`
*/ */
export const setLogLevel = function (level: keyof typeof LEVELS | number | string = 'fatal') { export const setLogLevel = function (level: keyof typeof LEVELS | number = 'fatal') {
let numericLevel: number = LEVELS.fatal; let numericLevel: number = LEVELS.fatal;
if (typeof level === 'string') { if (typeof level === 'string') {
level = level.toLowerCase(); if (level.toLowerCase() in LEVELS) {
if (level in LEVELS) { numericLevel = LEVELS[level];
numericLevel = LEVELS[level as keyof typeof LEVELS];
} }
} else if (typeof level === 'number') { } else if (typeof level === 'number') {
numericLevel = level; numericLevel = level;

View File

@@ -31,7 +31,7 @@ import packet from './diagrams/packet/styles.js';
import block from './diagrams/block/styles.js'; import block from './diagrams/block/styles.js';
import themes from './themes/index.js'; import themes from './themes/index.js';
async function checkValidStylisCSSStyleSheet(stylisString: string) { function checkValidStylisCSSStyleSheet(stylisString: string) {
const cssString = serialize(compile(`#my-svg-id{${stylisString}}`), stringify); const cssString = serialize(compile(`#my-svg-id{${stylisString}}`), stringify);
const errors = validate(cssString, 'this-file-was-created-by-tests.css') as Error[]; const errors = validate(cssString, 'this-file-was-created-by-tests.css') as Error[];
@@ -51,6 +51,7 @@ async function checkValidStylisCSSStyleSheet(stylisString: string) {
if (unexpectedErrors.length > 0) { if (unexpectedErrors.length > 0) {
throw new Error( throw new Error(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`The given CSS string was invalid: ${errors}.\n\n` + `The given CSS string was invalid: ${errors}.\n\n` +
'Copy the below CSS into https://jigsaw.w3.org/css-validator/validator to help debug where the invalid CSS is:\n\n' + 'Copy the below CSS into https://jigsaw.w3.org/css-validator/validator to help debug where the invalid CSS is:\n\n' +
`Original CSS value was ${cssString}` `Original CSS value was ${cssString}`
@@ -75,7 +76,7 @@ describe('styles', () => {
const styles = getStyles(diagramType, '', getConfig().themeVariables); const styles = getStyles(diagramType, '', getConfig().themeVariables);
await checkValidStylisCSSStyleSheet(styles); checkValidStylisCSSStyleSheet(styles);
}); });
/** /**
@@ -110,7 +111,7 @@ describe('styles', () => {
themes[themeId].getThemeVariables() themes[themeId].getThemeVariables()
); );
await checkValidStylisCSSStyleSheet(styles); checkValidStylisCSSStyleSheet(styles);
}); });
} }
} }

View File

@@ -60,7 +60,7 @@ export class MockedD3 {
if (beforeSelector === undefined) { if (beforeSelector === undefined) {
this._children.push(newMock); this._children.push(newMock);
} else { } else {
const idOnly = beforeSelector[0] == '#' ? beforeSelector.substring(1) : beforeSelector; const idOnly = beforeSelector.startsWith('#') ? beforeSelector.substring(1) : beforeSelector;
const foundIndex = this._children.findIndex((child) => child.id === idOnly); const foundIndex = this._children.findIndex((child) => child.id === idOnly);
if (foundIndex < 0) { if (foundIndex < 0) {
this._children.push(newMock); this._children.push(newMock);

View File

@@ -45,7 +45,12 @@ export const getLineFunctionsWithOffset = (
edge: Pick<EdgeData, 'arrowTypeStart' | 'arrowTypeEnd'> edge: Pick<EdgeData, 'arrowTypeStart' | 'arrowTypeEnd'>
) => { ) => {
return { return {
x: function (d: Point | [number, number], i: number, data: (Point | [number, number])[]) { x: function (
this: void,
d: Point | [number, number],
i: number,
data: (Point | [number, number])[]
) {
let offset = 0; let offset = 0;
if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) { if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) {
// Handle first point // Handle first point
@@ -70,7 +75,12 @@ export const getLineFunctionsWithOffset = (
} }
return pointTransformer(d).x + offset; return pointTransformer(d).x + offset;
}, },
y: function (d: Point | [number, number], i: number, data: (Point | [number, number])[]) { y: function (
this: void,
d: Point | [number, number],
i: number,
data: (Point | [number, number])[]
) {
// Same handling as X above // Same handling as X above
let offset = 0; let offset = 0;
if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) { if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) {

View File

@@ -20,6 +20,7 @@ export abstract class AbstractMermaidTokenBuilder extends DefaultTokenBuilder {
// to restrict users, they mustn't have any non-whitespace characters after the keyword. // to restrict users, they mustn't have any non-whitespace characters after the keyword.
tokenTypes.forEach((tokenType: TokenType): void => { tokenTypes.forEach((tokenType: TokenType): void => {
if (this.keywords.has(tokenType.name) && tokenType.PATTERN !== undefined) { if (this.keywords.has(tokenType.name) && tokenType.PATTERN !== undefined) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
tokenType.PATTERN = new RegExp(tokenType.PATTERN.toString() + '(?:(?=%%)|(?!\\S))'); tokenType.PATTERN = new RegExp(tokenType.PATTERN.toString() + '(?:(?=%%)|(?!\\S))');
} }
}); });