Skip to content

Rules ​

The rules of @mmd-toolkit/eslint-plugin, an ESLint language plugin for Mermaid diagram text built on @mmd-toolkit/parser, with one document for each rule.

The recommended configuration enables the rules marked ✅ in the list below: their reports are nearly always mistakes to fix.

Rule ids ​

A rule id starts with @mmd-toolkit, the namespace of the plugin. A common rule, one for every diagram type, has the id @mmd-toolkit/<name>; a rule of a diagram type has the id @mmd-toolkit/<diagram>-<name>. The rules of flowchart apply to flowchart-v2, flowchart-elk, and swimlane.

✅ The recommended configuration enables the rule.

🔧 Automatically fixable by the --fix CLI option.

💡 Manually fixable by editor suggestions.

Common rules ​

RuleDescription✅🔧💡
no-duplicate-init-keyDisallow a key written twice in one object of the JSON of an init directive.✅💡
no-invalid-init-directiveDisallow a directive meant to configure the diagram that is not written validly, so that mermaid.js ignores it.✅🔧
no-unclosed-directiveDisallow a directive without its closing }%% that takes the lines after it.✅

flowchart ​

RuleDescription✅🔧💡
flowchart-no-duplicate-descriptionDisallow an accDescr statement that sets the description again.✅💡
flowchart-no-duplicate-directionDisallow a direction statement that replaces the direction of its subgraph.✅💡
flowchart-no-duplicate-titleDisallow an accTitle statement that sets the title again.✅💡
flowchart-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
flowchart-no-ignored-textDisallow text on a direction line that mermaid.js drops.✅
flowchart-no-redefined-subgraphDisallow a subgraph declaration whose title differs from the title kept for its id.✅
flowchart-no-redefined-vertexDisallow writing a vertex again, differently or in a subgraph that does not get it.✅
flowchart-no-spaced-strokeDisallow whitespace before the : of a stroke style.🔧
flowchart-no-unclosed-description-blockDisallow an accDescr { block without its closing }.💡
flowchart-no-undefDisallow a style, class, or click statement that names an id that the diagram does not define.✅

sequence ​

RuleDescription✅🔧💡
sequence-no-create-destroyDisallow create before destroy.✅
sequence-no-duplicate-descriptionDisallow an accDescr statement that sets the description again.✅💡
sequence-no-duplicate-titleDisallow a title or accTitle statement that sets its title again.✅💡
sequence-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
sequence-no-ignored-textDisallow a line that mermaid.js reads as nothing.✅🔧
sequence-no-invalid-jsonDisallow a links or properties statement whose text is not a JSON object.✅🔧
sequence-no-link-without-separatorDisallow a link statement without the @ between its label and its URL.✅🔧
sequence-no-unclosed-description-blockDisallow an accDescr { block without its closing }.💡

class ​

RuleDescription✅🔧💡
class-no-bare-class-nameDisallow a class name alone on its line, which changes nothing.✅
class-no-duplicate-descriptionDisallow an accDescr statement that sets the description again.✅
class-no-duplicate-titleDisallow an accTitle statement that sets the title again.✅
class-no-ignored-textDisallow text that mermaid.js drops.✅
class-no-inline-commentDisallow a comment after other text on its line.🔧
class-no-redefined-classDisallow writing the label of a class again, differently.✅
class-no-unclosed-backquoteDisallow a backquoted class name without its closing backquote.✅
class-no-undefDisallow a statement that refers to a class that the diagram does not define.✅

state ​

RuleDescription✅🔧💡
state-no-duplicate-descriptionDisallow an accDescr statement that sets the description again.✅💡
state-no-duplicate-titleDisallow an accTitle statement that sets the title again.✅💡
state-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
state-no-ignored-textDisallow text that mermaid.js drops.✅🔧
state-no-unclosed-description-blockDisallow an accDescr { block without its closing }.💡
state-no-undefDisallow a style, class, click, or note statement that names no state.✅

er ​

RuleDescription✅🔧💡
er-no-duplicate-descriptionDisallow an accDescr statement that sets the description again.✅💡
er-no-duplicate-titleDisallow an accTitle statement that sets the title again.✅💡
er-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
er-no-ignored-textDisallow text that mermaid.js drops.
er-no-redefined-entityDisallow an entity statement that gives an entity a second alias.✅
er-no-unclosed-description-blockDisallow an accDescr { block that a } written for something else closes.
er-no-undefDisallow a style or class statement that names no entity and no subgraph.✅

journey ​

RuleDescription✅🔧💡
journey-no-duplicate-descriptionDisallow an accDescr statement that sets the description again.✅💡
journey-no-duplicate-titleDisallow a title or accTitle statement that sets its title again.✅💡
journey-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
journey-no-empty-personDisallow a person of a task that has no name.✅💡
journey-no-ignored-textDisallow text in the data of a task that mermaid.js drops.✅💡
journey-no-invalid-scoreDisallow a task score that is not a number from 1 to 5.✅💡

gantt ​

RuleDescription✅🔧💡
gantt-no-duplicate-descriptionDisallow an accDescr statement that sets the description again.✅💡
gantt-no-duplicate-idDisallow a task id that an earlier task already has.✅
gantt-no-duplicate-settingDisallow a setting statement that sets its setting again.✅💡
gantt-no-duplicate-titleDisallow a title or accTitle statement that sets its title again.✅💡
gantt-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
gantt-no-invalid-tagDisallow a tag in the data of a task that mermaid.js does not read as a tag.✅🔧
gantt-no-undefDisallow a task id in click, after, or until that is the id of no task.✅
gantt-no-unknown-excludeDisallow a word in excludes that is neither weekends nor the name of a day.✅🔧

pie ​

RuleDescription✅🔧💡
pie-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
pie-no-duplicate-labelDisallow a section whose label an earlier section has, with another value.✅
pie-no-duplicate-titleDisallow a title or an accTitle that replaces the title set before it.✅💡
pie-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡

quadrant ​

RuleDescription✅🔧💡
quadrant-no-duplicate-descriptionDisallow a statement that sets the description of the chart again.✅💡
quadrant-no-duplicate-styleDisallow a style that a point or a class gives again.✅💡
quadrant-no-duplicate-titleDisallow a title or accTitle statement that sets its title again.✅💡
quadrant-no-empty-description-blockDisallow a description block that holds no description.✅💡
quadrant-no-invalid-colorDisallow a hexadecimal colour without # in the style of a point or a class.✅🔧
quadrant-no-invalid-coordinateDisallow a coordinate of a point that is not a number from 0 to 1.✅🔧
quadrant-no-redefined-axisDisallow an axis statement that replaces a text of the axis.✅
quadrant-no-redefined-classDisallow a classDef statement that replaces the styles of its class.✅💡
quadrant-no-redefined-quadrantDisallow a quadrant statement that replaces the text of its quadrant.✅💡
quadrant-no-undefDisallow a class of a point that no classDef defines.✅

requirement ​

RuleDescription✅🔧💡
requirement-no-duplicate-descriptionDisallow an accDescr statement that sets the description again.✅💡
requirement-no-duplicate-fieldDisallow a field that the body of a requirement or an element already has.✅💡
requirement-no-duplicate-nameDisallow a requirement or an element that reuses the name of an earlier one.✅
requirement-no-duplicate-titleDisallow an accTitle statement that sets the title again.✅💡
requirement-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
requirement-no-ignored-textDisallow text that mermaid.js drops.✅
requirement-no-unclosed-description-blockDisallow an accDescr { block that a } written for something else closes.
requirement-no-undefDisallow a name in style, class, :::, or a relationship that names no requirement and no element.✅

usecase ​

RuleDescription✅🔧💡
usecase-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
usecase-no-duplicate-directionDisallow a direction statement that replaces the direction set before it.✅💡
usecase-no-duplicate-metadataDisallow a metadata value that replaces the value of the same key set before it.✅💡
usecase-no-duplicate-titleDisallow an accTitle that replaces the title set before it.✅💡
usecase-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
usecase-no-redefined-classDisallow a classDef that drops or changes the styles of the class defined before it.✅💡
usecase-no-unclosed-description-blockDisallow an accDescr { block that a } written for a later statement closes.

gitgraph ​

RuleDescription✅🔧💡
gitgraph-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
gitgraph-no-duplicate-optionDisallow an option that replaces the value of the same option before it in one statement.✅💡
gitgraph-no-duplicate-titleDisallow a title or an accTitle that replaces the title set before it.✅💡
gitgraph-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
gitgraph-no-redefined-commitDisallow a commit with the id of a commit or a merge written before it.✅

c4 ​

RuleDescription✅🔧💡
c4-no-duplicate-descriptionDisallow a description statement that replaces a different diagram description.✅
c4-no-duplicate-styleDisallow a style update that replaces a value that an earlier update gave.✅
c4-no-duplicate-titleDisallow a title statement that replaces a different title set by another title statement.✅
c4-no-invalid-attribute-keyDisallow incorrect casing of the color and offset keys in C4 style updates.✅
c4-no-redefined-elementDisallow a declaration of an element or a boundary that replaces an earlier label, kind, or type.✅
c4-no-undefDisallow a style update whose target does not exist when the update is read.✅
c4-no-useless-argumentDisallow nonempty arguments beyond the parameters that a C4 call reads.✅

mindmap ​

RuleDescription✅🔧💡
mindmap-no-duplicate-decorationDisallow a second icon or a second class line for one node.✅💡
mindmap-no-mismatched-shapeDisallow a shape whose closer does not match its opener.✅💡

timeline ​

RuleDescription✅🔧💡
timeline-no-duplicate-descriptionDisallow an accDescr statement that sets the description again.✅💡
timeline-no-duplicate-titleDisallow a title or accTitle statement that sets its title again.✅💡
timeline-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡

sankey ​

RuleDescription✅🔧💡
sankey-no-empty-nodeDisallow a source or a target of whitespace only, which makes a node without a name.✅
sankey-no-invalid-valueDisallow a link value that mermaid.js does not read as written.✅🔧💡

xychart ​

RuleDescription✅🔧💡
xychart-no-duplicate-descriptionDisallow a statement that sets the description of the chart again.✅
xychart-no-duplicate-titleDisallow a title or accTitle statement that sets its title again.✅
xychart-no-empty-description-blockDisallow a description block that holds no description.✅
xychart-no-extra-valueDisallow a value of a plot beyond the categories of the x axis.✅
xychart-no-invalid-orientationDisallow an orientation that mermaid.js does not read as horizontal.✅🔧
xychart-no-redefined-axisDisallow an axis statement that replaces the title or the data of the axis.✅
xychart-no-unclosed-description-blockDisallow a description block that is not closed by }.✅💡

block ​

RuleDescription✅🔧💡
block-no-duplicate-blockDisallow declaring a block again.✅
block-no-duplicate-columnsDisallow a columns statement that changes the count of its block.✅💡
block-no-edge-chainDisallow an edge statement with more than one link.✅🔧
block-no-edge-in-composite-headDisallow a link in the head of a composite block.✅💡
block-no-invalid-directionDisallow a direction of a block arrow that is not one of the direction words.✅🔧
block-no-mismatched-edgeDisallow an edge with a label whose two arrows do not match.✅💡
block-no-mismatched-shapeDisallow a shape whose closing does not match its opening.✅💡
block-no-redefined-styleDisallow a style statement that loses a style of an earlier one.✅💡
block-no-spaced-class-idDisallow whitespace around a comma in the ids of a class statement.✅🔧
block-no-undefDisallow a class statement for an id that no block has.✅
block-no-useless-widthDisallow a width on the first block of an edge.✅💡

packet ​

RuleDescription✅🔧💡
packet-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
packet-no-duplicate-titleDisallow a title or an accTitle that replaces the title set before it.✅💡
packet-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡

kanban ​

RuleDescription✅🔧💡
kanban-no-duplicate-sectionDisallow a repeated section id that lists its items more than once.✅

architecture ​

RuleDescription✅🔧💡
architecture-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
architecture-no-duplicate-titleDisallow an accTitle that replaces the title set before it.✅💡
architecture-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
architecture-no-reversed-markerDisallow an arrowhead of an edge written pointing the other way.✅💡
architecture-no-ungrouped-modifierDisallow the {group} modifier on an end of an edge that is in no group.✅💡

radar ​

RuleDescription✅🔧💡
radar-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
radar-no-duplicate-entryDisallow an entry of a curve that gives another value for an axis that an earlier entry of the curve has.✅
radar-no-duplicate-optionDisallow an option that replaces the value of the same option before it.✅💡
radar-no-duplicate-titleDisallow a title or an accTitle that replaces the title set before it.✅💡
radar-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
radar-no-mismatched-entry-countDisallow a curve of values without axes whose count differs from the count of the axes.✅
radar-no-reversed-rangeDisallow a min above the max of a diagram.✅💡
radar-no-unclosed-description-blockDisallow an accDescr { block that a } written for a later statement closes.
radar-no-undefDisallow an entry of a curve that names no axis.✅

eventmodeling ​

RuleDescription✅🔧💡
eventmodeling-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
eventmodeling-no-duplicate-titleDisallow an accTitle that replaces the accessible title set before it.✅💡
eventmodeling-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
eventmodeling-no-redefined-dataDisallow a data block that no frame can show, because an earlier block has its name.✅
eventmodeling-no-unclosed-description-blockDisallow an accDescr { block that a } written for a later statement closes.
eventmodeling-no-undefDisallow a source or a data reference that names nothing.✅

treemap ​

RuleDescription✅🔧💡
treemap-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
treemap-no-duplicate-titleDisallow a title or an accTitle that replaces the title set before it.✅💡
treemap-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
treemap-no-invalid-valueDisallow a value of a leaf that mermaid.js reads as another number.✅🔧💡

venn ​

RuleDescription✅🔧💡
venn-no-duplicate-styleDisallow a style that replaces an earlier value of the same target.✅💡
venn-no-duplicate-subsetDisallow a set or a union that is declared again.✅
venn-no-duplicate-titleDisallow a title that replaces a different title.✅💡
venn-no-ignored-textDisallow a character that the comment after it removes.✅
venn-no-invalid-style-keyDisallow a style property that the drawing does not read.✅🔧💡
venn-no-undefDisallow a text node or a style for an area that no set or union declares.✅

wardley ​

RuleDescription✅🔧💡
wardley-no-duplicate-annotationsDisallow an annotations after the first that gives the box of the annotations another position.✅💡
wardley-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
wardley-no-duplicate-evolutionDisallow an evolution that replaces the stages set before it.✅💡
wardley-no-duplicate-evolveDisallow an evolve that replaces the target of an earlier evolve of the same node.✅💡
wardley-no-duplicate-pipelineDisallow a pipeline that replaces the children of an earlier pipeline of the same parent.✅
wardley-no-duplicate-sizeDisallow a size that replaces the size set before it.✅💡
wardley-no-duplicate-titleDisallow a title or an accTitle that replaces the title set before it.✅💡
wardley-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
wardley-no-ignored-link-labelDisallow a label after ; that the label in the arrow of the link replaces.✅💡
wardley-no-redefined-nodeDisallow a node declared again with other values.✅
wardley-no-undefDisallow a link or an evolve that names no node.✅

cynefin ​

RuleDescription✅🔧💡
cynefin-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
cynefin-no-duplicate-titleDisallow a title or an accTitle that replaces the title set before it.✅💡
cynefin-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
cynefin-no-redefined-domainDisallow a domain written again without an item that it had before.✅💡

treeview ​

RuleDescription✅🔧💡
treeview-no-duplicate-annotationDisallow an annotation that replaces an annotation of the same kind on one node.✅💡
treeview-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
treeview-no-duplicate-titleDisallow an accTitle that replaces the accessible title set before it.✅💡
treeview-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
treeview-no-unclosed-description-blockDisallow an accDescr { block that no } closes.✅

agentflow ​

RuleDescription✅🔧💡
agentflow-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
agentflow-no-duplicate-directionDisallow a direction statement that replaces the direction of its flow.✅💡
agentflow-no-duplicate-titleDisallow an accTitle that replaces the title set before it.✅💡
agentflow-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡
agentflow-no-ignored-textDisallow text that mermaid.js drops from a direction line.✅
agentflow-no-redefined-connectorDisallow a connector declaration that replaces the title or the vertex written for its id before, or that a later flow does not get.✅
agentflow-no-redefined-flowDisallow a flow declaration that replaces the title written for its id before.✅
agentflow-no-redefined-vertexDisallow a vertex that replaces the label or the shape written for its id before, or that a later flow does not get.✅
agentflow-no-spaced-strokeDisallow whitespace before the : of a stroke style.🔧
agentflow-no-unclosed-description-blockDisallow an accDescr { block that is not closed by }.💡
agentflow-no-undefDisallow a style, class, or click statement for an id that nothing declares.✅

railroad ​

RuleDescription✅🔧💡
railroad-no-duplicate-descriptionDisallow an accDescr that replaces the description set before it.✅💡
railroad-no-duplicate-titleDisallow an accTitle that replaces the title set before it.✅💡
railroad-no-empty-description-blockDisallow an accDescr block that holds no description.✅💡

Third-party tools for Mermaid diagram text.