English
@mmd-toolkit/flowchart-no-redefined-subgraph
Disallow a subgraph declaration whose title differs from the title kept for its id.
✅ The recommended configuration enables this rule.
Repeating a subgraph id adds members to the same subgraph. mermaid.js keeps its first title, so a different title in another declaration is lost without an error.
Rule Details
This rule applies to flowcharts (flowchart, graph, flowchart-elk, and swimlane-beta). It reports a title in a declaration of the same subgraph id that differs from the title the subgraph keeps. That is the title of the first declaration, or the name it writes when it has no separate title, rather than a generated id.
A later declaration without a title, or with the title the subgraph already has, is not reported: it adds members without losing a title. A nested subgraph is read before its enclosing declaration finishes, so it supplies the title when both have the same id.
Title comparisons ignore whitespace at the ends, treat LF, CRLF, and CR as LF, and do not distinguish text, quoted text, and markdown text. Otherwise titles are compared as written, so differences in character references or HTML attribute quotes can be reported even when mermaid.js reads them as the same title.
Examples of incorrect code for this rule:
mmd
%% eslint @mmd-toolkit/flowchart-no-redefined-subgraph: error
flowchart LR
subgraph S[One]
A
end
subgraph S[Two]
B
endExamples of correct code for this rule:
mmd
%% eslint @mmd-toolkit/flowchart-no-redefined-subgraph: error
flowchart LR
subgraph S[One]
A
end
subgraph S
B
endmmd
%% eslint @mmd-toolkit/flowchart-no-redefined-subgraph: error
flowchart LR
subgraph S[One]
A
end
subgraph S[One]
B
endOptions
This rule has no options.
Related Rules
Further Reading
Version
This rule was introduced in @mmd-toolkit/eslint-plugin v0.1.0.