Skip to content

Commit

Permalink
Fix: shapes.ts linter
Browse files Browse the repository at this point in the history
  • Loading branch information
teyc committed Dec 20, 2024
1 parent 3e5edca commit 586d2a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/mermaid/src/diagrams/usecase/usecaseDB.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { BaseDiagramConfig, MermaidConfig } from '../../config.type.js';
import { getConfig } from '../../diagram-api/diagramAPI.js';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { log } from '../../logger.js';
import type { LayoutData } from '../../mermaid.js';
import type { Edge, Node } from '../../rendering-util/types.js';
import common from '../common/common.js';
Expand Down
15 changes: 9 additions & 6 deletions packages/mermaid/src/rendering-util/rendering-elements/shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,22 @@ export interface ShapeDefinition {
/**
* Aliases can include descriptive names, other short names, etc.
*/
aliases?: string[];
readonly aliases?: string[];
/**
* These are names used by mermaid before the introduction of new shapes. These will not be in standard formats, and shouldn't be used by the users
*/
internalAliases?: string[];
readonly internalAliases?: string[];
handler: ShapeHandler;
}

export const shapesDefs: ShapeDefinition[] = [
export const shapesDefs = [
{
semanticName: 'Actor',
name: 'Actor',
shortName: 'actor',
description: 'Actor used in Use Cases',
handler: actor,
aliases: ['stickman'],
},
{
semanticName: 'Process',
Expand Down Expand Up @@ -457,7 +458,7 @@ export const shapesDefs: ShapeDefinition[] = [
aliases: ['lined-document'],
handler: linedWaveEdgedRect,
},
] as const satisfies ShapeDefinition[];
] as const;

const generateShapeMap = () => {
// These are the shapes that didn't have documentation present
Expand Down Expand Up @@ -486,13 +487,15 @@ const generateShapeMap = () => {
classBox,
} as const;

const emptyArray = [] as const;

const entries = [
...(Object.entries(undocumentedShapes) as Entries<typeof undocumentedShapes>),
...shapesDefs.flatMap((shape) => {
const aliases = [
shape.shortName,
...('aliases' in shape ? (shape.aliases ?? []) : []),
...('internalAliases' in shape ? (shape.internalAliases ?? []) : []),
...('aliases' in shape ? (shape.aliases ?? emptyArray) : emptyArray),
...('internalAliases' in shape ? (shape.internalAliases ?? emptyArray) : emptyArray),
];
return aliases.map((alias) => [alias, shape.handler] as const);
}),
Expand Down

0 comments on commit 586d2a6

Please sign in to comment.