English
@mmd-toolkit/flowchart-no-duplicate-direction
Disallow a direction statement that replaces the direction of its subgraph.
✅ The recommended configuration enables this rule.
💡 This rule is manually fixable by editor suggestions.
A direction statement sets the direction of its subgraph. A later one in the same subgraph replaces it without an error, and the earlier direction is lost.
Rule Details
This rule applies to flowcharts (flowchart, graph, flowchart-elk, and swimlane-beta). It reports a direction statement that changes the direction set by an earlier statement in the same subgraph. Statements count for the subgraph whose body they stand in directly, including direction lines with other text on them.
mermaid.js draws subgraphs of the same id as one, using the first subgraph's direction. A direction in a later subgraph of that id is reported when it differs from the first subgraph's direction, including when the first has no direction.
Repeating the current direction is not reported, and TD and TB both mean top to bottom. Going back to an earlier direction is reported: after direction LR and direction BT, a third direction LR is reported.
Examples of incorrect code for this rule:
mmd
%% eslint @mmd-toolkit/flowchart-no-duplicate-direction: error
flowchart TD
subgraph S
direction LR
A --> B
direction BT
endExamples of correct code for this rule:
mmd
%% eslint @mmd-toolkit/flowchart-no-duplicate-direction: error
flowchart TD
subgraph S
direction LR
A --> B
endOptions
This rule has no options.
Related Rules
Further Reading
Version
This rule was introduced in @mmd-toolkit/eslint-plugin v0.1.0.